This commit is contained in:
InsanityAutomation
2019-05-26 13:57:49 -04:00
parent b128797198
commit ae025bcb67
292 changed files with 9659 additions and 3990 deletions
-10
View File
@@ -963,16 +963,6 @@
* The BLTouch probe uses a Hall effect sensor and emulates a servo.
*/
#define BLTOUCH
#if ENABLED(BLTOUCH)
//#define BLTOUCH_DELAY 500 // Minimum Command delay (ms). Enable and increase if needed
/**
* BLTouch V3.0 and newer smart series
* For genuine BLTouch 3.0 sensors. Clones may be confused by 3.0 command angles. YMMV.
* If the pin trigger is not detected, first try swapping the black and white wires then toggle this.
*/
//#define BLTOUCH_FORCE_5V_MODE
#endif
// A probe that is deployed and stowed with a solenoid pin (SOL1_PIN)
//#define SOLENOID_PROBE
+69 -1
View File
@@ -537,6 +537,73 @@
// Enable this if X or Y can't home without homing the other axis first.
//#define CODEPENDENT_XY_HOMING
#if ENABLED(BLTOUCH)
/**
* Either: Use the defaults (recommended) or: For special purposes, use the following DEFINES
* Do not activate settings that the probe might not understand. Clones might misunderstand
* advanced commands.
*
* Note: If the probe is not deploying, check a "Cmd: Reset" and "Cmd: Self-Test" and then
* check the wiring of the BROWN, RED and ORANGE wires.
*
* Note: If the trigger signal of your probe is not being recognized, it has been very often
* because the BLACK and WHITE wires needed to be swapped. They are not "interchangeable"
* like they would be with a real switch. So please check the wiring first.
*
* Settings for all BLTouch and clone probes:
*/
// Safety: The probe needs time to recognize the command.
// Minimum command delay (ms). Enable and increase if needed.
//#define BLTOUCH_DELAY 500
/**
* Settings for BLTOUCH Classic 1.2, 1.3 or BLTouch Smart 1.0, 2.0, 2.2, 3.0, 3.1, and most clones:
*/
// Feature: Switch into SW mode after a deploy. It makes the output pulse longer. Can be useful
// in special cases, like noisy or filtered input configurations.
//#define BLTOUCH_FORCE_SW_MODE
/**
* Settings for BLTouch Smart 3.0 and 3.1
* Summary:
* - Voltage modes: 5V and OD (open drain - "logic voltage free") output modes
* - High-Speed mode
* - Disable LCD voltage options
*/
/**
* Danger: Don't activate 5V mode unless attached to a 5V-tolerant controller!
* V3.0 or 3.1: Set default mode to 5V mode at Marlin startup.
* If disabled, OD mode is the hard-coded default on 3.0
* On startup, Marlin will compare its eeprom to this vale. If the selected mode
* differs, a mode set eeprom write will be completed at initialization.
* Use the option below to force an eeprom write to a V3.1 probe regardless.
*/
//#define BLTOUCH_SET_5V_MODE
/**
* Safety: Activate if connecting a probe with an unknown voltage mode.
* V3.0: Set a probe into mode selected above at Marlin startup. Required for 5V mode on 3.0
* V3.1: Force a probe with unknown mode into selected mode at Marlin startup ( = Probe EEPROM write )
* To preserve the life of the probe, use this once then turn it off and re-flash.
*/
//#define BLTOUCH_FORCE_MODE_SET
/**
* Use "HIGH SPEED" mode for probing.
* Danger: Disable if your probe sometimes fails. Only suitable for stable well-adjusted systems.
* This feature was designed for Delta's with very fast Z moves however higher speed cartesians may function
* If the machine cannot raise the probe fast enough after a trigger, it may enter a fault state.
*/
//#define BLTOUCH_HS_MODE
// Safety: Enable voltage mode settings in the LCD menu.
#define BLTOUCH_LCD_VOLTAGE_MENU
#endif // BLTOUCH
/**
* Z Steppers Auto-Alignment
* Add the G34 command to align multiple Z steppers using a bed probe.
@@ -1365,7 +1432,7 @@
* Note that M207 / M208 / M209 settings are saved to EEPROM.
*
*/
#define FWRETRACT
//#define FWRETRACT
#if ENABLED(FWRETRACT)
#define FWRETRACT_AUTORETRACT // costs ~500 bytes of PROGMEM
#if ENABLED(FWRETRACT_AUTORETRACT)
@@ -1392,6 +1459,7 @@
#if EXTRUDERS > 1
// Z raise distance for tool-change, as needed for some extruders
#define TOOLCHANGE_ZRAISE 1 // (mm)
#define TOOLCHANGE_RETURN_NEXT_MOVE // Instead of returning to old position, wait for next move command
// Retract and prime filament on tool-change
#define TOOLCHANGE_FILAMENT_SWAP
+21 -21
View File
@@ -1,24 +1,24 @@
/* **************************************************************************
Marlin 3D Printer Firmware
Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifdef __AVR__
+4 -4
View File
@@ -75,16 +75,16 @@
#endif
typedef enum {
#if ENABLED(_useTimer1)
#ifdef _useTimer1
_timer1,
#endif
#if ENABLED(_useTimer3)
#ifdef _useTimer3
_timer3,
#endif
#if ENABLED(_useTimer4)
#ifdef _useTimer4
_timer4,
#endif
#if ENABLED(_useTimer5)
#ifdef _useTimer5
_timer5,
#endif
_Nbr_16timers
+235 -214
View File
@@ -1,250 +1,271 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifdef __AVR__
#include "../../inc/MarlinConfigPre.h"
/**
* get_pwm_timer
* Grabs timer information and registers of the provided pin
* returns Timer struct containing this information
* Used by set_pwm_frequency, set_pwm_duty
*
*/
#if ENABLED(FAST_PWM_FAN)
#include "HAL.h"
struct Timer {
volatile uint8_t* TCCRnQ[3]; // max 3 TCCR registers per timer
volatile uint16_t* OCRnQ[3]; // max 3 OCR registers per timer
volatile uint16_t* ICRn; // max 1 ICR register per timer
uint8_t n; // the timer number [0->5]
uint8_t q; // the timer output [0->2] (A->C)
};
struct Timer {
volatile uint8_t* TCCRnQ[3]; // max 3 TCCR registers per timer
volatile uint16_t* OCRnQ[3]; // max 3 OCR registers per timer
volatile uint16_t* ICRn; // max 1 ICR register per timer
uint8_t n; // the timer number [0->5]
uint8_t q; // the timer output [0->2] (A->C)
};
Timer get_pwm_timer(pin_t pin) {
uint8_t q = 0;
switch (digitalPinToTimer(pin)) {
// Protect reserved timers (TIMER0 & TIMER1)
#ifdef TCCR0A
#if !AVR_AT90USB1286_FAMILY
case TIMER0A:
#endif
case TIMER0B:
/**
* get_pwm_timer
* Get the timer information and register of the provided pin.
* Return a Timer struct containing this information.
* Used by set_pwm_frequency, set_pwm_duty
*/
Timer get_pwm_timer(const pin_t pin) {
uint8_t q = 0;
switch (digitalPinToTimer(pin)) {
// Protect reserved timers (TIMER0 & TIMER1)
#ifdef TCCR0A
#if !AVR_AT90USB1286_FAMILY
case TIMER0A:
#endif
#ifdef TCCR1A
case TIMER1A: case TIMER1B:
#endif
break;
#if defined(TCCR2) || defined(TCCR2A)
#ifdef TCCR2
case TIMER2: {
case TIMER0B:
#endif
#ifdef TCCR1A
case TIMER1A: case TIMER1B:
#endif
break;
#if defined(TCCR2) || defined(TCCR2A)
#ifdef TCCR2
case TIMER2: {
Timer timer = {
/*TCCRnQ*/ { &TCCR2, nullptr, nullptr},
/*OCRnQ*/ { (uint16_t*)&OCR2, nullptr, nullptr},
/*ICRn*/ nullptr,
/*n, q*/ 2, 0
};
}
#elif defined TCCR2A
#if ENABLED(USE_OCR2A_AS_TOP)
case TIMER2A: break; // protect TIMER2A
case TIMER2B: {
Timer timer = {
/*TCCRnQ*/ { &TCCR2, nullptr, nullptr},
/*OCRnQ*/ { (uint16_t*)&OCR2, nullptr, nullptr},
/*TCCRnQ*/ { &TCCR2A, &TCCR2B, nullptr},
/*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr},
/*ICRn*/ nullptr,
/*n, q*/ 2, 0
/*n, q*/ 2, 1
};
return timer;
}
#else
case TIMER2B: ++q;
case TIMER2A: {
Timer timer = {
/*TCCRnQ*/ { &TCCR2A, &TCCR2B, nullptr},
/*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr},
/*ICRn*/ nullptr,
2, q
};
return timer;
}
#elif defined TCCR2A
#if ENABLED(USE_OCR2A_AS_TOP)
case TIMER2A: break; // protect TIMER2A
case TIMER2B: {
Timer timer = {
/*TCCRnQ*/ { &TCCR2A, &TCCR2B, nullptr},
/*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr},
/*ICRn*/ nullptr,
/*n, q*/ 2, 1
};
return timer;
}
#else
case TIMER2B: ++q;
case TIMER2A: {
Timer timer = {
/*TCCRnQ*/ { &TCCR2A, &TCCR2B, nullptr},
/*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr},
/*ICRn*/ nullptr,
2, q
};
return timer;
}
#endif
#endif
#endif
#ifdef TCCR3A
case TIMER3C: ++q;
case TIMER3B: ++q;
case TIMER3A: {
Timer timer = {
/*TCCRnQ*/ { &TCCR3A, &TCCR3B, &TCCR3C},
/*OCRnQ*/ { &OCR3A, &OCR3B, &OCR3C},
/*ICRn*/ &ICR3,
/*n, q*/ 3, q
};
return timer;
}
#endif
#ifdef TCCR4A
case TIMER4C: ++q;
case TIMER4B: ++q;
case TIMER4A: {
Timer timer = {
/*TCCRnQ*/ { &TCCR4A, &TCCR4B, &TCCR4C},
/*OCRnQ*/ { &OCR4A, &OCR4B, &OCR4C},
/*ICRn*/ &ICR4,
/*n, q*/ 4, q
};
return timer;
}
#endif
#ifdef TCCR5A
case TIMER5C: ++q;
case TIMER5B: ++q;
case TIMER5A: {
Timer timer = {
/*TCCRnQ*/ { &TCCR5A, &TCCR5B, &TCCR5C},
/*OCRnQ*/ { &OCR5A, &OCR5B, &OCR5C },
/*ICRn*/ &ICR5,
/*n, q*/ 5, q
};
return timer;
}
#endif
}
Timer timer = {
/*TCCRnQ*/ { nullptr, nullptr, nullptr},
/*OCRnQ*/ { nullptr, nullptr, nullptr},
/*ICRn*/ nullptr,
0, 0
};
return timer;
#endif
#ifdef TCCR3A
case TIMER3C: ++q;
case TIMER3B: ++q;
case TIMER3A: {
Timer timer = {
/*TCCRnQ*/ { &TCCR3A, &TCCR3B, &TCCR3C},
/*OCRnQ*/ { &OCR3A, &OCR3B, &OCR3C},
/*ICRn*/ &ICR3,
/*n, q*/ 3, q
};
return timer;
}
#endif
#ifdef TCCR4A
case TIMER4C: ++q;
case TIMER4B: ++q;
case TIMER4A: {
Timer timer = {
/*TCCRnQ*/ { &TCCR4A, &TCCR4B, &TCCR4C},
/*OCRnQ*/ { &OCR4A, &OCR4B, &OCR4C},
/*ICRn*/ &ICR4,
/*n, q*/ 4, q
};
return timer;
}
#endif
#ifdef TCCR5A
case TIMER5C: ++q;
case TIMER5B: ++q;
case TIMER5A: {
Timer timer = {
/*TCCRnQ*/ { &TCCR5A, &TCCR5B, &TCCR5C},
/*OCRnQ*/ { &OCR5A, &OCR5B, &OCR5C },
/*ICRn*/ &ICR5,
/*n, q*/ 5, q
};
return timer;
}
#endif
}
Timer timer = {
/*TCCRnQ*/ { nullptr, nullptr, nullptr},
/*OCRnQ*/ { nullptr, nullptr, nullptr},
/*ICRn*/ nullptr,
0, 0
};
return timer;
}
void set_pwm_frequency(const pin_t pin, int f_desired) {
Timer timer = get_pwm_timer(pin);
if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
uint16_t size;
if (timer.n == 2) size = 255; else size = 65535;
void set_pwm_frequency(const pin_t pin, int f_desired) {
Timer timer = get_pwm_timer(pin);
if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
uint16_t size;
if (timer.n == 2) size = 255; else size = 65535;
uint16_t res = 255; // resolution (TOP value)
uint8_t j = 0; // prescaler index
uint8_t wgm = 1; // waveform generation mode
uint16_t res = 255; // resolution (TOP value)
uint8_t j = 0; // prescaler index
uint8_t wgm = 1; // waveform generation mode
// Calculating the prescaler and resolution to use to achieve closest frequency
if (f_desired != 0) {
int f = (F_CPU) / (2 * 1024 * size) + 1; // Initialize frequency as lowest (non-zero) achievable
uint16_t prescaler[] = { 0, 1, 8, /*TIMER2 ONLY*/32, 64, /*TIMER2 ONLY*/128, 256, 1024 };
// Calculating the prescaler and resolution to use to achieve closest frequency
if (f_desired != 0) {
int f = (F_CPU) / (2 * 1024 * size) + 1; // Initialize frequency as lowest (non-zero) achievable
uint16_t prescaler[] = { 0, 1, 8, /*TIMER2 ONLY*/32, 64, /*TIMER2 ONLY*/128, 256, 1024 };
// loop over prescaler values
for (uint8_t i = 1; i < 8; i++) {
uint16_t res_temp_fast = 255, res_temp_phase_correct = 255;
if (timer.n == 2) {
// No resolution calculation for TIMER2 unless enabled USE_OCR2A_AS_TOP
#if ENABLED(USE_OCR2A_AS_TOP)
const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired);
res_temp_fast = rtf - 1;
res_temp_phase_correct = rtf / 2;
#endif
}
else {
// Skip TIMER2 specific prescalers when not TIMER2
if (i == 3 || i == 5) continue;
// loop over prescaler values
for (uint8_t i = 1; i < 8; i++) {
uint16_t res_temp_fast = 255, res_temp_phase_correct = 255;
if (timer.n == 2) {
// No resolution calculation for TIMER2 unless enabled USE_OCR2A_AS_TOP
#if ENABLED(USE_OCR2A_AS_TOP)
const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired);
res_temp_fast = rtf - 1;
res_temp_phase_correct = rtf / 2;
}
#endif
}
else {
// Skip TIMER2 specific prescalers when not TIMER2
if (i == 3 || i == 5) continue;
const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired);
res_temp_fast = rtf - 1;
res_temp_phase_correct = rtf / 2;
}
LIMIT(res_temp_fast, 1u, size);
LIMIT(res_temp_phase_correct, 1u, size);
// Calculate frequencies of test prescaler and resolution values
const int f_temp_fast = (F_CPU) / (prescaler[i] * (1 + res_temp_fast)),
f_temp_phase_correct = (F_CPU) / (2 * prescaler[i] * res_temp_phase_correct),
f_diff = ABS(f - f_desired),
f_fast_diff = ABS(f_temp_fast - f_desired),
f_phase_diff = ABS(f_temp_phase_correct - f_desired);
LIMIT(res_temp_fast, 1u, size);
LIMIT(res_temp_phase_correct, 1u, size);
// Calculate frequencies of test prescaler and resolution values
const int f_temp_fast = (F_CPU) / (prescaler[i] * (1 + res_temp_fast)),
f_temp_phase_correct = (F_CPU) / (2 * prescaler[i] * res_temp_phase_correct),
f_diff = ABS(f - f_desired),
f_fast_diff = ABS(f_temp_fast - f_desired),
f_phase_diff = ABS(f_temp_phase_correct - f_desired);
// If FAST values are closest to desired f
if (f_fast_diff < f_diff && f_fast_diff <= f_phase_diff) {
// Remember this combination
f = f_temp_fast;
res = res_temp_fast;
j = i;
// Set the Wave Generation Mode to FAST PWM
if (timer.n == 2) {
wgm = (
#if ENABLED(USE_OCR2A_AS_TOP)
WGM2_FAST_PWM_OCR2A
#else
WGM2_FAST_PWM
#endif
);
}
else wgm = WGM_FAST_PWM_ICRn;
// If FAST values are closest to desired f
if (f_fast_diff < f_diff && f_fast_diff <= f_phase_diff) {
// Remember this combination
f = f_temp_fast;
res = res_temp_fast;
j = i;
// Set the Wave Generation Mode to FAST PWM
if (timer.n == 2) {
wgm = (
#if ENABLED(USE_OCR2A_AS_TOP)
WGM2_FAST_PWM_OCR2A
#else
WGM2_FAST_PWM
#endif
);
}
// If PHASE CORRECT values are closes to desired f
else if (f_phase_diff < f_diff) {
f = f_temp_phase_correct;
res = res_temp_phase_correct;
j = i;
// Set the Wave Generation Mode to PWM PHASE CORRECT
if (timer.n == 2) {
wgm = (
#if ENABLED(USE_OCR2A_AS_TOP)
WGM2_PWM_PC_OCR2A
#else
WGM2_PWM_PC
#endif
);
}
else wgm = WGM_PWM_PC_ICRn;
else wgm = WGM_FAST_PWM_ICRn;
}
// If PHASE CORRECT values are closes to desired f
else if (f_phase_diff < f_diff) {
f = f_temp_phase_correct;
res = res_temp_phase_correct;
j = i;
// Set the Wave Generation Mode to PWM PHASE CORRECT
if (timer.n == 2) {
wgm = (
#if ENABLED(USE_OCR2A_AS_TOP)
WGM2_PWM_PC_OCR2A
#else
WGM2_PWM_PC
#endif
);
}
else wgm = WGM_PWM_PC_ICRn;
}
}
_SET_WGMnQ(timer.TCCRnQ, wgm);
_SET_CSn(timer.TCCRnQ, j);
}
_SET_WGMnQ(timer.TCCRnQ, wgm);
_SET_CSn(timer.TCCRnQ, j);
if (timer.n == 2) {
#if ENABLED(USE_OCR2A_AS_TOP)
_SET_OCRnQ(timer.OCRnQ, 0, res); // Set OCR2A value (TOP) = res
#endif
if (timer.n == 2) {
#if ENABLED(USE_OCR2A_AS_TOP)
_SET_OCRnQ(timer.OCRnQ, 0, res); // Set OCR2A value (TOP) = res
#endif
}
else
_SET_ICRn(timer.ICRn, res); // Set ICRn value (TOP) = res
}
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
// If v is 0 or v_size (max), digitalWrite to LOW or HIGH.
// Note that digitalWrite also disables pwm output for us (sets COM bit to 0)
if (v == 0)
digitalWrite(pin, invert);
else if (v == v_size)
digitalWrite(pin, !invert);
else {
Timer timer = get_pwm_timer(pin);
if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
// Set compare output mode to CLEAR -> SET or SET -> CLEAR (if inverted)
_SET_COMnQ(timer.TCCRnQ, (timer.q
#ifdef TCCR2
+ (timer.q == 2) // COM20 is on bit 4 of TCCR2, thus requires q + 1 in the macro
#endif
), COM_CLEAR_SET + invert
);
uint16_t top;
if (timer.n == 2) { // if TIMER2
top = (
#if ENABLED(USE_OCR2A_AS_TOP)
*timer.OCRnQ[0] // top = OCR2A
#else
255 // top = 0xFF (max)
#endif
);
}
else
_SET_ICRn(timer.ICRn, res); // Set ICRn value (TOP) = res
}
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
// If v is 0 or v_size (max), digitalWrite to LOW or HIGH.
// Note that digitalWrite also disables pwm output for us (sets COM bit to 0)
if (v == 0)
digitalWrite(pin, invert);
else if (v == v_size)
digitalWrite(pin, !invert);
else {
Timer timer = get_pwm_timer(pin);
if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
// Set compare output mode to CLEAR -> SET or SET -> CLEAR (if inverted)
_SET_COMnQ(timer.TCCRnQ, (timer.q
#ifdef TCCR2
+ (timer.q == 2) // COM20 is on bit 4 of TCCR2, thus requires q + 1 in the macro
#endif
), COM_CLEAR_SET + invert
);
uint16_t top;
if (timer.n == 2) { // if TIMER2
top = (
#if ENABLED(USE_OCR2A_AS_TOP)
*timer.OCRnQ[0] // top = OCR2A
#else
255 // top = 0xFF (max)
#endif
);
}
else
top = *timer.ICRn; // top = ICRn
_SET_OCRnQ(timer.OCRnQ, timer.q, v * float(top / v_size)); // Scale 8/16-bit v to top value
}
top = *timer.ICRn; // top = ICRn
_SET_OCRnQ(timer.OCRnQ, timer.q, v * float(top / v_size)); // Scale 8/16-bit v to top value
}
}
#endif // FAST_PWM_FAN
#endif // __AVR__
+1 -5
View File
@@ -81,9 +81,8 @@
#define _SET_INPUT(IO) CBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
#define _SET_OUTPUT(IO) SBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
#define _IS_INPUT(IO) !TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
#define _IS_INPUT(IO) !TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
#define _IS_OUTPUT(IO) TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
#define _HAS_TIMER(IO) bool(DIO ## IO ## _PWM)
// digitalRead/Write wrappers
#ifdef FASTIO_EXT_START
@@ -106,7 +105,6 @@
#define IS_INPUT(IO) _IS_INPUT(IO)
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
#define HAS_TIMER(IO) _HAS_TIMER(IO)
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
@@ -353,5 +351,3 @@ enum ClockSource2 : char {
#else
#error "unknown CPU"
#endif
#define USEABLE_HARDWARE_PWM(P) (PWM_PIN(P) && !PWM_CHK(P))
+10 -10
View File
@@ -95,29 +95,29 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform
// Interrupt handlers for Arduino
#if ENABLED(_useTimer1)
#ifdef _useTimer1
SIGNAL(TIMER1_COMPA_vect) { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
#endif
#if ENABLED(_useTimer3)
#ifdef _useTimer3
SIGNAL(TIMER3_COMPA_vect) { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
#endif
#if ENABLED(_useTimer4)
#ifdef _useTimer4
SIGNAL(TIMER4_COMPA_vect) { handle_interrupts(_timer4, &TCNT4, &OCR4A); }
#endif
#if ENABLED(_useTimer5)
#ifdef _useTimer5
SIGNAL(TIMER5_COMPA_vect) { handle_interrupts(_timer5, &TCNT5, &OCR5A); }
#endif
#else // WIRING
// Interrupt handlers for Wiring
#if ENABLED(_useTimer1)
#ifdef _useTimer1
void Timer1Service() { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
#endif
#if ENABLED(_useTimer3)
#ifdef _useTimer3
void Timer3Service() { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
#endif
@@ -126,7 +126,7 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
/****************** end of static functions ******************************/
void initISR(timer16_Sequence_t timer) {
#if ENABLED(_useTimer1)
#ifdef _useTimer1
if (timer == _timer1) {
TCCR1A = 0; // normal counting mode
TCCR1B = _BV(CS11); // set prescaler of 8
@@ -145,7 +145,7 @@ void initISR(timer16_Sequence_t timer) {
}
#endif
#if ENABLED(_useTimer3)
#ifdef _useTimer3
if (timer == _timer3) {
TCCR3A = 0; // normal counting mode
TCCR3B = _BV(CS31); // set prescaler of 8
@@ -163,7 +163,7 @@ void initISR(timer16_Sequence_t timer) {
}
#endif
#if ENABLED(_useTimer4)
#ifdef _useTimer4
if (timer == _timer4) {
TCCR4A = 0; // normal counting mode
TCCR4B = _BV(CS41); // set prescaler of 8
@@ -173,7 +173,7 @@ void initISR(timer16_Sequence_t timer) {
}
#endif
#if ENABLED(_useTimer5)
#ifdef _useTimer5
if (timer == _timer5) {
TCCR5A = 0; // normal counting mode
TCCR5B = _BV(CS51); // set prescaler of 8
-15
View File
@@ -78,14 +78,6 @@
#undef pgm_read_word
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
#define RST_POWER_ON 1
#define RST_EXTERNAL 2
#define RST_BROWN_OUT 4
#define RST_WATCHDOG 8
#define RST_JTAG 16
#define RST_SOFTWARE 32
#define RST_BACKUP 64
typedef int8_t pin_t;
#define HAL_SERVO_LIB Servo
@@ -143,13 +135,6 @@ inline void HAL_adc_init(void) {}//todo
void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result(void);
uint16_t HAL_getAdcReading(uint8_t chan);
void HAL_startAdcConversion(uint8_t chan);
uint8_t HAL_pinToAdcChannel(int pin);
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
void HAL_enable_AdcFreerun(void);
//void HAL_disable_AdcFreerun(uint8_t chan);
//
// Pin Map
-3
View File
@@ -46,7 +46,6 @@
// Due has 12 PWMs assigned to logical pins 2-13.
// 6, 7, 8 & 9 come from the PWM controller. The others come from the timers.
#define PWM_PIN(P) WITHIN(P, 2, 13)
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
#ifndef MASK
#define MASK(PIN) (1 << PIN)
@@ -180,8 +179,6 @@
#define IS_INPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) == 0)
// Check if pin is an output
#define IS_OUTPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
// Check if pin is a timer - Must be a constexpr
#define HAS_TIMER(IO) ((IO) >= 2 && (IO) <= 13)
// Shorthand
#define OUT_WRITE(IO,V) { SET_OUTPUT(IO); WRITE(IO,V); }
@@ -59,12 +59,12 @@
#if ENABLED(U8GLIB_ST7920)
#include "u8g_com_HAL_DUE_sw_spi_shared.h"
#include "../shared/Delay.h"
#include <U8glib.h>
#include "u8g_com_HAL_DUE_sw_spi_shared.h"
#define SPISEND_SW_DUE u8g_spiSend_sw_DUE_mode_0
static uint8_t rs_last_state = 255;
@@ -59,12 +59,12 @@
#if HAS_GRAPHICAL_LCD
#include "u8g_com_HAL_DUE_sw_spi_shared.h"
#include "../shared/Delay.h"
#include <U8glib.h>
#include "u8g_com_HAL_DUE_sw_spi_shared.h"
void u8g_SetPIOutput_DUE(u8g_t *u8g, uint8_t pin_index) {
PIO_Configure(g_APinDescription[u8g->pin_list[pin_index]].pPort, PIO_OUTPUT_1,
g_APinDescription[u8g->pin_list[pin_index]].ulPin, g_APinDescription[u8g->pin_list[pin_index]].ulPinConfiguration); // OUTPUT
+47 -26
View File
@@ -33,6 +33,10 @@
#include "../../inc/MarlinConfigPre.h"
#if EITHER(EEPROM_SETTINGS, WEBSUPPORT)
#include "spiffs.h"
#endif
#if ENABLED(WIFISUPPORT)
#include <ESPAsyncWebServer.h>
#include "wifi.h"
@@ -41,10 +45,7 @@
#endif
#if ENABLED(WEBSUPPORT)
#include "web.h"
#include "spiffs.h"
#endif
#elif ENABLED(EEPROM_SETTINGS)
#include "spiffs.h"
#endif
// --------------------------------------------------------------------------
@@ -92,21 +93,24 @@ esp_adc_cal_characteristics_t characteristics;
// --------------------------------------------------------------------------
void HAL_init(void) {
i2s_init();
}
void HAL_init_board(void) {
#if EITHER(EEPROM_SETTINGS, WEBSUPPORT)
spiffs_init();
#endif
#if ENABLED(WIFISUPPORT)
wifi_init();
#if ENABLED(OTASUPPORT)
OTA_init();
#endif
#if ENABLED(WEBSUPPORT)
spiffs_init();
web_init();
#endif
server.begin();
#elif ENABLED(EEPROM_SETTINGS)
spiffs_init();
#endif
i2s_init();
}
void HAL_idletask(void) {
@@ -117,18 +121,12 @@ void HAL_idletask(void) {
void HAL_clear_reset_source(void) { }
uint8_t HAL_get_reset_source(void) {
return rtc_get_reset_reason(1);
}
uint8_t HAL_get_reset_source(void) { return rtc_get_reset_reason(1); }
void _delay_ms(int delay_ms) {
delay(delay_ms);
}
void _delay_ms(int delay_ms) { delay(delay_ms); }
// return free memory between end of heap (or end bss) and whatever is current
int freeMemory() {
return ESP.getFreeHeap();
}
int freeMemory() { return ESP.getFreeHeap(); }
// --------------------------------------------------------------------------
// ADC
@@ -144,19 +142,41 @@ adc1_channel_t get_channel(int pin) {
case 33: return ADC1_CHANNEL(33);
case 32: return ADC1_CHANNEL(32);
}
return ADC1_CHANNEL_MAX;
}
void HAL_adc_init() {
// Configure ADC
adc1_config_width(ADC_WIDTH_12Bit);
adc1_config_channel_atten(get_channel(39), ADC_ATTEN_11db);
adc1_config_channel_atten(get_channel(36), ADC_ATTEN_11db);
adc1_config_channel_atten(get_channel(35), ADC_ATTEN_11db);
adc1_config_channel_atten(get_channel(34), ADC_ATTEN_11db);
adc1_config_channel_atten(get_channel(33), ADC_ATTEN_11db);
adc1_config_channel_atten(get_channel(32), ADC_ATTEN_11db);
// Configure channels only if used as (re-)configuring a pin for ADC that is used elsewhere might have adverse effects
#if HAS_TEMP_ADC_0
adc1_config_channel_atten(get_channel(TEMP_0_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_ADC_1
adc1_config_channel_atten(get_channel(TEMP_1_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_ADC_2
adc1_config_channel_atten(get_channel(TEMP_2_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_ADC_3
adc1_config_channel_atten(get_channel(TEMP_3_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_ADC_4
adc1_config_channel_atten(get_channel(TEMP_4_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_ADC_5
adc1_config_channel_atten(get_channel(TEMP_5_PIN), ADC_ATTEN_11db);
#endif
#if HAS_HEATED_BED
adc1_config_channel_atten(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_CHAMBER
adc1_config_channel_atten(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db);
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
adc1_config_channel_atten(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db);
#endif
// Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail.
// That's why we're not setting it up here.
@@ -172,9 +192,9 @@ void HAL_adc_start_conversion(uint8_t adc_pin) {
HAL_adc_result = mv*1023.0/3300.0;
}
int pin_to_channel[40] = {};
int cnt_channel = 1;
void analogWrite(int pin, int value) {
static int cnt_channel = 1,
pin_to_channel[40] = {};
if (pin_to_channel[pin] == 0) {
ledcAttachPin(pin, cnt_channel);
ledcSetup(cnt_channel, 490, 8);
@@ -185,4 +205,5 @@ void analogWrite(int pin, int value) {
ledcWrite(pin_to_channel[pin], value);
}
#endif // ARDUINO_ARCH_ESP32
+4
View File
@@ -75,6 +75,8 @@ extern portMUX_TYPE spinlock;
typedef int16_t pin_t;
#define HAL_SERVO_LIB Servo
// --------------------------------------------------------------------------
// Public Variables
// --------------------------------------------------------------------------
@@ -122,5 +124,7 @@ void HAL_adc_start_conversion(uint8_t adc_pin);
// Enable hooks into idle and setup for HAL
#define HAL_IDLETASK 1
#define HAL_INIT 1
#define BOARD_INIT() HAL_init_board();
void HAL_idletask(void);
void HAL_init(void);
void HAL_init_board(void);
@@ -0,0 +1,69 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifdef ARDUINO_ARCH_ESP32
#include "../../inc/MarlinConfig.h"
#if HAS_SERVOS
#include "HAL_Servo_ESP32.h"
int Servo::channel_next_free = 0;
Servo::Servo() {
this->channel = channel_next_free++;
}
int8_t Servo::attach(const int pin) {
if (this->channel >= CHANNEL_MAX_NUM) return -1;
if (pin > 0) this->pin = pin;
ledcSetup(this->channel, 50, 16); // channel X, 50 Hz, 16-bit depth
ledcAttachPin(this->pin, this->channel);
return true;
}
void Servo::detach() { ledcDetachPin(this->pin) }
int Servo::read() { return this->degrees; }
void Servo::write(int degrees) {
this->degrees = constrain(degrees, MIN_ANGLE, MAX_ANGLE);
int us = map(this->degrees, MIN_ANGLE, MAX_ANGLE, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
int duty = map(us, 0, TAU_USEC, 0, MAX_COMPARE);
ledcWrite(channel, duty);
}
void Servo::move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(0) >= 0) {
this->write(value);
safe_delay(servo_delay[this->channel]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
#endif
}
}
#endif // HAS_SERVOS
#endif // ARDUINO_ARCH_ESP32
@@ -0,0 +1,49 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <Arduino.h>
class Servo {
static const int MIN_ANGLE = 0,
MAX_ANGLE = 180,
MIN_PULSE_WIDTH = 544, // Shortest pulse sent to a servo
MAX_PULSE_WIDTH = 2400, // Longest pulse sent to a servo
TAU_MSEC = 20,
TAU_USEC = (TAU_MSEC * 1000),
MAX_COMPARE = ((1 << 16) - 1), // 65535
CHANNEL_MAX_NUM = 16;
public:
Servo();
int8_t attach(const int pin); // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail)
void detach();
void write(int degrees); // set angle
void move(const int degrees); // attach the servo, then move to value
int read(); // returns current pulse width as an angle between 0 and 180 degrees
private:
static int channel_next_free;
int channel;
int pin;
int degrees;
};
@@ -132,7 +132,7 @@ void HAL_timer_start(const uint8_t timer_num, uint32_t frequency) {
timer_enable_intr(timer.group, timer.idx);
// TODO need to deal with timer_group1_isr
timer_isr_register(timer.group, timer.idx, timer_group0_isr, (void*)timer.idx, ESP_INTR_FLAG_INTRDISABLED, nullptr);
timer_isr_register(timer.group, timer.idx, timer_group0_isr, (void*)timer.idx, 0, nullptr);
timer_start(timer.group, timer.idx);
}
@@ -169,10 +169,8 @@ hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
*/
hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
const tTimerConfig timer = TimerConfig[timer_num];
uint64_t counter_value;
timer_get_counter_value(timer.group, timer.idx, &counter_value);
return counter_value;
}
@@ -181,7 +179,7 @@ hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
* @param timer_num timer number to enable interrupts on
*/
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
const tTimerConfig timer = TimerConfig[timer_num];
//const tTimerConfig timer = TimerConfig[timer_num];
//timer_enable_intr(timer.group, timer.idx);
}
@@ -190,8 +188,8 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num) {
* @param timer_num timer number to disable interrupts on
*/
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
const tTimerConfig timer = TimerConfig[timer_num];
// timer_disable_intr(timer.group, timer.idx);
//const tTimerConfig timer = TimerConfig[timer_num];
//timer_disable_intr(timer.group, timer.idx);
}
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
@@ -28,6 +28,11 @@
#include <stdint.h>
#include "driver/timer.h"
// Includes needed to get I2S_STEPPER_STREAM. Note that pins.h
// is included in case this header is being included early.
#include "../../inc/MarlinConfig.h"
#include "../../pins/pins.h"
// --------------------------------------------------------------------------
// Defines
// --------------------------------------------------------------------------
+2 -2
View File
@@ -38,9 +38,9 @@ AsyncWebSocket ws("/ws"); // TODO Move inside the class.
RingBuffer::RingBuffer(ring_buffer_pos_t size)
: data(new uint8_t[size]),
size(size),
read_index(0),
write_index(0),
size(size)
write_index(0)
{}
RingBuffer::~RingBuffer() { delete[] data; }
-1
View File
@@ -67,7 +67,6 @@
// PWM outputs
#define PWM_PIN(P) (P < 34) // NOTE Pins >= 34 are input only on ESP32, so they can't be used for output.
#define USEABLE_HARDWARE_PWM(P) (!IS_I2S_EXPANDER_PIN(P) && PWM_PIN(P))
// Toggle pin value
#define TOGGLE(IO) WRITE(IO, !READ(IO))
@@ -28,25 +28,38 @@
#include "../shared/persistent_store_api.h"
#include "SPIFFS.h"
#include "FS.h"
#include <SPIFFS.h>
#include <FS.h>
#include "spiffs.h"
#define HAL_ESP32_EEPROM_SIZE 4096
#define HAL_ESP32_EEPROM_FILE_PATH "/eeprom.dat"
File eeprom_file;
bool PersistentStore::access_start() {
if (spiffs_initialized) {
eeprom_file = SPIFFS.open("/eeprom.dat", "r+");
eeprom_file = SPIFFS.open(HAL_ESP32_EEPROM_FILE_PATH, "r+");
size_t file_size = eeprom_file.size();
if (file_size < HAL_ESP32_EEPROM_SIZE) {
bool write_ok = eeprom_file.seek(file_size);
SERIAL_ECHO_MSG("SPIFFS EEPROM settings file " HAL_ESP32_EEPROM_FILE_PATH " is too small or did not exist, expanding.");
SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR(" file size: ", file_size, ", required size: ", HAL_ESP32_EEPROM_SIZE);
while (write_ok && file_size < HAL_ESP32_EEPROM_SIZE) {
write_ok = eeprom_file.write(0xFF) == 1;
file_size++;
// mode r+ does not allow to expand the file (at least on ESP32 SPIFFS9, so we close, reopen "a", append, close, reopen "r+"
eeprom_file.close();
eeprom_file = SPIFFS.open(HAL_ESP32_EEPROM_FILE_PATH, "a");
for (size_t i = eeprom_file.size(); i < HAL_ESP32_EEPROM_SIZE; i++)
eeprom_file.write(0xFF);
eeprom_file.close();
eeprom_file = SPIFFS.open(HAL_ESP32_EEPROM_FILE_PATH, "r+");
file_size = eeprom_file.size();
if (file_size < HAL_ESP32_EEPROM_SIZE) {
SERIAL_ERROR_MSG("Failed to expand " HAL_ESP32_EEPROM_FILE_PATH " to required size. SPIFFS partition full?");
SERIAL_ERROR_START(); SERIAL_ECHOLNPAIR(" file size: ", file_size, ", required size: ", HAL_ESP32_EEPROM_SIZE);
SERIAL_ERROR_START(); SERIAL_ECHOLNPAIR(" SPIFFS used bytes: ", SPIFFS.usedBytes(), ", total bytes: ", SPIFFS.totalBytes());
}
}
return true;
+4 -4
View File
@@ -28,16 +28,16 @@
#include "../../core/serial.h"
#include "FS.h"
#include "SPIFFS.h"
#include <FS.h>
#include <SPIFFS.h>
bool spiffs_initialized;
void spiffs_init() {
if (SPIFFS.begin())
if (SPIFFS.begin(true)) // formatOnFail = true
spiffs_initialized = true;
else
SERIAL_ECHO_MSG("SPIFFS mount failed");
SERIAL_ERROR_MSG("SPIFFS mount failed");
}
#endif // WEBSUPPORT
+1 -1
View File
@@ -26,7 +26,7 @@
#if ENABLED(WEBSUPPORT)
#include "SPIFFS.h"
#include <SPIFFS.h>
#include "wifi.h"
AsyncEventSource events("/events"); // event source (Server-Sent events)
+12 -3
View File
@@ -22,6 +22,7 @@
#ifdef ARDUINO_ARCH_ESP32
#include "../../core/serial.h"
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(WIFISUPPORT)
@@ -38,20 +39,28 @@ AsyncWebServer server(80);
#endif
void wifi_init() {
SERIAL_ECHO_MSG("Starting WiFi...");
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PWD);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
SERIAL_ERROR_MSG("Unable to connect to WiFi with SSID '" WIFI_SSID "', restarting.");
delay(5000);
ESP.restart();
}
delay(10);
// Loop forever (watchdog kill) on failure
if (!MDNS.begin(WIFI_HOSTNAME)) for(;;) delay(5000);
if (!MDNS.begin(WIFI_HOSTNAME)) {
SERIAL_ERROR_MSG("Unable to start mDNS with hostname '" WIFI_HOSTNAME "', restarting.");
delay(5000);
ESP.restart();
}
MDNS.addService("http", "tcp", 80);
SERIAL_ECHOLNPAIR("Successfully connected to WiFi with SSID '" WIFI_SSID "', hostname: '" WIFI_HOSTNAME "', IP address: ", WiFi.localIP().toString().c_str());
}
#endif // WIFISUPPORT
-15
View File
@@ -80,16 +80,6 @@
/// check if pin is an output
#define _IS_OUTPUT(IO) (LPC1768_PIN_PIN(IO) >= 0)
// hg42: HAS_TIMER is used only to check if it's a PWM pin
// hg42: we cannot use USEABLE_HARDWARE_PWM because it uses a function that cannot be used statically
// hg42: instead use PWM bit from the #define
/// check if pin is a timer
#define _HAS_TIMER(IO) true // could be LPC1768_PIN_PWM(IO), but there
// hg42: could be this:
// #define _HAS_TIMER(IO) LPC1768_PIN_PWM(IO)
// but this is an incomplete check (12 pins are PWMable, but only 6 can be used at the same time)
/// Read a pin wrapper
#define READ(IO) _READ(IO)
@@ -116,14 +106,9 @@
/// check if pin is an output wrapper
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
/// check if pin is a timer (wrapper)
#define HAS_TIMER(IO) _HAS_TIMER(IO)
// Shorthand
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
// digitalRead/Write wrappers
#define extDigitalRead(IO) digitalRead(IO)
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
-5
View File
@@ -21,11 +21,6 @@
*/
#pragma once
#define RST_POWER_ON 1
#define RST_EXTERNAL 2
#define RST_BROWN_OUT 4
#define RST_WATCHDOG 8
#define WDT_TIMEOUT 4000000 // 4 second timeout
void watchdog_init(void);
@@ -50,7 +50,7 @@
#include <Servo.h>
class MarlinServo: public Servo {
class libServo: public Servo {
public:
void move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
@@ -67,4 +67,4 @@ class MarlinServo: public Servo {
}
};
#define HAL_SERVO_LIB MarlinServo
#define HAL_SERVO_LIB libServo
+1 -9
View File
@@ -35,8 +35,7 @@
#include "../shared/Marduino.h"
#define PWM_PIN(P) true // all pins are PWM capable
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
#define PWM_PIN(P) true // all pins are PWM capable
#define LPC_PIN(pin) gpio_pin(pin)
#define LPC_GPIO(port) gpio_port(port)
@@ -89,10 +88,6 @@
/// check if pin is an output
#define _IS_OUTPUT(IO) (gpio_get_dir(IO))
/// check if pin is a timer
/// all gpio pins are pwm capable, either interrupt or hardware pwm controlled
#define _HAS_TIMER(IO) true
/// Read a pin wrapper
#define READ(IO) _READ(IO)
@@ -119,9 +114,6 @@
/// check if pin is an output wrapper
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
/// check if pin is a timer (wrapper)
#define HAS_TIMER(IO) _HAS_TIMER(IO)
// Shorthand
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
-5
View File
@@ -21,11 +21,6 @@
*/
#pragma once
#define RST_POWER_ON 1
#define RST_EXTERNAL 2
#define RST_BROWN_OUT 4
#define RST_WATCHDOG 8
#define WDT_TIMEOUT 4000000 // 4 second timeout
void watchdog_init(void);
-8
View File
@@ -127,14 +127,6 @@
#undef pgm_read_ptr
#define pgm_read_ptr(addr) (*(addr))
#define RST_POWER_ON 1
#define RST_EXTERNAL 2
#define RST_BROWN_OUT 4
#define RST_WATCHDOG 8
#define RST_JTAG 16
#define RST_SOFTWARE 32
#define RST_BACKUP 64
// --------------------------------------------------------------------------
// Types
// --------------------------------------------------------------------------
+1 -3
View File
@@ -80,10 +80,8 @@ void FastIO_init(); // Must be called before using fast io macros
#define IS_INPUT(IO)
#define IS_OUTPUT(IO)
#define HAS_TIMER(IO) digitalPinHasPWM(IO)
#define PWM_PIN(P) HAS_TIMER(P)
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
#define PWM_PIN(P) digitalPinHasPWM(P)
// digitalRead/Write wrappers
#define extDigitalRead(IO) digitalRead(IO)
+1 -1
View File
@@ -1 +1 @@
#error "Debug pins is not yet supported for STM32!"
#error "PINS_DEBUGGING is not yet supported for STM32!"
-15
View File
@@ -253,23 +253,8 @@ void HAL_adc_init(void);
#define HAL_ADC_READY() true
void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result(void);
/* Todo: Confirm none of this is needed.
uint16_t HAL_getAdcReading(uint8_t chan);
void HAL_startAdcConversion(uint8_t chan);
uint8_t HAL_pinToAdcChannel(int pin);
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
void HAL_enable_AdcFreerun(void);
//void HAL_disable_AdcFreerun(uint8_t chan);
*/
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
@@ -27,7 +27,7 @@
#if HAS_SERVOS
uint8_t ServoCount; //=0
uint8_t ServoCount = 0;
#include "HAL_Servo_STM32F1.h"
@@ -68,16 +68,16 @@ libServo::libServo() {
bool libServo::attach(const int32_t pin, const int32_t minAngle, const int32_t maxAngle) {
if (this->servoIndex >= MAX_SERVOS) return false;
if (!PWM_PIN(pin)) return false;
this->pin = pin;
this->minAngle = minAngle;
this->maxAngle = maxAngle;
timer_dev *tdev = PIN_MAP[this->pin].timer_device;
uint8_t tchan = PIN_MAP[this->pin].timer_channel;
timer_dev *tdev = PIN_MAP[pin].timer_device;
uint8_t tchan = PIN_MAP[pin].timer_channel;
pinMode(this->pin, PWM);
pwmWrite(this->pin, 0);
pinMode(pin, PWM);
pwmWrite(pin, 0);
timer_pause(tdev);
timer_set_prescaler(tdev, SERVO_PRESCALER - 1); // prescaler is 1-based
@@ -85,6 +85,8 @@ bool libServo::attach(const int32_t pin, const int32_t minAngle, const int32_t m
timer_generate_update(tdev);
timer_resume(tdev);
this->pin = pin; // set attached()
return true;
}
@@ -21,7 +21,11 @@
*
*/
#if defined(ARDUINO_ARCH_STM32F1) && (defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY))
#ifdef ARDUINO_ARCH_STM32F1
#include <libmaple/stm32.h>
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
#include "HAL_sdio_STM32F1.h"
@@ -276,4 +280,5 @@ bool SDIO_GetCmdResp7(void) {
return true;
}
#endif // ARDUINO_ARCH_STM32F1 && (STM32_HIGH_DENSITY || STM32_XL_DENSITY)
#endif // STM32_HIGH_DENSITY || STM32_XL_DENSITY
#endif // ARDUINO_ARCH_STM32F1
+5 -4
View File
@@ -37,20 +37,21 @@
#define _GET_MODE(IO) gpio_get_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit)
#define _SET_MODE(IO,M) gpio_set_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit, M)
#define _SET_OUTPUT(IO) _SET_MODE(IO, GPIO_OUTPUT_PP)
#define _SET_OUTPUT_OD(IO) _SET_MODE(IO, GPIO_OUTPUT_OD)
#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); } while(0)
#define OUT_WRITE_OD(IO,V) do{ _SET_OUTPUT_OD(IO); WRITE(IO,V); } while(0)
#define SET_INPUT(IO) _SET_MODE(IO, GPIO_INPUT_FLOATING)
#define SET_INPUT_PULLUP(IO) _SET_MODE(IO, GPIO_INPUT_PU)
#define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
#define SET_PWM(IO) pinMode(IO, PWM) // do{ gpio_set_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, GPIO_AF_OUTPUT_PP); timer_set_mode(PIN_MAP[pin].timer_device, PIN_MAP[pin].timer_channel, TIMER_PWM); }while(0)
#define SET_PWM_OD(IO) pinMode(IO, PWM_OPEN_DRAIN)
#define IS_INPUT(IO) (_GET_MODE(IO) == GPIO_INPUT_FLOATING || _GET_MODE(IO) == GPIO_INPUT_ANALOG || _GET_MODE(IO) == GPIO_INPUT_PU || _GET_MODE(IO) == GPIO_INPUT_PD)
#define IS_OUTPUT(IO) (_GET_MODE(IO) == GPIO_OUTPUT_PP)
#define HAS_TIMER(IO) (PIN_MAP[IO].timer_device != nullptr)
#define PWM_PIN(P) HAS_TIMER(P)
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
#define PWM_PIN(IO) (PIN_MAP[IO].timer_device != nullptr)
// digitalRead/Write wrappers
#define extDigitalRead(IO) digitalRead(IO)
@@ -64,11 +64,11 @@ static char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
if (!card.isDetected()) return false;
SdFile file, root = card.getroot();
if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC))
return false;
int16_t bytes_written = file.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
file.close();
int16_t bytes_written = 0;
if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
bytes_written = file.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
file.close();
}
return (bytes_written == HAL_STM32F1_EEPROM_SIZE);
}
@@ -26,10 +26,10 @@
* Communication interface for FSMC
*/
#if defined(ARDUINO_ARCH_STM32F1) && (defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY))
#include "../../inc/MarlinConfig.h"
#if defined(ARDUINO_ARCH_STM32F1) && (defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY))
#if HAS_GRAPHICAL_LCD
#include "U8glib.h"
@@ -226,14 +226,19 @@ void LCD_IO_Init(uint8_t cs, uint8_t rs) {
gpio_set_mode(GPIOD, 9, GPIO_AF_OUTPUT_PP); // FSMC_D14
gpio_set_mode(GPIOD, 10, GPIO_AF_OUTPUT_PP); // FSMC_D15
gpio_set_mode(GPIOD, 4, GPIO_AF_OUTPUT_PP); // FSMC_NOE
gpio_set_mode(GPIOD, 5, GPIO_AF_OUTPUT_PP); // FSMC_NWE
gpio_set_mode(GPIOD, 4, GPIO_AF_OUTPUT_PP); // FSMC_NOE
gpio_set_mode(GPIOD, 5, GPIO_AF_OUTPUT_PP); // FSMC_NWE
gpio_set_mode(PIN_MAP[cs].gpio_device, PIN_MAP[cs].gpio_bit, GPIO_AF_OUTPUT_PP); //FSMC_CS_NEx
gpio_set_mode(PIN_MAP[rs].gpio_device, PIN_MAP[rs].gpio_bit, GPIO_AF_OUTPUT_PP); //FSMC_RS_Ax
FSMC_NOR_PSRAM4_BASE->BCR = FSMC_BCR_WREN | FSMC_BCR_MTYP_SRAM | FSMC_BCR_MWID_16BITS | FSMC_BCR_MBKEN;
FSMC_NOR_PSRAM4_BASE->BTR = (FSMC_DATA_SETUP_TIME << 8) | FSMC_ADDRESS_SETUP_TIME;
#ifdef STM32_XL_DENSITY
FSMC_NOR_PSRAM4_BASE->BCR = FSMC_BCR_WREN | FSMC_BCR_MTYP_SRAM | FSMC_BCR_MWID_16BITS | FSMC_BCR_MBKEN;
FSMC_NOR_PSRAM4_BASE->BTR = (FSMC_DATA_SETUP_TIME << 8) | FSMC_ADDRESS_SETUP_TIME;
#else // PSRAM1 for STM32F103V (high density)
FSMC_NOR_PSRAM1_BASE->BCR = FSMC_BCR_WREN | FSMC_BCR_MTYP_SRAM | FSMC_BCR_MWID_16BITS | FSMC_BCR_MBKEN;
FSMC_NOR_PSRAM1_BASE->BTR = (FSMC_DATA_SETUP_TIME << 8) | FSMC_ADDRESS_SETUP_TIME;
#endif
afio_remap(AFIO_REMAP_FSMC_NADV);
-23
View File
@@ -136,14 +136,6 @@
#undef pgm_read_ptr
#define pgm_read_ptr(addr) (*(addr))
#define RST_POWER_ON 1
#define RST_EXTERNAL 2
#define RST_BROWN_OUT 4
#define RST_WATCHDOG 8
#define RST_JTAG 16
#define RST_SOFTWARE 32
#define RST_BACKUP 64
// --------------------------------------------------------------------------
// Types
// --------------------------------------------------------------------------
@@ -232,23 +224,8 @@ inline void HAL_adc_init(void) {}
#define HAL_ADC_READY() true
void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result(void);
/* Todo: Confirm none of this is needed.
uint16_t HAL_getAdcReading(uint8_t chan);
void HAL_startAdcConversion(uint8_t chan);
uint8_t HAL_pinToAdcChannel(int pin);
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
void HAL_enable_AdcFreerun(void);
//void HAL_disable_AdcFreerun(uint8_t chan);
*/
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
+1 -3
View File
@@ -50,10 +50,8 @@
#define IS_INPUT(IO)
#define IS_OUTPUT(IO)
#define HAS_TIMER(IO) true
#define PWM_PIN(P) HAS_TIMER(P)
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
#define PWM_PIN(P) true
// digitalRead/Write wrappers
#define extDigitalRead(IO) digitalRead(IO)
-23
View File
@@ -125,14 +125,6 @@
#undef pgm_read_ptr
#define pgm_read_ptr(addr) (*(addr))
#define RST_POWER_ON 1
#define RST_EXTERNAL 2
#define RST_BROWN_OUT 4
#define RST_WATCHDOG 8
#define RST_JTAG 16
#define RST_SOFTWARE 32
#define RST_BACKUP 64
// --------------------------------------------------------------------------
// Types
// --------------------------------------------------------------------------
@@ -211,23 +203,8 @@ inline void HAL_adc_init(void) {}
#define HAL_ADC_READY() true
void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result(void);
/* Todo: Confirm none of this is needed.
uint16_t HAL_getAdcReading(uint8_t chan);
void HAL_startAdcConversion(uint8_t chan);
uint8_t HAL_pinToAdcChannel(int pin);
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
void HAL_enable_AdcFreerun(void);
//void HAL_disable_AdcFreerun(uint8_t chan);
*/
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
+2 -3
View File
@@ -25,7 +25,7 @@
*
*/
//#include "Arduino.h"
//#include <Arduino.h>
#ifdef STM32F7
@@ -33,7 +33,7 @@
#include <SPI.h>
#include "TMC2660.h"
#include "../../HAL/HAL_STM32F7/HAL.h"
#include "HAL.h"
#include "../../core/serial.h"
#include "../../inc/MarlinConfig.h"
#include "../../Marlin.h"
@@ -42,7 +42,6 @@
#include "../../libs/duration_t.h"
#include "../../libs/hex_print_routines.h"
//some default values used in initialization
#define DEFAULT_MICROSTEPPING_VALUE 32
+1 -3
View File
@@ -49,10 +49,8 @@
#define IS_INPUT(IO)
#define IS_OUTPUT(IO)
#define HAS_TIMER(IO) true
#define PWM_PIN(P) HAS_TIMER(P)
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
#define PWM_PIN(P) true
// digitalRead/Write wrappers
#define extDigitalRead(IO) digitalRead(IO)
+1 -23
View File
@@ -89,14 +89,6 @@ typedef int8_t pin_t;
#undef pgm_read_word
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
#define RST_POWER_ON 1
#define RST_EXTERNAL 2
#define RST_BROWN_OUT 4
#define RST_WATCHDOG 8
#define RST_JTAG 16
#define RST_SOFTWARE 32
#define RST_BACKUP 64
// Clear the reset reason
void HAL_clear_reset_source(void);
@@ -128,25 +120,11 @@ void HAL_adc_init();
#define HAL_READ_ADC() HAL_adc_get_result()
#define HAL_ADC_READY() true
#define HAL_ANALOG_SELECT(pin) NOOP;
#define HAL_ANALOG_SELECT(pin)
void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result(void);
/*
uint16_t HAL_getAdcReading(uint8_t chan);
void HAL_startAdcConversion(uint8_t chan);
uint8_t HAL_pinToAdcChannel(int pin);
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
void HAL_enable_AdcFreerun(void);
//void HAL_disable_AdcFreerun(uint8_t chan);
*/
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
@@ -1,3 +1,24 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifdef __MK20DX256__
#include "../../inc/MarlinConfig.h"
@@ -20,7 +20,6 @@
*
*/
/**
* Teensy3.2 __MK20DX256__
*/
@@ -1,23 +1,24 @@
/* **************************************************************************
Marlin 3D Printer Firmware
Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Description: HAL for
@@ -91,7 +91,6 @@
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
#define PWM_PIN(P) digitalPinHasPWM(P)
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
/**
* Ports, functions, and pins
+1 -1
View File
@@ -1 +1 @@
#error "Debug pins is not supported on the Teensy 3.1 / 3.2 Platform!"
#error "PINS_DEBUGGING is not yet supported for Teensy 3.1 / 3.2!"
+1 -23
View File
@@ -97,14 +97,6 @@ typedef int8_t pin_t;
#undef pgm_read_word
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
#define RST_POWER_ON 1
#define RST_EXTERNAL 2
#define RST_BROWN_OUT 4
#define RST_WATCHDOG 8
#define RST_JTAG 16
#define RST_SOFTWARE 32
#define RST_BACKUP 64
/** clear reset reason */
void HAL_clear_reset_source(void);
@@ -133,25 +125,11 @@ void HAL_adc_init();
#define HAL_READ_ADC() HAL_adc_get_result()
#define HAL_ADC_READY() true
#define HAL_ANALOG_SELECT(pin) NOOP;
#define HAL_ANALOG_SELECT(pin)
void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result(void);
/*
uint16_t HAL_getAdcReading(uint8_t chan);
void HAL_startAdcConversion(uint8_t chan);
uint8_t HAL_pinToAdcChannel(int pin);
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
void HAL_enable_AdcFreerun(void);
//void HAL_disable_AdcFreerun(uint8_t chan);
*/
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
@@ -90,7 +90,6 @@
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
#define PWM_PIN(P) digitalPinHasPWM(P)
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
/**
* Ports, functions, and pins
+9
View File
@@ -55,3 +55,12 @@
//#define strchr_P(s,c) strchr(s,c)
#endif
#endif
// Restart causes
#define RST_POWER_ON 1
#define RST_EXTERNAL 2
#define RST_BROWN_OUT 4
#define RST_WATCHDOG 8
#define RST_JTAG 16
#define RST_SOFTWARE 32
#define RST_BACKUP 64
+1 -1
View File
@@ -53,7 +53,7 @@
#include "../../inc/MarlinConfig.h"
#if HAS_SERVOS && !(IS_32BIT_TEENSY || defined(TARGET_LPC1768) || defined(STM32F1) || defined(STM32F1xx) || defined(STM32F4) || defined(STM32F4xx) || defined(STM32F7xx))
#if HAS_SERVOS && !(IS_32BIT_TEENSY || defined(TARGET_LPC1768) || defined(STM32F1) || defined(STM32F1xx) || defined(STM32F4) || defined(STM32F4xx) || defined(STM32F7xx) || defined(ARDUINO_ARCH_ESP32))
#include "servo.h"
#include "servo_private.h"
+3 -1
View File
@@ -73,13 +73,15 @@
#elif IS_TEENSY35 || IS_TEENSY36
#include "../HAL_TEENSY35_36/HAL_Servo_Teensy.h"
#elif defined(TARGET_LPC1768)
#include "../HAL_LPC1768/MarlinServo.h"
#include "../HAL_LPC1768/HAL_Servo_LPC1768.h"
#elif defined(__STM32F1__) || defined(TARGET_STM32F1)
#include "../HAL_STM32F1/HAL_Servo_STM32F1.h"
#elif defined(STM32GENERIC) && defined(STM32F4)
#include "../HAL_STM32F4/HAL_Servo_STM32F4.h"
#elif defined(ARDUINO_ARCH_STM32)
#include "../HAL_STM32/HAL_Servo_STM32.h"
#elif defined(ARDUINO_ARCH_ESP32)
#include "../HAL_ESP32/HAL_Servo_ESP32.h"
#else
#include <stdint.h>
+3 -3
View File
@@ -63,9 +63,9 @@
#define INVALID_SERVO 255 // flag indicating an invalid servo index
//
#define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / PRESCALER) // converts microseconds to tick (PRESCALER depends on architecture)
#define ticksToUs(_ticks) (( (unsigned)_ticks * PRESCALER)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds
// Convert microseconds to ticks and back (PRESCALER depends on architecture)
#define usToTicks(_us) (clockCyclesPerMicrosecond() * (_us) / (PRESCALER))
#define ticksToUs(_ticks) (unsigned(_ticks) * (PRESCALER) / clockCyclesPerMicrosecond())
//#define NBR_TIMERS ((MAX_SERVOS) / (SERVOS_PER_TIMER))
+1 -1
View File
@@ -1058,7 +1058,7 @@ void setup() {
#endif
#if ENABLED(BLTOUCH)
bltouch.init();
bltouch.init(/*set_voltage=*/true);
#endif
#if ENABLED(I2C_POSITION_ENCODERS)
+12
View File
@@ -161,6 +161,18 @@ void safe_delay(millis_t ms) {
return &conv[3];
}
// Convert signed float to fixed-length string with 12.34 / -2.34 format or 123.45 / -23.45 format
char* ftostr42_52(const float &f) {
if (f <= -10 || f >= 100) return ftostr52(f); // need more digits
long i = (f * 1000 + (f < 0 ? -5: 5)) / 10;
conv[2] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 1000));
conv[3] = DIGIMOD(i, 100);
conv[4] = '.';
conv[5] = DIGIMOD(i, 10);
conv[6] = DIGIMOD(i, 1);
return &conv[2];
}
// Convert signed float to fixed-length string with 023.45 / -23.45 format
char* ftostr52(const float &f) {
long i = (f * 1000 + (f < 0 ? -5: 5)) / 10;
+3
View File
@@ -82,6 +82,9 @@ inline void serial_delay(const millis_t ms) {
// Convert unsigned float to string with 1.23 format
char* ftostr12ns(const float &x);
// Convert signed float to fixed-length string with 12.34 / -2.34 or 023.45 / -23.45 format
char* ftostr42_52(const float &x);
// Convert signed float to fixed-length string with 023.45 / -23.45 format
char* ftostr52(const float &x);
+1 -1
View File
@@ -83,7 +83,7 @@ void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
#endif
#if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
#define BSA_ENABLE(AXIS) do{ switch (AXIS) { case X_AXIS: enable_X(); break; case Y_AXIS: enable_Y(); break; case Z_AXIS: enable_Z(); } }while(0)
#define BSA_ENABLE(AXIS) do{ switch (AXIS) { case X_AXIS: enable_X(); break; case Y_AXIS: enable_Y(); break; case Z_AXIS: enable_Z(); break; default: break; } }while(0)
#else
#define BSA_ENABLE(AXIS) NOOP
#endif
+14 -7
View File
@@ -20,18 +20,25 @@
*
*/
#include "../Marlin.h"
#include "../inc/MarlinConfigPre.h"
#if ENABLED(BACKLASH_COMPENSATION)
#include "backlash.h"
#include "../module/motion.h"
#include "../module/planner.h"
#ifdef BACKLASH_DISTANCE_MM
#if ENABLED(BACKLASH_GCODE)
float Backlash::distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
#else
const float Backlash::distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
#endif
#endif
#if ENABLED(BACKLASH_GCODE)
uint8_t Backlash::correction = (BACKLASH_CORRECTION) * 0xFF;
#ifdef BACKLASH_DISTANCE_MM
float Backlash::distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
#endif
#ifdef BACKLASH_SMOOTHING_MM
float Backlash::smoothing_mm = BACKLASH_SMOOTHING_MM;
#endif
@@ -75,10 +82,10 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
// to segments where there is no direction change.
static int32_t residual_error[XYZ] = { 0 };
#else
// No leftover residual error from segment to segment
int32_t residual_error[XYZ] = { 0 };
// No direction change, no correction.
if (!changed_dir) return;
// No leftover residual error from segment to segment
int32_t residual_error[XYZ] = { 0 };
#endif
const float f_corr = float(correction) / 255.0f;
@@ -100,7 +107,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
if (reversing == (error_correction < 0)) {
if (segment_proportion == 0)
segment_proportion = MIN(1.0f, block->millimeters / smoothing_mm);
error_correction = ceil(segment_proportion * error_correction);
error_correction = CEIL(segment_proportion * error_correction);
}
else
error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps
+9 -11
View File
@@ -26,30 +26,28 @@
class Backlash {
public:
#ifdef BACKLASH_DISTANCE_MM
#if ENABLED(BACKLASH_GCODE)
static float distance_mm[XYZ];
#else
static const float distance_mm[XYZ];
//static constexpr float distance_mm[XYZ] = BACKLASH_DISTANCE_MM; // compiler barks at this
#endif
#endif
#if ENABLED(BACKLASH_GCODE)
static uint8_t correction;
#ifdef BACKLASH_DISTANCE_MM
static float distance_mm[XYZ];
#endif
#ifdef BACKLASH_SMOOTHING_MM
static float smoothing_mm;
#endif
static inline void set_correction(const float &v) { correction = MAX(0, MIN(1.0, v)) * all_on; }
static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
#elif ENABLED(BACKLASH_COMPENSATION)
#else
static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF;
#ifdef BACKLASH_DISTANCE_MM
static constexpr float distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
#endif
#ifdef BACKLASH_SMOOTHING_MM
static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM;
#endif
static inline void set_correction(float) { }
static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
#else
static constexpr uint8_t correction = 0;
static inline void set_correction(float) { }
static inline float get_correction() { return 0; }
#endif
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
+33 -3
View File
@@ -411,7 +411,6 @@
restore_ubl_active_state_and_leave();
}
else { // grid_size == 0 : A 3-Point leveling has been requested
save_ubl_active_state_and_disable();
tilt_mesh_based_on_probed_grid(true /* true says to do 3-Point leveling */ );
restore_ubl_active_state_and_leave();
@@ -738,12 +737,17 @@
save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained
DEPLOY_PROBE();
uint16_t count = GRID_MAX_POINTS;
uint16_t count = GRID_MAX_POINTS, current = 1;
do {
current = (GRID_MAX_POINTS) - count + 1;
if (do_ubl_mesh_map) display_map(g29_map_type);
SERIAL_ECHOLNPAIR("\nProbing mesh point ", current, "/", GRID_MAX_POINTS, ".\n");
#if HAS_LCD_MENU
ui.status_printf_P(0, PSTR(MSG_LCD_PROBING_MESH " %i/%i"), current, int(GRID_MAX_POINTS));
if (ui.button_pressed()) {
ui.quick_feedback(false); // Preserve button state for click-and-hold
SERIAL_ECHOLNPGM("\nMesh only partially populated.\n");
@@ -771,6 +775,7 @@
#endif
}
SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
} while (location.x_index >= 0 && --count);
STOW_PROBE();
@@ -1401,6 +1406,11 @@
incremental_LSF_reset(&lsf_results);
if (do_3_pt_leveling) {
SERIAL_ECHOLNPGM("Tilting mesh (1/3)");
#if HAS_LCD_MENU
ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 1/3"));
#endif
measured_z = probe_pt(PROBE_PT_1_X, PROBE_PT_1_Y, PROBE_PT_RAISE, g29_verbose_level);
if (isnan(measured_z))
abort_flag = true;
@@ -1415,6 +1425,11 @@
}
if (!abort_flag) {
SERIAL_ECHOLNPGM("Tilting mesh (2/3)");
#if HAS_LCD_MENU
ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 2/3"));
#endif
measured_z = probe_pt(PROBE_PT_2_X, PROBE_PT_2_Y, PROBE_PT_RAISE, g29_verbose_level);
//z2 = measured_z;
if (isnan(measured_z))
@@ -1430,6 +1445,11 @@
}
if (!abort_flag) {
SERIAL_ECHOLNPGM("Tilting mesh (3/3)");
#if HAS_LCD_MENU
ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 3/3"));
#endif
measured_z = probe_pt(PROBE_PT_3_X, PROBE_PT_3_Y, PROBE_PT_STOW, g29_verbose_level);
//z3 = measured_z;
if (isnan(measured_z))
@@ -1450,19 +1470,27 @@
#endif
if (abort_flag) {
SERIAL_ECHOLNPGM("?Error probing point. Aborting operation.");
SERIAL_ECHOLNPGM("?Error probing point. Aborting operation.");
return;
}
}
else { // !do_3_pt_leveling
bool zig_zag = false;
uint16_t total_points = g29_grid_size * g29_grid_size, current = 1;
for (uint8_t ix = 0; ix < g29_grid_size; ix++) {
const float rx = float(x_min) + ix * dx;
for (int8_t iy = 0; iy < g29_grid_size; iy++) {
const float ry = float(y_min) + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
if (!abort_flag) {
SERIAL_ECHOLNPAIR("Tilting mesh point ", current, "/", total_points, "\n");
#if HAS_LCD_MENU
ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " %i/%i"), current, total_points);
#endif
measured_z = probe_pt(rx, ry, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
abort_flag = isnan(measured_z);
@@ -1491,6 +1519,8 @@
}
incremental_LSF(&lsf_results, rx, ry, measured_z);
}
current++;
}
zig_zag ^= true;
+65 -14
View File
@@ -28,6 +28,8 @@
BLTouch bltouch;
bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
#include "../module/servo.h"
void stop();
@@ -38,21 +40,53 @@ void stop();
bool BLTouch::command(const BLTCommand cmd, const millis_t &ms) {
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("BLTouch Command :", cmd);
MOVE_SERVO(Z_PROBE_SERVO_NR, cmd);
safe_delay(MAX(ms, BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay
safe_delay(MAX(ms, (uint32_t)BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay
return triggered();
}
void BLTouch::init() {
// This is called by marlin.cpp on initialization
// SET_5V_MODE (if enabled). OD_MODE is the default on power on.
// This mode will stay active until manual SET_OD_MODE or power cycle
#if ENABLED(BLTOUCH_FORCE_5V_MODE)
_set_5V_mode(); // Set 5V mode if explicitely demanded (V3 upwards)
// Init the class and device. Call from setup().
void BLTouch::init(const bool set_voltage/*=false*/) {
// Voltage Setting (if enabled). At every Marlin initialization:
// BLTOUCH < V3.0 and clones: This will be ignored by the probe
// BLTOUCH V3.0: SET_5V_MODE or SET_OD_MODE (if enabled).
// OD_MODE is the default on power on, but setting it does not hurt
// This mode will stay active until manual SET_OD_MODE or power cycle
// BLTOUCH V3.1: SET_5V_MODE or SET_OD_MODE (if enabled).
// At power on, the probe will default to the eeprom settings configured by the user
#if ENABLED(BLTOUCH_FORCE_MODE_SET)
constexpr bool should_set = true;
#else
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPAIR("last_written_mode - ", (int)last_written_mode);
DEBUG_ECHOLNPGM("config mode - "
#if ENABLED(BLTOUCH_SET_5V_MODE)
"BLTOUCH_SET_5V_MODE"
#else
"OD"
#endif
);
}
const bool should_set = last_written_mode != (false
#if ENABLED(BLTOUCH_SET_5V_MODE)
|| true
#endif
);
#endif
if (should_set && set_voltage)
mode_conv_proc((false
#if ENABLED(BLTOUCH_SET_5V_MODE)
|| true
#endif
));
_reset();
_stow();
// There really should be no alarm outstanding now, and no triggered condition. But if there is,
// there is no need to worry people here on init right at the start of the printer.
}
void BLTouch::clear() {
@@ -97,6 +131,11 @@ bool BLTouch::deploy_proc() {
}
}
// One of the recommended ANTClabs ways to probe, using SW MODE
#if ENABLED(BLTOUCH_FORCE_SW_MODE)
_set_SW_mode();
#endif
// Now the probe is ready to issue a 10ms pulse when the pin goes up.
// The trigger STOW (see motion.cpp for example) will pull up the probes pin as soon as the pulse
// is registered.
@@ -146,20 +185,32 @@ bool BLTouch::status_proc() {
/**
* Return a TRUE for "YES, it is DEPLOYED"
* This function will ensure switch state is reset after execution
* This may change pin position in some scenarios, specifically
* if the pin has been triggered but not yet stowed.
*/
if (DEBUGGING(LEVELING)) DEBUG_ECHOLN("BLTouch STATUS requested");
_set_SW_mode();
_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);
_reset(); // turn off the SW Mode
if (tr) _stow(); else _deploy(); // and reset any triggered signal, restore state
if (tr) _stow(); else _deploy(); // Turn off SW mode, reset any trigger, honor pin state
return !tr;
}
void BLTouch::mode_conv_proc(const bool M5V) {
/**
* BLTOUCH pre V3.0 and clones: No reaction at all to this sequence apart from a DEPLOY -> STOW
* 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);
_deploy();
if (M5V) _set_5V_mode(); else _set_OD_mode();
_mode_store();
if (M5V) _set_5V_mode(); else _set_OD_mode();
_stow();
last_written_mode = M5V;
}
#endif // BLTOUCH
+14 -2
View File
@@ -30,6 +30,7 @@ typedef unsigned char BLTCommand;
#define BLTOUCH_SW_MODE 60
#define BLTOUCH_STOW 90
#define BLTOUCH_SELFTEST 120
#define BLTOUCH_MODE_STORE 130
#define BLTOUCH_5V_MODE 140
#define BLTOUCH_OD_MODE 150
#define BLTOUCH_RESET 160
@@ -51,6 +52,9 @@ typedef unsigned char BLTCommand;
#ifndef BLTOUCH_SETOD_DELAY
#define BLTOUCH_SETOD_DELAY BLTOUCH_DELAY
#endif
#ifndef BLTOUCH_MODE_STORE_DELAY
#define BLTOUCH_MODE_STORE_DELAY BLTOUCH_DELAY
#endif
#ifndef BLTOUCH_DEPLOY_DELAY
#define BLTOUCH_DEPLOY_DELAY 750
#endif
@@ -63,8 +67,8 @@ typedef unsigned char BLTCommand;
class BLTouch {
public:
static bool triggered(); // used by menu_advanced.cpp
static void init(); // used by main.cpp
static void init(const bool set_voltage=false);
static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
// DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing
FORCE_INLINE static bool deploy() { return deploy_proc(); }
@@ -77,21 +81,29 @@ public:
FORCE_INLINE static void _selftest() { command(BLTOUCH_SELFTEST, BLTOUCH_DELAY); }
FORCE_INLINE static void _set_SW_mode() { command(BLTOUCH_SW_MODE, BLTOUCH_DELAY); }
FORCE_INLINE static void _reset_SW_mode() { if (triggered()) _stow(); else _deploy(); }
FORCE_INLINE static void _set_5V_mode() { command(BLTOUCH_5V_MODE, BLTOUCH_SET5V_DELAY); }
FORCE_INLINE static void _set_OD_mode() { command(BLTOUCH_OD_MODE, BLTOUCH_SETOD_DELAY); }
FORCE_INLINE static void _mode_store() { command(BLTOUCH_MODE_STORE, BLTOUCH_MODE_STORE_DELAY); }
FORCE_INLINE static void _deploy() { command(BLTOUCH_DEPLOY, BLTOUCH_DEPLOY_DELAY); }
FORCE_INLINE static void _stow() { command(BLTOUCH_STOW, BLTOUCH_STOW_DELAY); }
FORCE_INLINE static void mode_conv_5V() { mode_conv_proc(true); }
FORCE_INLINE static void mode_conv_OD() { mode_conv_proc(false); }
private:
FORCE_INLINE static bool _deploy_query_alarm() { return command(BLTOUCH_DEPLOY, BLTOUCH_DEPLOY_DELAY); }
FORCE_INLINE static bool _stow_query_alarm() { return command(BLTOUCH_STOW, BLTOUCH_STOW_DELAY); }
static void clear();
static bool command(const BLTCommand cmd, const millis_t &ms);
static bool triggered();
static bool deploy_proc();
static bool stow_proc();
static bool status_proc();
static void mode_conv_proc(const bool M5V);
};
// Deploy/stow angles for use by servo.cpp / servo.h
+1 -1
View File
@@ -25,7 +25,7 @@
*
* Part of Marlin
*
* Copyright (c) 2016 MarlinFirmware
* Copyright (c) 2019 MarlinFirmware
*
* Marlin is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+3
View File
@@ -89,6 +89,9 @@ void LEDLights::set_color(const LEDColor &incol
: pixels.Color(incol.r, incol.g, incol.b, incol.w);
static uint16_t nextLed = 0;
#ifdef NEOPIXEL_BKGD_LED_INDEX
if (NEOPIXEL_BKGD_LED_INDEX == nextLed) { nextLed++; return; }
#endif
pixels.setBrightness(incol.i);
if (!isSequence)
set_neopixel_color(neocolor);
+25 -3
View File
@@ -37,11 +37,29 @@
Adafruit_NeoPixel pixels(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800);
void set_neopixel_color(const uint32_t color) {
for (uint16_t i = 0; i < pixels.numPixels(); ++i) {
#ifdef NEOPIXEL_BKGD_LED_INDEX
if (NEOPIXEL_BKGD_LED_INDEX == i) i++;
#endif
pixels.setPixelColor(i, color);
}
pixels.show();
}
void set_neopixel_color_startup(const uint32_t color) {
for (uint16_t i = 0; i < pixels.numPixels(); ++i)
pixels.setPixelColor(i, color);
pixels.show();
}
#ifdef NEOPIXEL_BKGD_LED_INDEX
void set_neopixel_color_background() {
uint8_t background_color[4] = NEOPIXEL_BKGD_COLOR;
pixels.setPixelColor(NEOPIXEL_BKGD_LED_INDEX, pixels.Color(background_color[0], background_color[1], background_color[2], background_color[3]));
pixels.show();
}
#endif
void setup_neopixel() {
SET_OUTPUT(NEOPIXEL_PIN);
pixels.setBrightness(NEOPIXEL_BRIGHTNESS); // 0 - 255 range
@@ -50,14 +68,18 @@ void setup_neopixel() {
#if ENABLED(NEOPIXEL_STARTUP_TEST)
safe_delay(1000);
set_neopixel_color(pixels.Color(255, 0, 0, 0)); // red
set_neopixel_color_startup(pixels.Color(255, 0, 0, 0)); // red
safe_delay(1000);
set_neopixel_color(pixels.Color(0, 255, 0, 0)); // green
set_neopixel_color_startup(pixels.Color(0, 255, 0, 0)); // green
safe_delay(1000);
set_neopixel_color(pixels.Color(0, 0, 255, 0)); // blue
set_neopixel_color_startup(pixels.Color(0, 0, 255, 0)); // blue
safe_delay(1000);
#endif
#ifdef NEOPIXEL_BKGD_LED_INDEX
set_neopixel_color_background();
#endif
#if ENABLED(LED_USER_PRESET_STARTUP)
set_neopixel_color(pixels.Color(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE));
#else
+5 -5
View File
@@ -170,8 +170,8 @@ void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*=
#endif
info.feedrate = uint16_t(feedrate_mm_s * 60.0f);
#if HOTENDS > 1
info.active_hotend = active_extruder;
#if EXTRUDERS > 1
info.active_extruder = active_extruder;
#endif
HOTEND_LOOP() info.target_temperature[e] = thermalManager.temp_hotend[e].target;
@@ -282,7 +282,7 @@ void PrintJobRecovery::resume() {
// Select the previously active tool (with no_move)
#if EXTRUDERS > 1
sprintf_P(cmd, PSTR("T%i S"), info.active_hotend);
sprintf_P(cmd, PSTR("T%i S"), info.active_extruder);
gcode.process_subcommands_now(cmd);
#endif
@@ -443,8 +443,8 @@ void PrintJobRecovery::resume() {
DEBUG_ECHOLNPAIR("feedrate: ", info.feedrate);
#if HOTENDS > 1
DEBUG_ECHOLNPAIR("active_hotend: ", int(info.active_hotend));
#if EXTRUDERS > 1
DEBUG_ECHOLNPAIR("active_extruder: ", int(info.active_extruder));
#endif
DEBUG_ECHOPGM("target_temperature: ");
+2 -2
View File
@@ -51,8 +51,8 @@ typedef struct {
uint16_t feedrate;
#if HOTENDS > 1
uint8_t active_hotend;
#if EXTRUDERS > 1
uint8_t active_extruder;
#endif
int16_t target_temperature[HOTENDS];
+45 -107
View File
@@ -313,8 +313,6 @@
#endif
}
#define HAS_HW_COMMS(ST) AXIS_DRIVER_TYPE(ST, TMC2130) || AXIS_DRIVER_TYPE(ST, TMC2160) || AXIS_DRIVER_TYPE(ST, TMC2660) || AXIS_DRIVER_TYPE(ST, TMC5130) || AXIS_DRIVER_TYPE(ST, TMC5160) || (AXIS_DRIVER_TYPE(ST, TMC2208) && defined(ST##_HARDWARE_SERIAL))
void monitor_tmc_driver() {
static millis_t next_poll = 0;
const millis_t ms = millis();
@@ -330,43 +328,43 @@
}
#endif
if (need_update_error_counters || need_debug_reporting) {
#if HAS_HW_COMMS(X)
#if AXIS_IS_TMC(X)
monitor_tmc_driver(stepperX, need_update_error_counters, need_debug_reporting);
#endif
#if HAS_HW_COMMS(Y)
#if AXIS_IS_TMC(Y)
monitor_tmc_driver(stepperY, need_update_error_counters, need_debug_reporting);
#endif
#if HAS_HW_COMMS(Z)
#if AXIS_IS_TMC(Z)
monitor_tmc_driver(stepperZ, need_update_error_counters, need_debug_reporting);
#endif
#if HAS_HW_COMMS(X2)
#if AXIS_IS_TMC(X2)
monitor_tmc_driver(stepperX2, need_update_error_counters, need_debug_reporting);
#endif
#if HAS_HW_COMMS(Y2)
#if AXIS_IS_TMC(Y2)
monitor_tmc_driver(stepperY2, need_update_error_counters, need_debug_reporting);
#endif
#if HAS_HW_COMMS(Z2)
#if AXIS_IS_TMC(Z2)
monitor_tmc_driver(stepperZ2, need_update_error_counters, need_debug_reporting);
#endif
#if HAS_HW_COMMS(Z3)
#if AXIS_IS_TMC(Z3)
monitor_tmc_driver(stepperZ3, need_update_error_counters, need_debug_reporting);
#endif
#if HAS_HW_COMMS(E0)
#if AXIS_IS_TMC(E0)
monitor_tmc_driver(stepperE0, need_update_error_counters, need_debug_reporting);
#endif
#if HAS_HW_COMMS(E1)
#if AXIS_IS_TMC(E1)
monitor_tmc_driver(stepperE1, need_update_error_counters, need_debug_reporting);
#endif
#if HAS_HW_COMMS(E2)
#if AXIS_IS_TMC(E2)
monitor_tmc_driver(stepperE2, need_update_error_counters, need_debug_reporting);
#endif
#if HAS_HW_COMMS(E3)
#if AXIS_IS_TMC(E3)
monitor_tmc_driver(stepperE3, need_update_error_counters, need_debug_reporting);
#endif
#if HAS_HW_COMMS(E4)
#if AXIS_IS_TMC(E4)
monitor_tmc_driver(stepperE4, need_update_error_counters, need_debug_reporting);
#endif
#if HAS_HW_COMMS(E5)
#if AXIS_IS_TMC(E5)
monitor_tmc_driver(stepperE5, need_update_error_counters, need_debug_reporting);
#endif
@@ -471,8 +469,8 @@
template<class TMC>
static void print_vsense(TMC &st) { serialprintPGM(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); }
#if HAS_TMCX1X0
static void tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) {
#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;
@@ -480,6 +478,8 @@
default: break;
}
}
#endif
#if HAS_TMCX1X0
static void _tmc_parse_drv_status(TMC2130Stepper &st, const TMC_drv_status_enum i) {
switch (i) {
case TMC_STALLGUARD: if (st.stallguard()) SERIAL_CHAR('X'); break;
@@ -492,10 +492,13 @@
#endif
#if HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5160)
template<char AXIS_LETTER, char DRIVER_ID> void print_vsense(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID> &st) { UNUSED(st); }
template<char AXIS_LETTER, char DRIVER_ID> void print_vsense(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID> &st) { UNUSED(st); }
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
void print_vsense(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &) { }
static void tmc_status(TMC2160Stepper &st, const TMC_debug_enum i) {
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
void print_vsense(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &) { }
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;
@@ -513,7 +516,7 @@
#endif
#if HAS_DRIVER(TMC2208)
static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
static void _tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_PWM_SCALE: SERIAL_PRINT(st.pwm_scale_sum(), DEC); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.stealth()); break;
@@ -539,7 +542,7 @@
#endif
template <typename TMC>
static void tmc_status(TMC &st, const TMC_debug_enum i, const float spmm) {
static void tmc_status(TMC &st, const TMC_debug_enum i) {
SERIAL_CHAR('\t');
switch (i) {
case TMC_CODES: st.printLabel(); break;
@@ -573,9 +576,9 @@
}
break;
case TMC_TPWMTHRS_MMS: {
uint32_t tpwmthrs_val = st.TPWMTHRS();
uint32_t tpwmthrs_val = st.get_pwm_thrs();
if (tpwmthrs_val)
SERIAL_ECHO(12650000UL * st.microsteps() / (256 * tpwmthrs_val * spmm));
SERIAL_ECHO(tpwmthrs_val);
else
SERIAL_CHAR('-');
}
@@ -588,13 +591,13 @@
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;
default: tmc_status(st, i); break;
default: _tmc_status(st, i); break;
}
}
#if HAS_DRIVER(TMC2660)
template<char AXIS_LETTER, char DRIVER_ID>
void tmc_status(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID> &st, const TMC_debug_enum i, const float) {
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
void tmc_status(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const TMC_debug_enum i) {
SERIAL_CHAR('\t');
switch (i) {
case TMC_CODES: st.printLabel(); break;
@@ -649,72 +652,52 @@
static void tmc_debug_loop(const TMC_debug_enum i, const bool print_x, const bool print_y, const bool print_z, const bool print_e) {
if (print_x) {
#if AXIS_IS_TMC(X)
tmc_status(stepperX, i, planner.settings.axis_steps_per_mm[X_AXIS]);
tmc_status(stepperX, i);
#endif
#if AXIS_IS_TMC(X2)
tmc_status(stepperX2, i, planner.settings.axis_steps_per_mm[X_AXIS]);
tmc_status(stepperX2, i);
#endif
}
if (print_y) {
#if AXIS_IS_TMC(Y)
tmc_status(stepperY, i, planner.settings.axis_steps_per_mm[Y_AXIS]);
tmc_status(stepperY, i);
#endif
#if AXIS_IS_TMC(Y2)
tmc_status(stepperY2, i, planner.settings.axis_steps_per_mm[Y_AXIS]);
tmc_status(stepperY2, i);
#endif
}
if (print_z) {
#if AXIS_IS_TMC(Z)
tmc_status(stepperZ, i, planner.settings.axis_steps_per_mm[Z_AXIS]);
tmc_status(stepperZ, i);
#endif
#if AXIS_IS_TMC(Z2)
tmc_status(stepperZ2, i, planner.settings.axis_steps_per_mm[Z_AXIS]);
tmc_status(stepperZ2, i);
#endif
#if AXIS_IS_TMC(Z3)
tmc_status(stepperZ3, i, planner.settings.axis_steps_per_mm[Z_AXIS]);
tmc_status(stepperZ3, i);
#endif
}
if (print_e) {
#if AXIS_IS_TMC(E0)
tmc_status(stepperE0, i, planner.settings.axis_steps_per_mm[E_AXIS]);
tmc_status(stepperE0, i);
#endif
#if AXIS_IS_TMC(E1)
tmc_status(stepperE1, i, planner.settings.axis_steps_per_mm[E_AXIS
#if ENABLED(DISTINCT_E_FACTORS)
+ 1
#endif
]);
tmc_status(stepperE1, i);
#endif
#if AXIS_IS_TMC(E2)
tmc_status(stepperE2, i, planner.settings.axis_steps_per_mm[E_AXIS
#if ENABLED(DISTINCT_E_FACTORS)
+ 2
#endif
]);
tmc_status(stepperE2, i);
#endif
#if AXIS_IS_TMC(E3)
tmc_status(stepperE3, i, planner.settings.axis_steps_per_mm[E_AXIS
#if ENABLED(DISTINCT_E_FACTORS)
+ 3
#endif
]);
tmc_status(stepperE3, i);
#endif
#if AXIS_IS_TMC(E4)
tmc_status(stepperE4, i, planner.settings.axis_steps_per_mm[E_AXIS
#if ENABLED(DISTINCT_E_FACTORS)
+ 4
#endif
]);
tmc_status(stepperE4, i);
#endif
#if AXIS_IS_TMC(E5)
tmc_status(stepperE5, i, planner.settings.axis_steps_per_mm[E_AXIS
#if ENABLED(DISTINCT_E_FACTORS)
+ 5
#endif
]);
tmc_status(stepperE5, i);
#endif
}
@@ -877,8 +860,8 @@
}
#endif
#if HAS_DRIVER(TMC2660)
template <char AXIS_LETTER, char DRIVER_ID>
static void tmc_get_registers(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID> &st, const TMC_get_registers_enum i) {
template <char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
static void tmc_get_registers(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const TMC_get_registers_enum i) {
switch (i) {
case TMC_AXIS_CODES: SERIAL_CHAR('\t'); st.printLabel(); break;
PRINT_TMC_REGISTER(DRVCONF);
@@ -1118,49 +1101,4 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
if (axis_connection) ui.set_status_P(PSTR("TMC CONNECTION ERROR"));
}
#if HAS_LCD_MENU
void init_tmc_section() {
#if AXIS_IS_TMC(X)
stepperX.init_lcd_variables(X_AXIS);
#endif
#if AXIS_IS_TMC(Y)
stepperY.init_lcd_variables(Y_AXIS);
#endif
#if AXIS_IS_TMC(Z)
stepperZ.init_lcd_variables(Z_AXIS);
#endif
#if AXIS_IS_TMC(X2)
stepperX2.init_lcd_variables(X_AXIS);
#endif
#if AXIS_IS_TMC(Y2)
stepperY2.init_lcd_variables(Y_AXIS);
#endif
#if AXIS_IS_TMC(Z2)
stepperZ2.init_lcd_variables(Z_AXIS);
#endif
#if AXIS_IS_TMC(Z3)
stepperZ3.init_lcd_variables(Z_AXIS);
#endif
#if AXIS_IS_TMC(E0)
stepperE0.init_lcd_variables(E_AXIS);
#endif
#if AXIS_IS_TMC(E1)
stepperE1.init_lcd_variables(E_AXIS_N(1));
#endif
#if AXIS_IS_TMC(E2)
stepperE2.init_lcd_variables(E_AXIS_N(2));
#endif
#if AXIS_IS_TMC(E3)
stepperE3.init_lcd_variables(E_AXIS_N(3));
#endif
#if AXIS_IS_TMC(E4)
stepperE4.init_lcd_variables(E_AXIS_N(4));
#endif
#if AXIS_IS_TMC(E5)
stepperE5.init_lcd_variables(E_AXIS_N(5));
#endif
}
#endif
#endif // HAS_TRINAMIC
+72 -65
View File
@@ -23,12 +23,11 @@
#include "../inc/MarlinConfig.h"
#include "../lcd/ultralcd.h"
#if HAS_TRINAMIC
#include <TMCStepper.h>
#endif
#if HAS_LCD_MENU
#include "../module/planner.h"
#endif
#include <TMCStepper.h>
#include "../module/planner.h"
#define TMC_X_LABEL 'X', '0'
#define TMC_Y_LABEL 'Y', '0'
@@ -57,7 +56,7 @@
#define MONITOR_DRIVER_STATUS_INTERVAL_MS 500u
#endif
constexpr uint16_t _tmc_thrs(const uint16_t msteps, const int32_t thrs, const uint32_t spmm) {
constexpr uint16_t _tmc_thrs(const uint16_t msteps, const uint32_t thrs, const uint32_t spmm) {
return 12650000UL * msteps / (256 * thrs * spmm);
}
@@ -92,13 +91,13 @@ class TMCStorage {
#if ENABLED(HYBRID_THRESHOLD)
uint8_t hybrid_thrs = 0;
#endif
#if ENABLED(SENSORLESS_HOMING)
#if USE_SENSORLESS
int8_t homing_thrs = 0;
#endif
} stored;
};
template<class TMC, char AXIS_LETTER, char DRIVER_ID>
template<class TMC, char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
public:
TMCMarlin(uint16_t cs_pin, float RS) :
@@ -121,30 +120,40 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
inline void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); }
inline bool get_stealthChop_status() { return this->en_pwm_mode(); }
#endif
#if HAS_LCD_MENU
inline void init_lcd_variables(const AxisEnum spmm_id) {
#if ENABLED(HYBRID_THRESHOLD)
this->stored.hybrid_thrs = _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[spmm_id]);
#endif
#if ENABLED(SENSORLESS_HOMING)
this->stored.homing_thrs = this->sgt();
#if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
}
void set_pwm_thrs(const uint32_t thrs) {
TMC::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
#if HAS_LCD_MENU
this->stored.hybrid_thrs = thrs;
#endif
}
#endif
#if USE_SENSORLESS
inline int8_t sgt() { return TMC::sgt(); }
void sgt(const int8_t sgt_val) {
TMC::sgt(sgt_val);
#if HAS_LCD_MENU
this->stored.homing_thrs = sgt_val;
#endif
}
#endif
#if HAS_LCD_MENU
inline void refresh_stepper_current() { rms_current(this->val_mA); }
#if ENABLED(HYBRID_THRESHOLD)
inline void refresh_hybrid_thrs(float spmm) { this->TPWMTHRS(_tmc_thrs(this->microsteps(), this->stored.hybrid_thrs, spmm)); }
inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
#endif
#if ENABLED(SENSORLESS_HOMING)
inline void refresh_homing_thrs() { this->sgt(this->stored.homing_thrs); }
#if USE_SENSORLESS
inline void refresh_homing_thrs() { sgt(this->stored.homing_thrs); }
#endif
#endif
};
template<char AXIS_LETTER, char DRIVER_ID>
class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID> : public TMC2208Stepper, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC2208Stepper, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
public:
TMCMarlin(Stream * SerialPort, float RS, bool has_rx=true) :
TMC2208Stepper(SerialPort, RS, has_rx=true)
@@ -166,24 +175,28 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID> : public TMC2208Stepper,
inline void refresh_stepping_mode() { en_spreadCycle(!this->stored.stealthChop_enabled); }
inline bool get_stealthChop_status() { return !this->en_spreadCycle(); }
#endif
#if HAS_LCD_MENU
inline void init_lcd_variables(const AxisEnum spmm_id) {
#if ENABLED(HYBRID_THRESHOLD)
this->stored.hybrid_thrs = _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[spmm_id]);
#if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
}
void set_pwm_thrs(const uint32_t thrs) {
TMC2208Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
#if HAS_LCD_MENU
this->stored.hybrid_thrs = thrs;
#endif
}
#endif
#if HAS_LCD_MENU
inline void refresh_stepper_current() { rms_current(this->val_mA); }
#if ENABLED(HYBRID_THRESHOLD)
inline void refresh_hybrid_thrs(float spmm) { this->TPWMTHRS(_tmc_thrs(this->microsteps(), this->stored.hybrid_thrs, spmm)); }
inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
#endif
#endif
};
template<char AXIS_LETTER, char DRIVER_ID>
class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID> : public TMC2660Stepper, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC2660Stepper, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
public:
TMCMarlin(uint16_t cs_pin, float RS) :
TMC2660Stepper(cs_pin, RS)
@@ -197,30 +210,30 @@ class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID> : public TMC2660Stepper,
TMC2660Stepper::rms_current(mA);
}
#if HAS_LCD_MENU
inline void init_lcd_variables(const AxisEnum spmm_id) {
#if ENABLED(SENSORLESS_HOMING)
this->stored.homing_thrs = this->sgt();
#if USE_SENSORLESS
inline int8_t sgt() { return TMC2660Stepper::sgt(); }
void sgt(const int8_t sgt_val) {
TMC2660Stepper::sgt(sgt_val);
#if HAS_LCD_MENU
this->stored.homing_thrs = sgt_val;
#endif
}
#endif
#if HAS_LCD_MENU
inline void refresh_stepper_current() { rms_current(this->val_mA); }
#if ENABLED(SENSORLESS_HOMING)
inline void refresh_homing_thrs() { this->sgt(this->stored.homing_thrs); }
#if USE_SENSORLESS
inline void refresh_homing_thrs() { sgt(this->stored.homing_thrs); }
#endif
#endif
};
template<typename TMC>
void tmc_get_current(TMC &st) {
void tmc_print_current(TMC &st) {
st.printLabel();
SERIAL_ECHOLNPAIR(" driver current: ", st.getMilliamps());
}
template<typename TMC>
void tmc_set_current(TMC &st, const int mA) {
st.rms_current(mA);
}
#if ENABLED(MONITOR_DRIVER_STATUS)
template<typename TMC>
@@ -237,25 +250,21 @@ void tmc_set_current(TMC &st, const int mA) {
SERIAL_ECHOLNPGM(" prewarn flag cleared");
}
#endif
template<typename TMC>
void tmc_get_pwmthrs(TMC &st, const uint16_t spmm) {
st.printLabel();
SERIAL_ECHOLNPAIR(" stealthChop max speed: ", _tmc_thrs(st.microsteps(), st.TPWMTHRS(), spmm));
}
template<typename TMC>
void tmc_set_pwmthrs(TMC &st, const int32_t thrs, const uint32_t spmm) {
st.TPWMTHRS(_tmc_thrs(st.microsteps(), thrs, spmm));
}
template<typename TMC>
void tmc_get_sgt(TMC &st) {
st.printLabel();
SERIAL_ECHOPGM(" homing sensitivity: ");
SERIAL_PRINTLN(st.sgt(), DEC);
}
template<typename TMC>
void tmc_set_sgt(TMC &st, const int8_t sgt_val) {
st.sgt(sgt_val);
}
#if ENABLED(HYBRID_THRESHOLD)
template<typename TMC>
void tmc_print_pwmthrs(TMC &st) {
st.printLabel();
SERIAL_ECHOLNPAIR(" stealthChop max speed: ", st.get_pwm_thrs());
}
#endif
#if USE_SENSORLESS
template<typename TMC>
void tmc_print_sgt(TMC &st) {
st.printLabel();
SERIAL_ECHOPGM(" homing sensitivity: ");
SERIAL_PRINTLN(st.sgt(), DEC);
}
#endif
void monitor_tmc_driver();
void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z, const bool test_e);
@@ -268,10 +277,6 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
void tmc_get_registers(const bool print_x, const bool print_y, const bool print_z, const bool print_e);
#endif
#if HAS_LCD_MENU
void init_tmc_section();
#endif
/**
* TMC2130 specific sensorless homing using stallGuard2.
* stallGuard2 only works when in spreadCycle mode.
@@ -295,3 +300,5 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
#if TMC_HAS_SPI
void tmc_init_cs_pins();
#endif
#endif // HAS_TRINAMIC
+3 -4
View File
@@ -237,10 +237,6 @@ void GcodeSuite::G28(const bool always_home_all) {
workspace_plane = PLANE_XY;
#endif
#if ENABLED(BLTOUCH)
bltouch.init();
#endif
// Always home with tool 0 active
#if HOTENDS > 1
#if DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE)
@@ -353,6 +349,9 @@ void GcodeSuite::G28(const bool always_home_all) {
// Home Z last if homing towards the bed
#if Z_HOME_DIR < 0
if (doZ) {
#if ENABLED(BLTOUCH)
bltouch.init();
#endif
#if ENABLED(Z_SAFE_HOMING)
home_z_safely();
#else
+106 -59
View File
@@ -73,11 +73,6 @@ void GcodeSuite::G34() {
do { // break out on error
if (!TEST(axis_known_position, X_AXIS) || !TEST(axis_known_position, Y_AXIS)) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> XY homing required.");
break;
}
const int8_t z_auto_align_iterations = parser.intval('I', Z_STEPPER_ALIGN_ITERATIONS);
if (!WITHIN(z_auto_align_iterations, 1, 30)) {
SERIAL_ECHOLNPGM("?(I)teration out of bounds (1-30).");
@@ -111,10 +106,6 @@ void GcodeSuite::G34() {
workspace_plane = PLANE_XY;
#endif
#if ENABLED(BLTOUCH)
bltouch.init();
#endif
// Always home with tool 0 active
#if HOTENDS > 1
const uint8_t old_tool_index = active_extruder;
@@ -125,70 +116,122 @@ void GcodeSuite::G34() {
extruder_duplication_enabled = false;
#endif
// Before moving other axes raise Z, if needed. Never lower Z.
if (current_position[Z_AXIS] < Z_CLEARANCE_BETWEEN_PROBES) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before moving to probe pos) to ", Z_CLEARANCE_BETWEEN_PROBES);
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
}
#if BOTH(BLTOUCH, BLTOUCH_HS_MODE)
// In BLTOUCH HS mode, the probe travels in a deployed state.
// Users of G34 might have a badly misaligned bed, so raise Z by the
// length of the deployed pin (BLTOUCH stroke < 7mm)
#define Z_BASIC_CLEARANCE Z_CLEARANCE_BETWEEN_PROBES + 7.0f
#else
#define Z_BASIC_CLEARANCE Z_CLEARANCE_BETWEEN_PROBES
#endif
// 0.05 is a 5% incline. On a 300mm bed that would be a misalignment of about 1.5cm.
// This angle is the maximum misalignment catered for
#define MAX_ANGLE 0.05f
float z_probe = Z_BASIC_CLEARANCE + MAX_ANGLE * (
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS)
SQRT(MAX(HYPOT2(z_auto_align_xpos[0] - z_auto_align_ypos[0], z_auto_align_xpos[1] - z_auto_align_ypos[1]),
HYPOT2(z_auto_align_xpos[1] - z_auto_align_ypos[1], z_auto_align_xpos[2] - z_auto_align_ypos[2]),
HYPOT2(z_auto_align_xpos[2] - z_auto_align_ypos[2], z_auto_align_xpos[0] - z_auto_align_ypos[0])))
#else
HYPOT(z_auto_align_xpos[0] - z_auto_align_ypos[0], z_auto_align_xpos[1] - z_auto_align_ypos[1])
#endif
);
// Home before the alignment procedure
gcode.G28(false);
// Move the Z coordinate realm towards the positive - dirty trick
current_position[Z_AXIS] -= z_probe * 0.5;
// Remember corrections to determine errors on each iteration
float last_z_align_move[Z_STEPPER_COUNT] = ARRAY_N(Z_STEPPER_COUNT, 10000.0f, 10000.0f, 10000.0f),
z_measured[Z_STEPPER_COUNT] = { 0 };
z_measured[Z_STEPPER_COUNT] = { 0 },
z_maxdiff = 0.0f,
amplification = z_auto_align_amplification;
uint8_t iteration;
bool err_break = false;
for (uint8_t iteration = 0; iteration < z_auto_align_iterations; ++iteration) {
for (iteration = 0; iteration < z_auto_align_iterations; ++iteration) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> probing all positions.");
// Reset minimum value
float z_measured_min = 100000.0f;
// For each iteration go through all probe positions (one per Z-Stepper)
for (uint8_t zstepper = 0; zstepper < Z_STEPPER_COUNT; ++zstepper) {
// Probe a Z height for each stepper
z_measured[zstepper] = probe_pt(z_auto_align_xpos[zstepper], z_auto_align_ypos[zstepper], PROBE_PT_RAISE, false);
SERIAL_ECHOLNPAIR(" \nITERATION: ", int(iteration + 1));
// Stop on error
if (isnan(z_measured[zstepper])) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> PROBING FAILED!");
// Initialize minimum value
float z_measured_min = 100000.0f;
// Probe all positions (one per Z-Stepper)
for (uint8_t zstepper = 0; zstepper < Z_STEPPER_COUNT; ++zstepper) {
// Safe clearance even on an incline
do_blocking_move_to_z(z_probe);
// Probe a Z height for each stepper
if (isnan(probe_pt(z_auto_align_xpos[zstepper], z_auto_align_ypos[zstepper], PROBE_PT_RAISE, 0, true))) {
SERIAL_ECHOLNPGM("Probing failed.");
err_break = true;
break;
}
// This is not the trigger Z value. It is the position of the probe after raising it.
// It is higher than the trigger value by a constant value (not known here). This value
// is more useful for determining the desired next iteration Z position for probing. It is
// equally well suited for determining the misalignment, just like the trigger position would be.
z_measured[zstepper] = current_position[Z_AXIS];
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " measured position is ", z_measured[zstepper]);
// Remember the maximum position to calculate the correction
// Remember the minimum measurement to calculate the correction later on
z_measured_min = MIN(z_measured_min, z_measured[zstepper]);
}
} // for (zstepper)
if (err_break) break;
// Remember the current z position to return to
float z_original_position = current_position[Z_AXIS];
// Adapt the next probe clearance height based on the new measurements.
// Safe_height = lowest distance to bed (= highest measurement) plus highest measured misalignment.
SERIAL_EOL();
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS)
z_maxdiff = MAX(ABS(z_measured[0] - z_measured[1]), ABS(z_measured[1] - z_measured[2]), ABS(z_measured[2] - z_measured[0]));
z_probe = Z_BASIC_CLEARANCE + MAX(z_measured[0], z_measured[1], z_measured[2]) + z_maxdiff;
SERIAL_ECHOLNPAIR("DIFFERENCE Z1-Z2: ", ABS(z_measured[0] - z_measured[1]),
"DIFFERENCE Z2-Z3: ", ABS(z_measured[1] - z_measured[2]),
"DIFFERENCE Z3-Z1: ", ABS(z_measured[2] - z_measured[0]));
#else
z_maxdiff = ABS(z_measured[0] - z_measured[1]);
z_probe = Z_BASIC_CLEARANCE + MAX(z_measured[0], z_measured[1]) + z_maxdiff;
SERIAL_ECHOLNPAIR("DIFFERENCE Z1-Z2: ", ABS(z_measured[0] - z_measured[1]));
#endif
SERIAL_EOL();
// Raise to the new next probing height right away
do_blocking_move_to_z(z_probe);
// The following correction actions are to be enabled for select Z-steppers only
stepper.set_separate_multi_axis(true);
// Iterations can stop early if all corrections are below required accuracy
bool success_break = true;
// Correct stepper offsets and re-iterate
// Correct the individual stepper offsets
for (uint8_t zstepper = 0; zstepper < Z_STEPPER_COUNT; ++zstepper) {
stepper.set_separate_multi_axis(true);
set_all_z_lock(true); // Steppers will be enabled separately
// Calculate current stepper move
const float z_align_move = z_measured[zstepper] - z_measured_min,
z_align_abs = ABS(z_align_move);
// Check for lost accuracy compared to last move
// Optimize one iterations correction based on the first measurements
if (z_align_abs > 0.0f) amplification = iteration == 1 ? MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification;
// Check for less accuracy compared to last move
if (last_z_align_move[zstepper] < z_align_abs - 1.0) {
// Stop here
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> detected decreasing accuracy.");
SERIAL_ECHOLNPGM("Decreasing accuracy detected.");
err_break = true;
break;
}
else
last_z_align_move[zstepper] = z_align_abs;
// Remember the alignment for the next iteration
last_z_align_move[zstepper] = z_align_abs;
// Only stop early if all measured points achieve accuracy target
// 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);
// Lock all steppers except one
set_all_z_lock(true);
switch (zstepper) {
case 0: stepper.set_z_lock(false); break;
case 1: stepper.set_z2_lock(false); break;
@@ -197,26 +240,25 @@ void GcodeSuite::G34() {
#endif
}
// This will lose home position and require re-homing
do_blocking_move_to_z(z_auto_align_amplification * z_align_move + current_position[Z_AXIS]);
}
// Do a move to correct part of the misalignment for the current stepper
do_blocking_move_to_z(amplification * z_align_move + current_position[Z_AXIS]);
} // for (zstepper)
// Back to normal stepper operations
set_all_z_lock(false);
stepper.set_separate_multi_axis(false);
if (err_break) break;
// Move Z back to previous position
set_all_z_lock(true);
do_blocking_move_to_z(z_original_position);
set_all_z_lock(false);
if (success_break) { SERIAL_ECHOLNPGM("Target accuracy achieved."); break; }
stepper.set_separate_multi_axis(false);
} // for (iteration)
if (success_break) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> achieved target accuracy.");
break;
}
}
if (err_break) { SERIAL_ECHOLNPGM("Aborted due to error."); break; }
if (err_break) break;
SERIAL_ECHOLNPAIR("Performed iterations: ", int(iteration + (iteration != z_auto_align_iterations)), " of ", int(z_auto_align_iterations));
SERIAL_ECHOLNPAIR_F("Achieved accuracy: ", z_maxdiff);
SERIAL_EOL();
// Restore the active tool after homing
#if HOTENDS > 1
@@ -229,15 +271,20 @@ void GcodeSuite::G34() {
));
#endif
#if HAS_LEVELING
#if ENABLED(RESTORE_LEVELING_AFTER_G34)
set_bed_leveling_enabled(leveling_was_active);
#endif
#if HAS_LEVELING && ENABLED(RESTORE_LEVELING_AFTER_G34)
set_bed_leveling_enabled(leveling_was_active);
#endif
// After this operation the z position needs correction
set_axis_is_not_at_home(Z_AXIS);
#if BOTH(BLTOUCH, BLTOUCH_HS_MODE)
// In BLTOUCH HS mode, the pin is still deployed at this point.
// The upcoming G28 means travel, so it is better to stow the pin.
bltouch._stow();
#endif
// Home after the alignment procedure
gcode.G28(false);
} while(0);
+5 -2
View File
@@ -25,14 +25,17 @@
#if ENABLED(CALIBRATION_GCODE)
#include "../gcode.h"
#if ENABLED(BACKLASH_GCODE)
#include "../../feature/backlash.h"
#endif
#include "../../lcd/ultralcd.h"
#include "../../module/motion.h"
#include "../../module/planner.h"
#include "../../module/tool_change.h"
#include "../../module/endstops.h"
#include "../../feature/bedlevel/bedlevel.h"
#include "../../feature/backlash.h"
/**
* G425 backs away from the calibration object by various distances
+131 -104
View File
@@ -34,6 +34,10 @@
#include "../../module/servo.h"
#endif
#if ENABLED(BLTOUCH)
#include "../../feature/bltouch.h"
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
#include "../../feature/host_actions.h"
#endif
@@ -91,122 +95,152 @@ inline void toggle_pins() {
} // toggle_pins
inline void servo_probe_test() {
#if !(NUM_SERVOS > 0 && HAS_SERVO_0)
SERIAL_ERROR_MSG("SERVO not setup");
SERIAL_ERROR_MSG("SERVO not set up.");
#elif !HAS_Z_SERVO_PROBE
SERIAL_ERROR_MSG("Z_PROBE_SERVO_NR not setup");
SERIAL_ERROR_MSG("Z_PROBE_SERVO_NR not set up.");
#else // HAS_Z_SERVO_PROBE
const uint8_t probe_index = parser.byteval('P', Z_PROBE_SERVO_NR);
SERIAL_ECHOLNPGM("Servo probe test");
SERIAL_ECHOLNPAIR(". using index: ", probe_index);
SERIAL_ECHOLNPAIR(". deploy angle: ", servo_angles[probe_index][0]);
SERIAL_ECHOLNPAIR(". stow angle: ", servo_angles[probe_index][1]);
SERIAL_ECHOLNPAIR("Servo probe test\n"
". using index: ", int(probe_index),
", deploy angle: ", servo_angles[probe_index][0],
", stow angle: ", servo_angles[probe_index][1]
);
bool probe_inverting;
bool deploy_state, stow_state;
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
#define PROBE_TEST_PIN Z_MIN_PIN
constexpr bool probe_inverting = Z_MIN_ENDSTOP_INVERTING;
SERIAL_ECHOLNPAIR(". probe uses Z_MIN pin: ", PROBE_TEST_PIN);
SERIAL_ECHOLNPGM(". uses Z_MIN_ENDSTOP_INVERTING (ignores Z_MIN_PROBE_ENDSTOP_INVERTING)");
SERIAL_ECHOLNPAIR(". Probe Z_MIN_PIN: ", int(PROBE_TEST_PIN));
SERIAL_ECHOPGM(". Z_MIN_ENDSTOP_INVERTING: ");
#if Z_MIN_ENDSTOP_INVERTING
SERIAL_ECHOLNPGM("true");
#else
SERIAL_ECHOLNPGM("false");
#endif
probe_inverting = Z_MIN_ENDSTOP_INVERTING;
#elif USES_Z_MIN_PROBE_ENDSTOP
#else
#define PROBE_TEST_PIN Z_MIN_PROBE_PIN
SERIAL_ECHOLNPAIR(". probe uses Z_MIN_PROBE_PIN: ", PROBE_TEST_PIN);
SERIAL_ECHOLNPGM(". uses Z_MIN_PROBE_ENDSTOP_INVERTING (ignores Z_MIN_ENDSTOP_INVERTING)");
SERIAL_ECHOPGM(". Z_MIN_PROBE_ENDSTOP_INVERTING: ");
constexpr bool probe_inverting = Z_MIN_PROBE_ENDSTOP_INVERTING;
#if Z_MIN_PROBE_ENDSTOP_INVERTING
SERIAL_ECHOLNPGM("true");
#else
SERIAL_ECHOLNPGM("false");
#endif
probe_inverting = Z_MIN_PROBE_ENDSTOP_INVERTING;
SERIAL_ECHOLNPAIR(". Probe Z_MIN_PROBE_PIN: ", int(PROBE_TEST_PIN));
SERIAL_ECHOPGM( ". Z_MIN_PROBE_ENDSTOP_INVERTING: ");
#endif
SERIAL_ECHOLNPGM(". deploy & stow 4 times");
serialprint_truefalse(probe_inverting);
SERIAL_EOL();
SET_INPUT_PULLUP(PROBE_TEST_PIN);
uint8_t i = 0;
bool deploy_state, stow_state;
do {
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy
safe_delay(500);
deploy_state = READ(PROBE_TEST_PIN);
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][1]); // Stow
safe_delay(500);
stow_state = READ(PROBE_TEST_PIN);
} while (++i < 4);
if (probe_inverting != deploy_state) SERIAL_ECHOLNPGM("WARNING - INVERTING setting probably backwards");
if (deploy_state != stow_state) {
SERIAL_ECHOLNPGM("BLTouch clone detected");
if (deploy_state) {
SERIAL_ECHOLNPGM(". DEPLOYED state: HIGH (logic 1)");
SERIAL_ECHOLNPGM(". STOWED (triggered) state: LOW (logic 0)");
// First, check for a probe that recognizes an advanced BLTouch sequence.
// In addition to STOW and DEPLOY, it uses SW MODE (and RESET in the beginning)
// to see if this is one of the following: BLTOUCH Classic 1.2, 1.3, or
// BLTouch Smart 1.0, 2.0, 2.2, 3.0, 3.1. But only if the user has actually
// configured a BLTouch as being present. If the user has not configured this,
// the BLTouch will be detected in the last phase of these tests (see further on).
bool blt = false;
// This code will try to detect a BLTouch probe or clone
#if ENABLED(BLTOUCH)
SERIAL_ECHOLNPGM(". Check for BLTOUCH");
bltouch._reset();
bltouch._stow();
if (probe_inverting == READ(PROBE_TEST_PIN)) {
bltouch._set_SW_mode();
if (probe_inverting != READ(PROBE_TEST_PIN)) {
bltouch._deploy();
if (probe_inverting == READ(PROBE_TEST_PIN)) {
bltouch._stow();
SERIAL_ECHOLNPGM("= BLTouch Classic 1.2, 1.3, Smart 1.0, 2.0, 2.2, 3.0, 3.1 detected.");
// Check for a 3.1 by letting the user trigger it, later
blt = true;
}
}
else {
SERIAL_ECHOLNPGM(". DEPLOYED state: LOW (logic 0)");
SERIAL_ECHOLNPGM(". STOWED (triggered) state: HIGH (logic 1)");
}
#if ENABLED(BLTOUCH)
SERIAL_ECHOLNPGM("ERROR: BLTOUCH enabled - set this device up as a Z Servo Probe with inverting as true.");
#endif
}
else { // measure active signal length
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy
safe_delay(500);
SERIAL_ECHOLNPGM("please trigger probe");
uint16_t probe_counter = 0;
#endif
// Allow 30 seconds max for operator to trigger probe
for (uint16_t j = 0; j < 500 * 30 && probe_counter == 0 ; j++) {
// The following code is common to all kinds of servo probes.
// Since it could be a real servo or a BLTouch (any kind) or a clone,
// use only "common" functions - i.e. SERVO_MOVE. No bltouch.xxxx stuff.
safe_delay(2);
// If it is already recognised as a being a BLTouch, no need for this test
if (!blt) {
// DEPLOY and STOW 4 times and see if the signal follows
// Then it is a mechanical switch
uint8_t i = 0;
SERIAL_ECHOLNPGM(". Deploy & stow 4 times");
do {
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy
safe_delay(500);
deploy_state = READ(PROBE_TEST_PIN);
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][1]); // Stow
safe_delay(500);
stow_state = READ(PROBE_TEST_PIN);
} while (++i < 4);
if (0 == j % (500 * 1)) gcode.reset_stepper_timeout(); // Keep steppers powered
if (probe_inverting != deploy_state) SERIAL_ECHOLNPGM("WARNING: INVERTING setting probably backwards.");
if (deploy_state != READ(PROBE_TEST_PIN)) { // probe triggered
if (deploy_state != stow_state) {
SERIAL_ECHOLNPGM("= Mechanical Switch detected");
if (deploy_state) {
SERIAL_ECHOLNPAIR(" DEPLOYED state: HIGH (logic 1)",
" STOWED (triggered) state: LOW (logic 0)");
}
else {
SERIAL_ECHOLNPAIR(" DEPLOYED state: LOW (logic 0)",
" STOWED (triggered) state: HIGH (logic 1)");
}
#if ENABLED(BLTOUCH)
SERIAL_ECHOLNPGM("FAIL: BLTOUCH enabled - Set up this device as a Servo Probe with INVERTING set to 'true'.");
#endif
return;
}
}
for (probe_counter = 1; probe_counter < 50 && deploy_state != READ(PROBE_TEST_PIN); ++probe_counter)
safe_delay(2);
// Ask the user for a trigger event and measure the pulse width.
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy
safe_delay(500);
SERIAL_ECHOLNPGM("** Please trigger probe within 30 sec **");
uint16_t probe_counter = 0;
if (probe_counter == 50)
SERIAL_ECHOLNPGM("Z Servo Probe detected"); // >= 100mS active time
else if (probe_counter >= 2)
SERIAL_ECHOLNPAIR("BLTouch compatible probe detected - pulse width (+/- 4mS): ", probe_counter * 2); // allow 4 - 100mS pulse
else
SERIAL_ECHOLNPGM("noise detected - please re-run test"); // less than 2mS pulse
// Wait 30 seconds for user to trigger probe
for (uint16_t j = 0; j < 500 * 30 && probe_counter == 0 ; j++) {
safe_delay(2);
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][1]); // Stow
if (0 == j % (500 * 1)) gcode.reset_stepper_timeout(); // Keep steppers powered
} // pulse detected
if (deploy_state != READ(PROBE_TEST_PIN)) { // probe triggered
for (probe_counter = 0; probe_counter < 15 && deploy_state != READ(PROBE_TEST_PIN); ++probe_counter) safe_delay(2);
} // for loop waiting for trigger
if (probe_counter == 15)
SERIAL_ECHOLNPGM(". Pulse width: 30ms or more");
else
SERIAL_ECHOLNPAIR(". Pulse width (+/- 4ms): ", probe_counter * 2);
if (probe_counter >= 4) {
if (probe_counter == 15) {
if (blt) SERIAL_ECHOPGM("= BLTouch V3.1");
else SERIAL_ECHOPGM("= Z Servo Probe");
}
else SERIAL_ECHOPGM("= BLTouch pre V3.1 or compatible probe");
SERIAL_ECHOLNPGM(" detected.");
}
else SERIAL_ECHOLNPGM("FAIL: Noise detected - please re-run test");
if (probe_counter == 0) SERIAL_ECHOLNPGM("trigger not detected");
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][1]); // Stow
return;
}
}
} // measure active signal length
if (!probe_counter) SERIAL_ECHOLNPGM("FAIL: Trigger not detected");
#endif
#endif // HAS_Z_SERVO_PROBE
} // servo_probe_test
@@ -239,12 +273,10 @@ inline void servo_probe_test() {
*/
void GcodeSuite::M43() {
if (parser.seen('T')) { // must be first or else its "S" and "E" parameters will execute endstop or servo test
toggle_pins();
return;
}
// 'T' must be first. It uses 'S' and 'E' differently.
if (parser.seen('T')) return toggle_pins();
// Enable or disable endstop monitoring
// 'E' Enable or disable endstop monitoring and return
if (parser.seen('E')) {
endstops.monitor_flag = parser.value_bool();
SERIAL_ECHOPGM("endstop monitor ");
@@ -253,25 +285,23 @@ void GcodeSuite::M43() {
return;
}
if (parser.seen('S')) {
servo_probe_test();
return;
}
// 'S' Run servo probe test and return
if (parser.seen('S')) return servo_probe_test();
// Get the range of pins to test or watch
// 'P' Get the range of pins to test or watch
uint8_t first_pin = PARSED_PIN_INDEX('P', 0),
last_pin = parser.seenval('P') ? first_pin : NUMBER_PINS_TOTAL - 1;
if (first_pin > last_pin) return;
// 'I' to ignore protected pins
const bool ignore_protection = parser.boolval('I');
// Watch until click, M108, or reset
// 'W' Watch until click, M108, or reset
if (parser.boolval('W')) {
SERIAL_ECHOLNPGM("Watching pins");
#ifdef ARDUINO_ARCH_SAM
NOLESS(first_pin, 2); // don't hijack the UART pins
NOLESS(first_pin, 2); // Don't hijack the UART pins
#endif
uint8_t pin_state[last_pin - first_pin + 1];
for (uint8_t i = first_pin; i <= last_pin; i++) {
@@ -280,11 +310,11 @@ void GcodeSuite::M43() {
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
pinMode(pin, INPUT_PULLUP);
delay(1);
/*
/*
if (IS_ANALOG(pin))
pin_state[pin - first_pin] = analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)); // int16_t pin_state[...]
else
//*/
//*/
pin_state[i - first_pin] = extDigitalRead(pin);
}
@@ -303,9 +333,9 @@ void GcodeSuite::M43() {
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
const byte val =
/*
IS_ANALOG(pin)
? analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)) : // int16_t val
:
IS_ANALOG(pin)
? analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)) : // int16_t val
:
//*/
extDigitalRead(pin);
if (val != pin_state[i - first_pin]) {
@@ -315,21 +345,18 @@ void GcodeSuite::M43() {
}
#if HAS_RESUME_CONTINUE
if (!wait_for_user) {
KEEPALIVE_STATE(IN_HANDLER);
break;
}
if (!wait_for_user) { KEEPALIVE_STATE(IN_HANDLER); break; }
#endif
safe_delay(200);
}
return;
}
// Report current state of selected pin(s)
for (uint8_t i = first_pin; i <= last_pin; i++) {
pin_t pin = GET_PIN_MAP_PIN(i);
if (VALID_PIN(pin)) report_pin_state_extended(pin, ignore_protection, true);
else {
// Report current state of selected pin(s)
for (uint8_t i = first_pin; i <= last_pin; i++) {
pin_t pin = GET_PIN_MAP_PIN(i);
if (VALID_PIN(pin)) report_pin_state_extended(pin, ignore_protection, true);
}
}
}
+1 -1
View File
@@ -45,7 +45,7 @@ void GcodeSuite::M226() {
case 0: target = LOW; break;
case -1: target = !extDigitalRead(pin); break;
}
while (extDigitalRead(pin) != target) idle();
while (int(extDigitalRead(pin)) != target) idle();
}
} // pin_state -1 0 1 && pin > -1
} // parser.seen('P')
+7 -2
View File
@@ -34,8 +34,13 @@ 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'))
MOVE_SERVO(servo_index, parser.value_int());
if (parser.seen('S')) {
const int a = parser.value_int();
if (a == -1)
servo[servo_index].detach();
else
MOVE_SERVO(servo_index, a);
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOPAIR(" Servo ", servo_index);
+1 -1
View File
@@ -34,7 +34,7 @@
/**
*
* M916: increase KVAL_HOLD until get thermal warning
* M916: Increase KVAL_HOLD until thermal warning
*
*
* J - select which driver(s) to monitor on multi-driver axis
+2 -2
View File
@@ -43,8 +43,8 @@
* With no parameters report driver currents.
*/
void GcodeSuite::M906() {
#define TMC_SAY_CURRENT(Q) tmc_get_current(stepper##Q)
#define TMC_SET_CURRENT(Q) tmc_set_current(stepper##Q, value)
#define TMC_SAY_CURRENT(Q) tmc_print_current(stepper##Q)
#define TMC_SET_CURRENT(Q) stepper##Q.rms_current(value)
bool report = true;
+18 -20
View File
@@ -192,10 +192,10 @@
*/
#if ENABLED(HYBRID_THRESHOLD)
void GcodeSuite::M913() {
#define TMC_SAY_PWMTHRS(A,Q) tmc_get_pwmthrs(stepper##Q, planner.settings.axis_steps_per_mm[_AXIS(A)])
#define TMC_SET_PWMTHRS(A,Q) tmc_set_pwmthrs(stepper##Q, value, planner.settings.axis_steps_per_mm[_AXIS(A)])
#define TMC_SAY_PWMTHRS_E(E) tmc_get_pwmthrs(stepperE##E, planner.settings.axis_steps_per_mm[E_AXIS_N(E)])
#define TMC_SET_PWMTHRS_E(E) tmc_set_pwmthrs(stepperE##E, value, planner.settings.axis_steps_per_mm[E_AXIS_N(E)])
#define TMC_SAY_PWMTHRS(A,Q) tmc_print_pwmthrs(stepper##Q)
#define TMC_SET_PWMTHRS(A,Q) stepper##Q.set_pwm_thrs(value)
#define TMC_SAY_PWMTHRS_E(E) tmc_print_pwmthrs(stepperE##E)
#define TMC_SET_PWMTHRS_E(E) stepperE##E.set_pwm_thrs(value)
bool report = true;
#if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3)
@@ -309,8 +309,6 @@
*/
#if USE_SENSORLESS
void GcodeSuite::M914() {
#define TMC_SAY_SGT(Q) tmc_get_sgt(stepper##Q)
#define TMC_SET_SGT(Q) tmc_set_sgt(stepper##Q, value)
bool report = true;
const uint8_t index = parser.byteval('I');
@@ -321,33 +319,33 @@
#if X_SENSORLESS
case X_AXIS:
#if AXIS_HAS_STALLGUARD(X)
if (index < 2) TMC_SET_SGT(X);
if (index < 2) stepperX.sgt(value);
#endif
#if AXIS_HAS_STALLGUARD(X2)
if (!(index & 1)) TMC_SET_SGT(X2);
if (!(index & 1)) stepperX2.sgt(value);
#endif
break;
#endif
#if Y_SENSORLESS
case Y_AXIS:
#if AXIS_HAS_STALLGUARD(Y)
if (index < 2) TMC_SET_SGT(Y);
if (index < 2) stepperY.sgt(value);
#endif
#if AXIS_HAS_STALLGUARD(Y2)
if (!(index & 1)) TMC_SET_SGT(Y2);
if (!(index & 1)) stepperY2.sgt(value);
#endif
break;
#endif
#if Z_SENSORLESS
case Z_AXIS:
#if AXIS_HAS_STALLGUARD(Z)
if (index < 2) TMC_SET_SGT(Z);
if (index < 2) stepperZ.sgt(value);
#endif
#if AXIS_HAS_STALLGUARD(Z2)
if (index == 0 || index == 2) TMC_SET_SGT(Z2);
if (index == 0 || index == 2) stepperZ2.sgt(value);
#endif
#if AXIS_HAS_STALLGUARD(Z3)
if (index == 0 || index == 3) TMC_SET_SGT(Z3);
if (index == 0 || index == 3) stepperZ3.sgt(value);
#endif
break;
#endif
@@ -357,29 +355,29 @@
if (report) {
#if X_SENSORLESS
#if AXIS_HAS_STALLGUARD(X)
TMC_SAY_SGT(X);
tmc_print_sgt(stepperX);
#endif
#if AXIS_HAS_STALLGUARD(X2)
TMC_SAY_SGT(X2);
tmc_print_sgt(stepperX2);
#endif
#endif
#if Y_SENSORLESS
#if AXIS_HAS_STALLGUARD(Y)
TMC_SAY_SGT(Y);
tmc_print_sgt(stepperY);
#endif
#if AXIS_HAS_STALLGUARD(Y2)
TMC_SAY_SGT(Y2);
tmc_print_sgt(stepperY2);
#endif
#endif
#if Z_SENSORLESS
#if AXIS_HAS_STALLGUARD(Z)
TMC_SAY_SGT(Z);
tmc_print_sgt(stepperZ);
#endif
#if AXIS_HAS_STALLGUARD(Z2)
TMC_SAY_SGT(Z2);
tmc_print_sgt(stepperZ2);
#endif
#if AXIS_HAS_STALLGUARD(Z3)
TMC_SAY_SGT(Z3);
tmc_print_sgt(stepperZ3);
#endif
#endif
}
+20 -13
View File
@@ -103,6 +103,7 @@
* M42 - Change pin status via gcode: M42 P<pin> S<value>. LED pin assumed if P is omitted.
* M43 - Display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
* M48 - Measure Z Probe repeatability: M48 P<points> X<pos> Y<pos> V<level> E<engage> L<legs> S<chizoid>. (Requires Z_MIN_PROBE_REPEATABILITY_TEST)
* M73 - Set the progress percentage. (Requires LCD_SET_PROGRESS_MANUALLY)
* M75 - Start the print job timer.
* M76 - Pause the print job timer.
* M77 - Stop the print job timer.
@@ -121,8 +122,8 @@
* M106 - Set print fan speed.
* M107 - Print fan off.
* M108 - Break out of heating loops (M109, M190, M303). With no controller, breaks out of M0/M1. (Requires EMERGENCY_PARSER)
* M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating
* Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling
* M109 - S<temp> Wait for extruder current temp to reach target temp. ** Wait only when heating! **
* R<temp> Wait for extruder current temp to reach target temp. ** Wait for heating or cooling. **
* If AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
* M110 - Set the current line number. (Used by host printing)
* M111 - Set debug flags: "M111 S<flagbits>". See flag bits defined in enum.h.
@@ -135,13 +136,14 @@
* M119 - Report endstops status.
* M120 - Enable endstops detection.
* M121 - Disable endstops detection.
* M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/TMC2208/TMC2660)
* M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/TMC2208/TMC2660 or L6470)
* M125 - Save current position and move to filament change position. (Requires PARK_HEAD_ON_PAUSE)
* M126 - Solenoid Air Valve Open. (Requires BARICUDA)
* M127 - Solenoid Air Valve Closed. (Requires BARICUDA)
* M128 - EtoP Open. (Requires BARICUDA)
* M129 - EtoP Closed. (Requires BARICUDA)
* M140 - Set bed target temp. S<temp>
* M141 - Set heated chamber target temp. S<temp> (Requires a chamber heater)
* M145 - Set heatup values for materials on the LCD. H<hotend> B<bed> F<fan speed> for S<material> (0=PLA, 1=ABS)
* M149 - Set temperature units. (Requires TEMPERATURE_UNITS_SUPPORT)
* M150 - Set Status LED Color as R<red> U<green> B<blue> P<bright>. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632).
@@ -150,8 +152,8 @@
* M164 - Commit the mix and save to a virtual tool (current, or as specified by 'S'). (Requires MIXING_EXTRUDER)
* M165 - Set the mix for the mixing extruder (and current virtual tool) with parameters ABCDHI. (Requires MIXING_EXTRUDER and DIRECT_MIXING_IN_G1)
* M166 - Set the Gradient Mix for the mixing extruder. (Requires GRADIENT_MIX)
* M190 - Sxxx Wait for bed current temp to reach target temp. ** Waits only when heating! **
* Rxxx Wait for bed current temp to reach target temp. ** Waits for heating or cooling. **
* M190 - S<temp> Wait for bed current temp to reach target temp. ** Wait only when heating! **
* R<temp> Wait for bed current temp to reach target temp. ** Wait for heating or cooling. **
* M200 - Set filament diameter, D<diameter>, setting E axis units to cubic. (Use S0 to revert to linear units.)
* M201 - Set max acceleration in units/s^2 for print moves: "M201 X<accel> Y<accel> Z<accel> E<accel>"
* M202 - Set max acceleration in units/s^2 for travel moves: "M202 X<accel> Y<accel> Z<accel> E<accel>" ** UNUSED IN MARLIN! **
@@ -210,9 +212,10 @@
* M501 - Restore parameters from EEPROM. (Requires EEPROM_SETTINGS)
* M502 - Revert to the default "factory settings". ** Does not write them to EEPROM! **
* M503 - Print the current settings (in memory): "M503 S<verbose>". S0 specifies compact output.
* M504 - Validate EEPROM contents. (Requires EEPROM_SETTINGS)
* M524 - Abort the current SD print job (started with M24)
* M540 - Enable/disable SD card abort on endstop hit: "M540 S<state>". (Requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
* M569 - Enable stealthChop on an axis. (Requires at least one #_X_DRIVER_TYPE to be TMC2130 or TMC2208)
* M569 - Enable stealthChop on an axis. (Requires at least one _DRIVER_TYPE to be TMC2130 or TMC2208)
* M600 - Pause for filament change: "M600 X<pos> Y<pos> Z<raise> E<first_retract> L<later_retract>". (Requires ADVANCED_PAUSE_FEATURE)
* M603 - Configure filament change: "M603 T<tool> U<unload_length> L<load_length>". (Requires ADVANCED_PAUSE_FEATURE)
* M605 - Set Dual X-Carriage movement mode: "M605 S<mode> [X<x_offset>] [R<temp_offset>]". (Requires DUAL_X_CARRIAGE)
@@ -233,8 +236,9 @@
* M867 - Enable/disable or toggle error correction for position encoder modules.
* M868 - Report or set position encoder module error correction threshold.
* M869 - Report position encoder module error.
* M876 - Handle Prompt Response. (Requires HOST_PROMPT_SUPPORT and not EMERGENCY_PARSER)
* M900 - Get or Set Linear Advance K-factor. (Requires LIN_ADVANCE)
* M906 - Set or get motor current in milliamps using axis codes X, Y, Z, E. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/TMC2208/TMC2660)
* M906 - Set or get motor current in milliamps using axis codes X, Y, Z, E. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/TMC2208/TMC2660 or L6470)
* M907 - Set digital trimpot motor current using axis codes. (Requires a board with digital trimpots)
* M908 - Control digital trimpot directly. (Requires DAC_STEPPER_CURRENT or DIGIPOTSS_PIN)
* M909 - Print digipot/DAC current value. (Requires DAC_STEPPER_CURRENT)
@@ -243,9 +247,11 @@
* M912 - Clear stepper driver overtemperature pre-warn condition flag. (Requires at least one _DRIVER_TYPE defined as TMC2130/TMC2208/TMC2660)
* M913 - Set HYBRID_THRESHOLD speed. (Requires HYBRID_THRESHOLD)
* M914 - Set StallGuard sensitivity. (Requires SENSORLESS_HOMING or SENSORLESS_PROBING)
* M917 - L6470 tuning: Find minimum current thresholds
* M918 - L6470 tuning: Increase speed until max or error
* M916 - L6470 tuning: Increase KVAL_HOLD until thermal warning. (Requires at least one _DRIVER_TYPE L6470)
* M917 - L6470 tuning: Find minimum current thresholds. (Requires at least one _DRIVER_TYPE L6470)
* M918 - L6470 tuning: Increase speed until max or error. (Requires at least one _DRIVER_TYPE L6470)
* M951 - Set Magnetic Parking Extruder parameters. (Requires MAGNETIC_PARKING_EXTRUDER)
* M7219 - Control Max7219 Matrix LEDs. (Requires MAX7219_GCODE)
*
* M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration)
* M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree)
@@ -254,6 +260,7 @@
* M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position)
*
* ************ Custom codes - This can change to suit future G-code regulations
* G425 - Calibrate using a conductive object. (Requires CALIBRATION_GCODE)
* M928 - Start SD logging: "M928 filename.gco". Stop with M29. (Requires SDSUPPORT)
* M997 - Perform in-application firmware update
* M999 - Restart after being stopped by error
@@ -788,10 +795,6 @@ private:
static void M702();
#endif
#if ENABLED(MAX7219_GCODE)
static void M7219();
#endif
#if ENABLED(GCODE_MACROS)
static void M810_819();
#endif
@@ -877,6 +880,10 @@ private:
static void M1000();
#endif
#if ENABLED(MAX7219_GCODE)
static void M7219();
#endif
static void T(const uint8_t tool_index);
};
+24 -16
View File
@@ -304,11 +304,12 @@
#define HEATER_0_MAX6675_TMAX 1024
#elif TEMP_SENSOR_0 == -1
#define HEATER_0_USES_AD595
#elif TEMP_SENSOR_0 == 1000
#define HEATER_0_USER_THERMISTOR
#elif TEMP_SENSOR_0 > 0
#define THERMISTOR_HEATER_0 TEMP_SENSOR_0
#define HEATER_0_USES_THERMISTOR
#if TEMP_SENSOR_0 == 1000
#define HEATER_0_USER_THERMISTOR
#endif
#else
#undef HEATER_0_MINTEMP
#undef HEATER_0_MAXTEMP
@@ -332,11 +333,12 @@
#define HEATER_1_MAX6675_TMAX 1024
#elif TEMP_SENSOR_1 == -1
#define HEATER_1_USES_AD595
#elif TEMP_SENSOR_1 == 1000
#define HEATER_1_USER_THERMISTOR
#elif TEMP_SENSOR_1 > 0
#define THERMISTOR_HEATER_1 TEMP_SENSOR_1
#define HEATER_1_USES_THERMISTOR
#if TEMP_SENSOR_1 == 1000
#define HEATER_1_USER_THERMISTOR
#endif
#else
#undef HEATER_1_MINTEMP
#undef HEATER_1_MAXTEMP
@@ -350,11 +352,12 @@
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2."
#elif TEMP_SENSOR_2 == -1
#define HEATER_2_USES_AD595
#elif TEMP_SENSOR_2 == 1000
#define HEATER_2_USER_THERMISTOR
#elif TEMP_SENSOR_2 > 0
#define THERMISTOR_HEATER_2 TEMP_SENSOR_2
#define HEATER_2_USES_THERMISTOR
#if TEMP_SENSOR_2 == 1000
#define HEATER_2_USER_THERMISTOR
#endif
#else
#undef HEATER_2_MINTEMP
#undef HEATER_2_MAXTEMP
@@ -368,11 +371,12 @@
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_3."
#elif TEMP_SENSOR_3 == -1
#define HEATER_3_USES_AD595
#elif TEMP_SENSOR_3 == 1000
#define HEATER_3_USER_THERMISTOR
#elif TEMP_SENSOR_3 > 0
#define THERMISTOR_HEATER_3 TEMP_SENSOR_3
#define HEATER_3_USES_THERMISTOR
#if TEMP_SENSOR_3 == 1000
#define HEATER_3_USER_THERMISTOR
#endif
#else
#undef HEATER_3_MINTEMP
#undef HEATER_3_MAXTEMP
@@ -386,11 +390,12 @@
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_4."
#elif TEMP_SENSOR_4 == -1
#define HEATER_4_USES_AD595
#elif TEMP_SENSOR_4 == 1000
#define HEATER_4_USER_THERMISTOR
#elif TEMP_SENSOR_4 > 0
#define THERMISTOR_HEATER_4 TEMP_SENSOR_4
#define HEATER_4_USES_THERMISTOR
#if TEMP_SENSOR_4 == 1000
#define HEATER_4_USER_THERMISTOR
#endif
#else
#undef HEATER_4_MINTEMP
#undef HEATER_4_MAXTEMP
@@ -404,11 +409,12 @@
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_5."
#elif TEMP_SENSOR_5 == -1
#define HEATER_5_USES_AD595
#elif TEMP_SENSOR_5 == 1000
#define HEATER_5_USER_THERMISTOR
#elif TEMP_SENSOR_5 > 0
#define THERMISTOR_HEATER_5 TEMP_SENSOR_5
#define HEATER_5_USES_THERMISTOR
#if TEMP_SENSOR_5 == 1000
#define HEATER_5_USER_THERMISTOR
#endif
#else
#undef HEATER_5_MINTEMP
#undef HEATER_5_MAXTEMP
@@ -422,11 +428,12 @@
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BED."
#elif TEMP_SENSOR_BED == -1
#define HEATER_BED_USES_AD595
#elif TEMP_SENSOR_BED == 1000
#define BED_USER_THERMISTOR
#elif TEMP_SENSOR_BED > 0
#define THERMISTORBED TEMP_SENSOR_BED
#define HEATER_BED_USES_THERMISTOR
#if TEMP_SENSOR_BED == 1000
#define HEATER_BED_USER_THERMISTOR
#endif
#else
#undef BED_MINTEMP
#undef BED_MAXTEMP
@@ -440,11 +447,12 @@
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_CHAMBER."
#elif TEMP_SENSOR_CHAMBER == -1
#define HEATER_CHAMBER_USES_AD595
#elif TEMP_SENSOR_CHAMBER == 1000
#define CHAMBER_USER_THERMISTOR
#elif TEMP_SENSOR_CHAMBER > 0
#define THERMISTORCHAMBER TEMP_SENSOR_CHAMBER
#define HEATER_CHAMBER_USES_THERMISTOR
#if TEMP_SENSOR_CHAMBER == 1000
#define HEATER_CHAMBER_USER_THERMISTOR
#endif
#else
#undef CHAMBER_MINTEMP
#undef CHAMBER_MAXTEMP
+5 -2
View File
@@ -985,6 +985,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#if HAS_BED_PROBE
static_assert(FLOOR(float(X_PROBE_OFFSET_FROM_EXTRUDER)) == float(X_PROBE_OFFSET_FROM_EXTRUDER), "X_PROBE_OFFSET_FROM_EXTRUDER must be an integer!");
static_assert(FLOOR(float(Y_PROBE_OFFSET_FROM_EXTRUDER)) == float(Y_PROBE_OFFSET_FROM_EXTRUDER), "Y_PROBE_OFFSET_FROM_EXTRUDER must be an integer!");
/**
* Z_PROBE_SLED is incompatible with DELTA
*/
@@ -1025,8 +1028,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#if ENABLED(BLTOUCH)
#if BLTOUCH_DELAY < 200
#error "BLTOUCH_DELAY less than 200 is unsafe and is not supported."
#elif DISABLED(BLTOUCH_FORCE_5V_MODE) && NONE(ENDSTOPPULLUPS, ENDSTOPPULLUP_ZMIN, ENDSTOPPULLUP_ZMIN_PROBE)
#error "BLTOUCH without BLTOUCH_FORCE_5V_MODE requires ENDSTOPPULLUPS, ENDSTOPPULLUP_ZMIN or ENDSTOPPULLUP_ZMIN_PROBE."
#elif DISABLED(BLTOUCH_SET_5V_MODE) && NONE(ENDSTOPPULLUPS, ENDSTOPPULLUP_ZMIN, ENDSTOPPULLUP_ZMIN_PROBE)
#error "BLTOUCH without BLTOUCH_SET_5V_MODE requires ENDSTOPPULLUPS, ENDSTOPPULLUP_ZMIN or ENDSTOPPULLUP_ZMIN_PROBE."
#endif
#endif
+2 -2
View File
@@ -39,7 +39,7 @@
/**
* Marlin release version identifier
*/
#define SHORT_BUILD_VERSION "2.0.x_TR15"
#define SHORT_BUILD_VERSION "2.0.x_TR16"
/**
* Verbose version identifier which should contain a reference to the location
@@ -52,7 +52,7 @@
* here we define this default string as the date where the latest release
* version was tagged.
*/
#define STRING_DISTRIBUTION_DATE "2019-05-15"
#define STRING_DISTRIBUTION_DATE "2019-05-26"
/**
* Required minimum Configuration.h and Configuration_adv.h file versions.
+1 -1
View File
@@ -418,7 +418,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline);
}
if (onpage) {
lcd_moveto(((lcd_chr_fit - 1) - (vallen + 1)) * one_chr_width, baseline); // Right-justified, leaving padded by spaces
lcd_moveto((lcd_chr_fit - (vallen + 1)) * one_chr_width, baseline); // Right-justified, leaving padded by spaces
lcd_put_wchar(' '); // overwrite char if value gets shorter
lcd_put_u8str(value);
}
+1 -1
View File
@@ -725,8 +725,8 @@ namespace ExtUI {
#if HAS_LEVELING
bool getLevelingActive() { return planner.leveling_active; }
void setLevelingActive(const bool state) { set_bed_leveling_enabled(state); }
bool getMeshValid() { return leveling_is_valid(); }
#if HAS_MESH
bool getMeshValid() { return leveling_is_valid(); }
bed_mesh_t getMeshArray() { return Z_VALUES_ARR; }
float getMeshPoint(const uint8_t xpos, const uint8_t ypos) { return Z_VALUES(xpos,ypos); }
void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zoff) {
+5 -2
View File
@@ -61,6 +61,10 @@ namespace ExtUI {
constexpr uint8_t hotendCount = HOTENDS;
constexpr uint8_t fanCount = FAN_COUNT;
#if HAS_MESH
typedef float (&bed_mesh_t)[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
#endif
bool isMoving();
bool isAxisPositionKnown(const axis_t);
bool isPositionKnown(); // Axis position guaranteed, steppers active since homing
@@ -122,9 +126,8 @@ namespace ExtUI {
#if HAS_LEVELING
bool getLevelingActive();
void setLevelingActive(const bool);
bool getMeshValid();
#if HAS_MESH
#include "../../feature/bedlevel/bedlevel.h"
bool getMeshValid();
bed_mesh_t getMeshArray();
float getMeshPoint(const uint8_t xpos, const uint8_t ypos);
void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zval);
+15 -14
View File
@@ -84,7 +84,7 @@
#define MSG_SWITCH_PS_ON _UxGT("Netzteil ein")
#define MSG_SWITCH_PS_OFF _UxGT("Netzteil aus")
#define MSG_EXTRUDE _UxGT("Extrudieren")
#define MSG_RETRACT _UxGT("Rückzug")
#define MSG_RETRACT _UxGT("Einzug")
#define MSG_MOVE_AXIS _UxGT("Achse Bewegen")
#define MSG_BED_LEVELING _UxGT("Bett-Nivellierung")
#define MSG_LEVEL_BED _UxGT("Bett nivellieren")
@@ -162,14 +162,14 @@
#define MSG_MESH_LOADED _UxGT("Netz %i geladen")
#define MSG_MESH_SAVED _UxGT("Netz %i gespeichert")
#define MSG_NO_STORAGE _UxGT("Kein Speicher")
#define MSG_UBL_SAVE_ERROR _UxGT("ERR:UBL speichern")
#define MSG_UBL_RESTORE_ERROR _UxGT("ERR:UBL wiederherst.")
#define MSG_UBL_SAVE_ERROR _UxGT("Err:UBL speichern")
#define MSG_UBL_RESTORE_ERROR _UxGT("Err:UBL wiederherst.")
#define MSG_UBL_Z_OFFSET_STOPPED _UxGT("Z-Versatz angehalten")
#define MSG_UBL_STEP_BY_STEP_MENU _UxGT("Schrittweises UBL")
#define MSG_LED_CONTROL _UxGT("LED-Steuerung")
#define MSG_LED_CONTROL _UxGT("Licht-Steuerung")
#define MSG_LEDS _UxGT("Licht")
#define MSG_LED_PRESETS _UxGT("Licht-Einstellungen")
#define MSG_LED_PRESETS _UxGT("Licht-Einstellung")
#define MSG_SET_LEDS_RED _UxGT("Rot")
#define MSG_SET_LEDS_ORANGE _UxGT("Orange")
#define MSG_SET_LEDS_YELLOW _UxGT("Gelb")
@@ -235,7 +235,7 @@
#define MSG_VTRAV_MIN _UxGT("V min Leerfahrt")
#define MSG_ACCELERATION _UxGT("Beschleunigung")
#define MSG_AMAX _UxGT("A max ") // space intentional
#define MSG_A_RETRACT _UxGT("A Rückzug")
#define MSG_A_RETRACT _UxGT("A Einzug")
#define MSG_A_TRAVEL _UxGT("A Leerfahrt")
#define MSG_STEPS_PER_MM _UxGT("Steps/mm")
#if IS_KINEMATIC
@@ -295,20 +295,20 @@
#define MSG_NO_MOVE _UxGT("Motoren angeschaltet")
#define MSG_KILLED _UxGT("ABGEBROCHEN")
#define MSG_STOPPED _UxGT("ANGEHALTEN")
#define MSG_CONTROL_RETRACT _UxGT("Rückzug mm")
#define MSG_CONTROL_RETRACT_SWAP _UxGT("Wechs. Rückzug mm")
#define MSG_CONTROL_RETRACTF _UxGT("Rückzug V")
#define MSG_CONTROL_RETRACT _UxGT("Einzug mm")
#define MSG_CONTROL_RETRACT_SWAP _UxGT("Wechs. Einzug mm")
#define MSG_CONTROL_RETRACTF _UxGT("Einzug V")
#define MSG_CONTROL_RETRACT_ZHOP _UxGT("Z-Sprung mm")
#define MSG_CONTROL_RETRACT_RECOVER _UxGT("UnRet mm")
#define MSG_CONTROL_RETRACT_RECOVER_SWAP _UxGT("Wechs. UnRet mm")
#define MSG_CONTROL_RETRACT_RECOVERF _UxGT("UnRet V")
#define MSG_CONTROL_RETRACT_RECOVER_SWAPF _UxGT("S UnRet V")
#define MSG_AUTORETRACT _UxGT("Autom. Rückzug")
#define MSG_FILAMENT_SWAP_LENGTH _UxGT("Rückzugslänge")
#define MSG_AUTORETRACT _UxGT("Autom. Einzug")
#define MSG_FILAMENT_SWAP_LENGTH _UxGT("Einzugslänge")
#define MSG_TOOL_CHANGE _UxGT("Werkzeugwechsel")
#define MSG_TOOL_CHANGE_ZLIFT _UxGT("Z anheben")
#define MSG_SINGLENOZZLE_PRIME_SPD _UxGT("Prime-Geschwin.")
#define MSG_SINGLENOZZLE_RETRACT_SPD _UxGT("Rückzug-Geschwin.")
#define MSG_SINGLENOZZLE_RETRACT_SPD _UxGT("Einzug-Geschwin.")
#define MSG_NOZZLE_STANDBY _UxGT("Düsen-Standby")
#define MSG_FILAMENTCHANGE _UxGT("Filament wechseln")
#define MSG_FILAMENTLOAD _UxGT("Filament laden")
@@ -326,6 +326,7 @@
#define MSG_BLTOUCH_SW_MODE _UxGT("BLTouch SW-Modus")
#define MSG_BLTOUCH_5V_MODE _UxGT("BLTouch 5V-Modus")
#define MSG_BLTOUCH_OD_MODE _UxGT("BLTouch OD Mode")
#define MSG_BLTOUCH_MODE_STORE _UxGT("BLTouch Mode Store")
#define MSG_BLTOUCH_STOW _UxGT("BLTouch einfahren")
#define MSG_MANUAL_DEPLOY _UxGT("Z-Sonde ausfahren")
#define MSG_MANUAL_STOW _UxGT("Z-Sonde einfahren")
@@ -348,8 +349,8 @@
#define MSG_ERR_MINTEMP LCD_STR_THERMOMETER _UxGT(" UNTERSCHRITTEN")
#define MSG_ERR_MAXTEMP_BED _UxGT("BETT ") LCD_STR_THERMOMETER _UxGT(" ÜBERSCHRITTEN")
#define MSG_ERR_MINTEMP_BED _UxGT("BETT ") LCD_STR_THERMOMETER _UxGT(" UNTERSCHRITTEN")
#define MSG_ERR_MAXTEMP_CHAMBER _UxGT("Err: GEHÄUSE MAX TEM")
#define MSG_ERR_MINTEMP_CHAMBER _UxGT("Err: GEHÄUSE MIN TEM")
#define MSG_ERR_MAXTEMP_CHAMBER _UxGT("Err:Gehäuse max Temp")
#define MSG_ERR_MINTEMP_CHAMBER _UxGT("Err:Gehäuse min Temp")
#define MSG_ERR_Z_HOMING MSG_HOME _UxGT(" ") MSG_X MSG_Y _UxGT(" ") MSG_FIRST
#define MSG_HALTED _UxGT("DRUCKER STOPP")
#define MSG_PLEASE_RESET _UxGT("Bitte neustarten")
+36 -15
View File
@@ -247,6 +247,12 @@
#ifndef MSG_UBL_LEVEL_BED
#define MSG_UBL_LEVEL_BED _UxGT("Unified Bed Leveling")
#endif
#ifndef MSG_LCD_PROBING_MESH
#define MSG_LCD_PROBING_MESH _UxGT("Probing point")
#endif
#ifndef MSG_LCD_TILTING_MESH
#define MSG_LCD_TILTING_MESH _UxGT("Tilting point")
#endif
#ifndef MSG_IDEX_MENU
#define MSG_IDEX_MENU _UxGT("IDEX Mode")
#endif
@@ -895,25 +901,40 @@
#define MSG_BLTOUCH _UxGT("BLTouch")
#endif
#ifndef MSG_BLTOUCH_SELFTEST
#define MSG_BLTOUCH_SELFTEST _UxGT("BLTouch Self-Test")
#define MSG_BLTOUCH_SELFTEST _UxGT("Cmd: Self-Test")
#endif
#ifndef MSG_BLTOUCH_RESET
#define MSG_BLTOUCH_RESET _UxGT("Reset BLTouch")
#endif
#ifndef MSG_BLTOUCH_DEPLOY
#define MSG_BLTOUCH_DEPLOY _UxGT("Deploy BLTouch")
#endif
#ifndef MSG_BLTOUCH_SW_MODE
#define MSG_BLTOUCH_SW_MODE _UxGT("BLTouch SW Mode")
#endif
#ifndef MSG_BLTOUCH_5V_MODE
#define MSG_BLTOUCH_5V_MODE _UxGT("BLTouch 5V Mode")
#endif
#ifndef MSG_BLTOUCH_OD_MODE
#define MSG_BLTOUCH_OD_MODE _UxGT("BLTouch OD Mode")
#define MSG_BLTOUCH_RESET _UxGT("Cmd: Reset")
#endif
#ifndef MSG_BLTOUCH_STOW
#define MSG_BLTOUCH_STOW _UxGT("Stow BLTouch")
#define MSG_BLTOUCH_STOW _UxGT("Cmd: Stow")
#endif
#ifndef MSG_BLTOUCH_DEPLOY
#define MSG_BLTOUCH_DEPLOY _UxGT("Cmd: Deploy")
#endif
#ifndef MSG_BLTOUCH_SW_MODE
#define MSG_BLTOUCH_SW_MODE _UxGT("Cmd: SW-Mode")
#endif
#ifndef MSG_BLTOUCH_5V_MODE
#define MSG_BLTOUCH_5V_MODE _UxGT("Cmd: 5V-Mode")
#endif
#ifndef MSG_BLTOUCH_OD_MODE
#define MSG_BLTOUCH_OD_MODE _UxGT("Cmd: OD-Mode")
#endif
#ifndef MSG_BLTOUCH_MODE_STORE
#define MSG_BLTOUCH_MODE_STORE _UxGT("Cmd: Mode-Store")
#endif
#ifndef MSG_BLTOUCH_MODE_STORE_5V
#define MSG_BLTOUCH_MODE_STORE_5V _UxGT("Set BLTouch to 5V")
#endif
#ifndef MSG_BLTOUCH_MODE_STORE_OD
#define MSG_BLTOUCH_MODE_STORE_OD _UxGT("Set BLTouch to OD")
#endif
#ifndef MSG_BLTOUCH_MODE_ECHO
#define MSG_BLTOUCH_MODE_ECHO _UxGT("Report Drain")
#endif
#ifndef MSG_BLTOUCH_MODE_CHANGE
#define MSG_BLTOUCH_MODE_CHANGE _UxGT(" ***WARNING*** Wrong Setting May Damage Machine! Proceed Anyway?")
#endif
#ifndef MSG_MANUAL_DEPLOY
#define MSG_MANUAL_DEPLOY _UxGT("Deploy Z-Probe")
+3
View File
@@ -97,6 +97,8 @@
#define MSG_UBL_UNHOMED _UxGT("Home XYZ prima")
#define MSG_UBL_TOOLS _UxGT("Strumenti UBL")
#define MSG_UBL_LEVEL_BED _UxGT("Unified Bed Leveling")
#define MSG_LCD_PROBING_MESH _UxGT("Punto sondato")
#define MSG_LCD_TILTING_MESH _UxGT("Punto inclinaz.")
#define MSG_IDEX_MENU _UxGT("Modo IDEX")
#define MSG_OFFSETS_MENU _UxGT("Strumenti Offsets")
#define MSG_IDEX_MODE_AUTOPARK _UxGT("Auto-Park")
@@ -324,6 +326,7 @@
#define MSG_BLTOUCH_SW_MODE _UxGT("BLTouch modo SW")
#define MSG_BLTOUCH_5V_MODE _UxGT("BLTouch modo 5V")
#define MSG_BLTOUCH_OD_MODE _UxGT("BLTouch modo OD")
#define MSG_BLTOUCH_MODE_STORE _UxGT("BLTouch modo mem.")
#define MSG_BLTOUCH_STOW _UxGT("Ritrai BLTouch")
#define MSG_MANUAL_DEPLOY _UxGT("Estendi Sonda-Z")
#define MSG_MANUAL_STOW _UxGT("Ritrai Sonda-Z")
+2 -2
View File
@@ -53,7 +53,7 @@ DECLARE_MENU_EDIT_TYPE(uint8_t, uint8, ui8tostr3, 1 ); // 123
DECLARE_MENU_EDIT_TYPE(uint16_t, uint16_3, ui16tostr3, 1 ); // 123, -12 right-justified
DECLARE_MENU_EDIT_TYPE(uint16_t, uint16_4, ui16tostr4, 0.1 ); // 1234, -123 right-justified
DECLARE_MENU_EDIT_TYPE(float, float3, ftostr3, 1 ); // 123 right-justified
DECLARE_MENU_EDIT_TYPE(float, float52, ftostr52, 100 ); // 123.45, -23.45
DECLARE_MENU_EDIT_TYPE(float, float52, ftostr42_52, 100 ); // _2.34, 12.34, -2.34 or 123.45, -23.45
DECLARE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000 ); // 1.234
DECLARE_MENU_EDIT_TYPE(float, float5, ftostr5rj, 0.01f ); // 12345 right-justified
DECLARE_MENU_EDIT_TYPE(float, float5_25, ftostr5rj, 0.04f ); // 12345 right-justified (25 increment)
@@ -123,7 +123,7 @@ DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint8); // 123 right-justif
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint16_3); // 123, -12 right-justified
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint16_4); // 1234, -123 right-justified
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float3); // 123 right-justified
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float52); // 123.45, -23.45
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float52); // _2.34, 12.34, -2.34 or 123.45, -23.45
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float43); // 1.234
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float5); // 12345 right-justified
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float5_25); // 12345 right-justified (25 increment)
+11 -28
View File
@@ -39,11 +39,6 @@
#include "../../module/probe.h"
#endif
#if ENABLED(BLTOUCH)
#include "../../module/endstops.h"
#include "../../feature/bltouch.h"
#endif
#if ENABLED(PIDTEMP)
#include "../../module/temperature.h"
#endif
@@ -62,7 +57,7 @@ void menu_backlash();
void menu_dac() {
dac_driver_getValues();
START_MENU();
MENU_BACK(MSG_CONTROL);
MENU_BACK(MSG_ADVANCED_SETTINGS);
#define EDIT_DAC_PERCENT(N) MENU_ITEM_EDIT_CALLBACK(uint8, MSG_##N " " MSG_DAC_PERCENT, &driverPercent[_AXIS(N)], 0, 100, dac_driver_commit)
EDIT_DAC_PERCENT(X);
EDIT_DAC_PERCENT(Y);
@@ -80,7 +75,7 @@ void menu_backlash();
void menu_pwm() {
START_MENU();
MENU_BACK(MSG_CONTROL);
MENU_BACK(MSG_ADVANCED_SETTINGS);
#define EDIT_CURRENT_PWM(LABEL,I) MENU_ITEM_EDIT_CALLBACK(long5, LABEL, &stepper.motor_current_setting[I], 100, 2000, stepper.refresh_motor_power)
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
EDIT_CURRENT_PWM(MSG_X MSG_Y, 0);
@@ -107,18 +102,7 @@ void menu_backlash();
#endif
#if ENABLED(SD_FIRMWARE_UPDATE)
#include "../../module/configuration_store.h"
//
// Toggle the SD Firmware Update state in EEPROM
//
static void _lcd_toggle_sd_update() {
const bool new_state = !settings.sd_update_status();
ui.completion_feedback(settings.set_sd_update_status(new_state));
ui.return_to_status();
if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
}
#endif
#if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
@@ -694,18 +678,17 @@ void menu_advanced_settings() {
MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &planner.abort_on_endstop_hit);
#endif
//
// BLTouch Self-Test and Reset
//
#if ENABLED(BLTOUCH)
MENU_ITEM(gcode, MSG_BLTOUCH_SELFTEST, PSTR("M280 P" STRINGIFY(Z_PROBE_SERVO_NR) " S" STRINGIFY(BLTOUCH_SELFTEST)));
if (!endstops.z_probe_enabled && bltouch.triggered())
MENU_ITEM(gcode, MSG_BLTOUCH_RESET, PSTR("M280 P" STRINGIFY(Z_PROBE_SERVO_NR) " S" STRINGIFY(BLTOUCH_RESET)));
#endif
#if ENABLED(SD_FIRMWARE_UPDATE)
bool sd_update_state = settings.sd_update_status();
MENU_ITEM_EDIT_CALLBACK(bool, MSG_SD_UPDATE, &sd_update_state, _lcd_toggle_sd_update);
MENU_ITEM_EDIT_CALLBACK(bool, MSG_SD_UPDATE, &sd_update_state, []{
//
// Toggle the SD Firmware Update state in EEPROM
//
const bool new_state = !settings.sd_update_status();
ui.completion_feedback(settings.set_sd_update_status(new_state));
ui.return_to_status();
if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
});
#endif
#if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS)
+49 -16
View File
@@ -90,7 +90,7 @@ static void lcd_factory_settings() {
void menu_debug() {
START_MENU();
MENU_BACK(MSG_MAIN);
MENU_BACK(MSG_CONFIGURATION);
#if ENABLED(LCD_PROGRESS_BAR_TEST)
MENU_ITEM(submenu, MSG_PROGRESS_BAR_TEST, _progress_bar_test);
@@ -107,7 +107,7 @@ static void lcd_factory_settings() {
void menu_tool_change() {
START_MENU();
MENU_BACK(MSG_MAIN);
MENU_BACK(MSG_CONFIGURATION);
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
MENU_ITEM_EDIT(float3, MSG_FILAMENT_SWAP_LENGTH, &toolchange_settings.swap_length, 0, 200);
MENU_MULTIPLIER_ITEM_EDIT(int4, MSG_SINGLENOZZLE_RETRACT_SPD, &toolchange_settings.retract_speed, 10, 5400);
@@ -123,16 +123,17 @@ static void lcd_factory_settings() {
#include "../../module/motion.h"
#include "../../gcode/queue.h"
void _recalc_offsets() {
if (active_extruder && all_axes_known()) { // For the 2nd extruder re-home so the next tool-change gets the new offsets.
enqueue_and_echo_commands_P(PSTR("G28")); // In future, we can babystep the 2nd extruder (if active), making homing unnecessary.
active_extruder = 0;
}
}
void menu_tool_offsets() {
auto _recalc_offsets = []{
if (active_extruder && all_axes_known()) { // For the 2nd extruder re-home so the next tool-change gets the new offsets.
enqueue_and_echo_commands_P(PSTR("G28")); // In future, we can babystep the 2nd extruder (if active), making homing unnecessary.
active_extruder = 0;
}
};
START_MENU();
MENU_BACK(MSG_MAIN);
MENU_BACK(MSG_CONFIGURATION);
#if ENABLED(DUAL_X_CARRIAGE)
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float52, MSG_X_OFFSET, &hotend_offset[X_AXIS][1], MIN(X2_HOME_POS, X2_MAX_POS) - 25.0, MAX(X2_HOME_POS, X2_MAX_POS) + 25.0, _recalc_offsets);
#else
@@ -151,7 +152,7 @@ static void lcd_factory_settings() {
void menu_idex() {
START_MENU();
MENU_BACK(MSG_MAIN);
MENU_BACK(MSG_CONFIGURATION);
MENU_ITEM(gcode, MSG_IDEX_MODE_AUTOPARK, PSTR("M605 S1\nG28 X\nG1 X100"));
const bool need_g28 = !(TEST(axis_known_position, Y_AXIS) && TEST(axis_known_position, Z_AXIS));
@@ -171,16 +172,48 @@ static void lcd_factory_settings() {
#if ENABLED(BLTOUCH)
#if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU)
void bltouch_report() {
SERIAL_ECHOLNPAIR("EEPROM Last BLTouch Mode - ", (int)bltouch.last_written_mode);
SERIAL_ECHOLNPGM("Configuration BLTouch Mode - "
#if ENABLED(BLTOUCH_SET_5V_MODE)
"5V"
#else
"OD"
#endif
);
char mess[21];
strcpy_P(mess, PSTR("BLTouch Mode - "));
sprintf_P(&mess[15], bltouch.last_written_mode ? PSTR("5V") : PSTR("OD"));
ui.set_status(mess);
ui.return_to_status();
}
#endif
void menu_bltouch() {
START_MENU();
MENU_BACK(MSG_MAIN);
MENU_BACK(MSG_CONFIGURATION);
MENU_ITEM(function, MSG_BLTOUCH_RESET, bltouch._reset);
MENU_ITEM(function, MSG_BLTOUCH_SELFTEST, bltouch._selftest);
MENU_ITEM(function, MSG_BLTOUCH_DEPLOY, bltouch._deploy);
MENU_ITEM(function, MSG_BLTOUCH_STOW, bltouch._stow);
MENU_ITEM(function, MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode);
MENU_ITEM(function, MSG_BLTOUCH_5V_MODE, bltouch._set_5V_mode);
MENU_ITEM(function, MSG_BLTOUCH_OD_MODE, bltouch._set_OD_mode);
#if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU)
MENU_ITEM(submenu, MSG_BLTOUCH_5V_MODE, []{
do_select_screen(PSTR(MSG_BLTOUCH_5V_MODE), PSTR(MSG_BUTTON_CANCEL), bltouch._set_5V_mode, ui.goto_previous_screen, PSTR(MSG_BLTOUCH_MODE_CHANGE));
});
MENU_ITEM(submenu, MSG_BLTOUCH_OD_MODE, []{
do_select_screen(PSTR(MSG_BLTOUCH_OD_MODE), PSTR(MSG_BUTTON_CANCEL), bltouch._set_OD_mode, ui.goto_previous_screen, PSTR(MSG_BLTOUCH_MODE_CHANGE));
});
MENU_ITEM(function, MSG_BLTOUCH_MODE_STORE, bltouch._mode_store);
MENU_ITEM(submenu, MSG_BLTOUCH_MODE_STORE_5V, []{
do_select_screen(PSTR(MSG_BLTOUCH_MODE_STORE_5V), PSTR(MSG_BUTTON_CANCEL), bltouch.mode_conv_5V, ui.goto_previous_screen, PSTR(MSG_BLTOUCH_MODE_CHANGE));
});
MENU_ITEM(submenu, MSG_BLTOUCH_MODE_STORE_OD, []{
do_select_screen(PSTR(MSG_BLTOUCH_MODE_STORE_OD), PSTR(MSG_BUTTON_CANCEL), bltouch.mode_conv_OD, ui.goto_previous_screen, PSTR(MSG_BLTOUCH_MODE_CHANGE));
});
MENU_ITEM(function, MSG_BLTOUCH_MODE_ECHO, bltouch_report);
#endif
END_MENU();
}
@@ -192,7 +225,7 @@ static void lcd_factory_settings() {
void menu_case_light() {
START_MENU();
MENU_BACK(MSG_MAIN);
MENU_BACK(MSG_CONFIGURATION);
MENU_ITEM_EDIT_CALLBACK(uint8, MSG_CASE_LIGHT_BRIGHTNESS, &case_light_brightness, 0, 255, update_case_light, true);
MENU_ITEM_EDIT_CALLBACK(bool, MSG_CASE_LIGHT, (bool*)&case_light_on, update_case_light);
END_MENU();
@@ -206,7 +239,7 @@ static void lcd_factory_settings() {
void menu_config_retract() {
START_MENU();
MENU_BACK(MSG_CONTROL);
MENU_BACK(MSG_CONFIGURATION);
#if ENABLED(FWRETRACT_AUTORETRACT)
MENU_ITEM_EDIT_CALLBACK(bool, MSG_AUTORETRACT, &fwretract.autoretract_enabled, fwretract.refresh_autoretract);
#endif
+2 -2
View File
@@ -372,8 +372,8 @@ void _lcd_pause_message(PGM_P const msg1, PGM_P const msg2=nullptr, PGM_P const
STATIC_ITEM_P(pause_header(), true, true);
STATIC_ITEM_P(msg1);
if (msg2) STATIC_ITEM_P(msg2);
if (msg3) STATIC_ITEM_P(msg3);
if ((!!msg2) + (!!msg3) + 2 < LCD_HEIGHT - 1) STATIC_ITEM(" ");
if (msg3 && (LCD_HEIGHT) >= 5) STATIC_ITEM_P(msg3);
if ((!!msg2) + (!!msg3) + 2 < (LCD_HEIGHT) - 1) STATIC_ITEM(" ");
HOTEND_STATUS_ITEM();
END_SCREEN();
}
+3 -2
View File
@@ -53,6 +53,8 @@
#if MACHINE_CAN_PAUSE
void lcd_pause_job() {
ui.synchronize(PSTR(MSG_PAUSE_PRINT));
#if ENABLED(POWER_LOSS_RECOVERY)
if (recovery.enabled) recovery.save(true, false);
#endif
@@ -69,7 +71,6 @@
#elif defined(ACTION_ON_PAUSE)
host_action_pause();
#endif
planner.synchronize();
}
void lcd_resume() {
@@ -264,7 +265,6 @@ void menu_main() {
if (card_detected) {
if (!card_open) {
MENU_ITEM(submenu, MSG_CARD_MENU, menu_sdcard);
MENU_ITEM(gcode,
#if PIN_EXISTS(SD_DETECT)
MSG_CHANGE_SDCARD, PSTR("M21")
@@ -272,6 +272,7 @@ void menu_main() {
MSG_RELEASE_SDCARD, PSTR("M22")
#endif
);
MENU_ITEM(submenu, MSG_CARD_MENU, menu_sdcard);
}
}
else {
+14 -14
View File
@@ -414,18 +414,12 @@ void menu_temperature() {
#endif
#endif // FAN_COUNT > 0
#if ENABLED(SPINDLE_LASER_ENABLE)
MENU_ITEM(submenu, MSG_LASER_MENU, menu_spindle_laser);
#endif
#if HAS_TEMP_HOTEND
//
// Cooldown
//
bool has_heat = false;
HOTEND_LOOP() if (thermalManager.temp_hotend[HOTEND_INDEX].target) { has_heat = true; break; }
#if HAS_TEMP_BED
if (thermalManager.temp_bed.target) has_heat = true;
#endif
if (has_heat) MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
//
// Preheat for Material 1 and 2
//
@@ -437,11 +431,17 @@ void menu_temperature() {
MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
#endif
#endif // HAS_TEMP_HOTEND
//
// Cooldown
//
bool has_heat = false;
HOTEND_LOOP() if (thermalManager.temp_hotend[HOTEND_INDEX].target) { has_heat = true; break; }
#if HAS_TEMP_BED
if (thermalManager.temp_bed.target) has_heat = true;
#endif
if (has_heat) MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
#if ENABLED(SPINDLE_LASER_ENABLE)
MENU_ITEM(submenu, MSG_LASER_MENU, menu_spindle_laser);
#endif
#endif // HAS_TEMP_HOTEND
END_MENU();
}
+13 -13
View File
@@ -124,43 +124,43 @@ void menu_tmc_current() {
#define TMC_EDIT_STORED_HYBRID_THRS(ST, MSG) MENU_ITEM_EDIT_CALLBACK(uint8, MSG, &stepper##ST.stored.hybrid_thrs, 0, 255, refresh_hybrid_thrs_##ST);
#if AXIS_HAS_STEALTHCHOP(X)
void refresh_hybrid_thrs_X() { stepperX.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[X_AXIS]); }
void refresh_hybrid_thrs_X() { stepperX.refresh_hybrid_thrs(); }
#endif
#if AXIS_HAS_STEALTHCHOP(Y)
void refresh_hybrid_thrs_Y() { stepperY.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[Y_AXIS]); }
void refresh_hybrid_thrs_Y() { stepperY.refresh_hybrid_thrs(); }
#endif
#if AXIS_HAS_STEALTHCHOP(Z)
void refresh_hybrid_thrs_Z() { stepperZ.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[Z_AXIS]); }
void refresh_hybrid_thrs_Z() { stepperZ.refresh_hybrid_thrs(); }
#endif
#if AXIS_HAS_STEALTHCHOP(X2)
void refresh_hybrid_thrs_X2() { stepperX2.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[X_AXIS]); }
void refresh_hybrid_thrs_X2() { stepperX2.refresh_hybrid_thrs(); }
#endif
#if AXIS_HAS_STEALTHCHOP(Y2)
void refresh_hybrid_thrs_Y2() { stepperY2.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[Y_AXIS]); }
void refresh_hybrid_thrs_Y2() { stepperY2.refresh_hybrid_thrs(); }
#endif
#if AXIS_HAS_STEALTHCHOP(Z2)
void refresh_hybrid_thrs_Z2() { stepperZ2.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[Z_AXIS]); }
void refresh_hybrid_thrs_Z2() { stepperZ2.refresh_hybrid_thrs(); }
#endif
#if AXIS_HAS_STEALTHCHOP(Z3)
void refresh_hybrid_thrs_Z3() { stepperZ3.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[Z_AXIS]); }
void refresh_hybrid_thrs_Z3() { stepperZ3.refresh_hybrid_thrs(); }
#endif
#if AXIS_HAS_STEALTHCHOP(E0)
void refresh_hybrid_thrs_E0() { stepperE0.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[E_AXIS]); }
void refresh_hybrid_thrs_E0() { stepperE0.refresh_hybrid_thrs(); }
#endif
#if AXIS_HAS_STEALTHCHOP(E1)
void refresh_hybrid_thrs_E1() { stepperE1.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[E_AXIS_N(1)]); }
void refresh_hybrid_thrs_E1() { stepperE1.refresh_hybrid_thrs(); }
#endif
#if AXIS_HAS_STEALTHCHOP(E2)
void refresh_hybrid_thrs_E2() { stepperE2.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[E_AXIS_N(2)]); }
void refresh_hybrid_thrs_E2() { stepperE2.refresh_hybrid_thrs(); }
#endif
#if AXIS_HAS_STEALTHCHOP(E3)
void refresh_hybrid_thrs_E3() { stepperE3.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[E_AXIS_N(3)]); }
void refresh_hybrid_thrs_E3() { stepperE3.refresh_hybrid_thrs(); }
#endif
#if AXIS_HAS_STEALTHCHOP(E4)
void refresh_hybrid_thrs_E4() { stepperE4.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[E_AXIS_N(4)]); }
void refresh_hybrid_thrs_E4() { stepperE4.refresh_hybrid_thrs(); }
#endif
#if AXIS_HAS_STEALTHCHOP(E5)
void refresh_hybrid_thrs_E5() { stepperE5.refresh_hybrid_thrs(planner.settings.axis_steps_per_mm[E_AXIS_N(5)]); }
void refresh_hybrid_thrs_E5() { stepperE5.refresh_hybrid_thrs(); }
#endif
void menu_tmc_hybrid_thrs() {
+2
View File
@@ -116,5 +116,7 @@
#define THERMISTOR_NAME "Dummy 1"
#elif THERMISTOR_ID == 999
#define THERMISTOR_NAME "Dummy 2"
#elif THERMISTOR_ID == 1000
#define THERMISTOR_NAME "Custom"
#endif // THERMISTOR_ID
+2 -6
View File
@@ -293,10 +293,6 @@ void MarlinUI::init() {
#if HAS_ENCODER_ACTION
encoderDiff = 0;
#endif
#if HAS_TRINAMIC && HAS_LCD_MENU
init_tmc_section();
#endif
}
bool MarlinUI::get_blink() {
@@ -1000,8 +996,8 @@ void MarlinUI::update() {
uint8_t get_ADC_keyValue(void) {
if (thermalManager.ADCKey_count >= 16) {
const uint16_t currentkpADCValue = thermalManager.current_ADCKey_raw >> 2;
thermalManager.current_ADCKey_raw = 0;
const uint16_t currentkpADCValue = thermalManager.current_ADCKey_raw << 2;
thermalManager.current_ADCKey_raw = 1024;
thermalManager.ADCKey_count = 0;
if (currentkpADCValue < 4000)
for (uint8_t i = 0; i < ADC_KEY_NUM; i++) {
+100 -54
View File
@@ -37,7 +37,7 @@
*/
// Change EEPROM version if the structure changes
#define EEPROM_VERSION "V66"
#define EEPROM_VERSION "V67"
#define EEPROM_OFFSET 100
// Check the integrity of data offsets.
@@ -109,10 +109,13 @@ extern float saved_extruder_advance_K[EXTRUDERS];
void M217_report(const bool eeprom);
#endif
#if ENABLED(BLTOUCH)
#include "../feature/bltouch.h"
#endif
#if HAS_TRINAMIC
#include "stepper_indirection.h"
#include "../feature/tmc_util.h"
#define TMC_GET_PWMTHRS(A,Q) _tmc_thrs(stepper##Q.microsteps(), stepper##Q.TPWMTHRS(), planner.settings.axis_steps_per_mm[_AXIS(A)])
#endif
#pragma pack(push, 1) // No padding between variables
@@ -207,6 +210,11 @@ typedef struct SettingsDataStruct {
//
uint16_t servo_angles[EEPROM_NUM_SERVOS][2]; // M281 P L U
//
// BLTOUCH
//
bool bltouch_last_written_mode;
//
// DELTA / [XYZ]_DUAL_ENDSTOPS
//
@@ -701,6 +709,19 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(servo_angles);
}
//
// BLTOUCH
//
{
_FIELD_TEST(bltouch_last_written_mode);
#if ENABLED(BLTOUCH)
const bool &bltouch_last_written_mode = bltouch.last_written_mode;
#else
constexpr bool bltouch_last_written_mode = false;
#endif
EEPROM_WRITE(bltouch_last_written_mode);
}
//
// DELTA Geometry or Dual Endstops offsets
//
@@ -962,49 +983,49 @@ void MarlinSettings::postprocess() {
#if ENABLED(HYBRID_THRESHOLD)
tmc_hybrid_threshold_t tmc_hybrid_threshold = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
#if AXIS_HAS_STEALTHCHOP(X)
tmc_hybrid_threshold.X = TMC_GET_PWMTHRS(X, X);
tmc_hybrid_threshold.X = stepperX.get_pwm_thrs();
#endif
#if AXIS_HAS_STEALTHCHOP(Y)
tmc_hybrid_threshold.Y = TMC_GET_PWMTHRS(Y, Y);
tmc_hybrid_threshold.Y = stepperY.get_pwm_thrs();
#endif
#if AXIS_HAS_STEALTHCHOP(Z)
tmc_hybrid_threshold.Z = TMC_GET_PWMTHRS(Z, Z);
tmc_hybrid_threshold.Z = stepperZ.get_pwm_thrs();
#endif
#if AXIS_HAS_STEALTHCHOP(X2)
tmc_hybrid_threshold.X2 = TMC_GET_PWMTHRS(X, X2);
tmc_hybrid_threshold.X2 = stepperX2.get_pwm_thrs();
#endif
#if AXIS_HAS_STEALTHCHOP(Y2)
tmc_hybrid_threshold.Y2 = TMC_GET_PWMTHRS(Y, Y2);
tmc_hybrid_threshold.Y2 = stepperY2.get_pwm_thrs();
#endif
#if AXIS_HAS_STEALTHCHOP(Z2)
tmc_hybrid_threshold.Z2 = TMC_GET_PWMTHRS(Z, Z2);
tmc_hybrid_threshold.Z2 = stepperZ2.get_pwm_thrs();
#endif
#if AXIS_HAS_STEALTHCHOP(Z3)
tmc_hybrid_threshold.Z3 = TMC_GET_PWMTHRS(Z, Z3);
tmc_hybrid_threshold.Z3 = stepperZ3.get_pwm_thrs();
#endif
#if MAX_EXTRUDERS
#if AXIS_HAS_STEALTHCHOP(E0)
tmc_hybrid_threshold.E0 = TMC_GET_PWMTHRS(E, E0);
tmc_hybrid_threshold.E0 = stepperE0.get_pwm_thrs();
#endif
#if MAX_EXTRUDERS > 1
#if AXIS_HAS_STEALTHCHOP(E1)
tmc_hybrid_threshold.E1 = TMC_GET_PWMTHRS(E, E1);
tmc_hybrid_threshold.E1 = stepperE1.get_pwm_thrs();
#endif
#if MAX_EXTRUDERS > 2
#if AXIS_HAS_STEALTHCHOP(E2)
tmc_hybrid_threshold.E2 = TMC_GET_PWMTHRS(E, E2);
tmc_hybrid_threshold.E2 = stepperE2.get_pwm_thrs();
#endif
#if MAX_EXTRUDERS > 3
#if AXIS_HAS_STEALTHCHOP(E3)
tmc_hybrid_threshold.E3 = TMC_GET_PWMTHRS(E, E3);
tmc_hybrid_threshold.E3 = stepperE3.get_pwm_thrs();
#endif
#if MAX_EXTRUDERS > 4
#if AXIS_HAS_STEALTHCHOP(E4)
tmc_hybrid_threshold.E4 = TMC_GET_PWMTHRS(E, E4);
tmc_hybrid_threshold.E4 = stepperE4.get_pwm_thrs();
#endif
#if MAX_EXTRUDERS > 5
#if AXIS_HAS_STEALTHCHOP(E5)
tmc_hybrid_threshold.E5 = TMC_GET_PWMTHRS(E, E5);
tmc_hybrid_threshold.E5 = stepperE5.get_pwm_thrs();
#endif
#endif // MAX_EXTRUDERS > 5
#endif // MAX_EXTRUDERS > 4
@@ -1177,17 +1198,20 @@ void MarlinSettings::postprocess() {
// Backlash Compensation
//
{
#if ENABLED(BACKLASH_COMPENSATION)
const float (&backlash_distance_mm)[XYZ] = backlash.distance_mm;
const uint8_t &backlash_correction = backlash.correction;
#ifdef BACKLASH_DISTANCE_MM
const float (&backlash_distance_mm)[XYZ] = backlash.distance_mm;
#else
const float backlash_distance_mm[XYZ] = { 0 };
const uint8_t backlash_correction = 0;
const float backlash_distance_mm[XYZ] = { 0 };
#endif
#if ENABLED(BACKLASH_COMPENSATION)
const uint8_t &backlash_correction = backlash.correction;
#else
const uint8_t backlash_correction = 0;
#endif
#ifdef BACKLASH_SMOOTHING_MM
const float &backlash_smoothing_mm = backlash.smoothing_mm;
const float &backlash_smoothing_mm = backlash.smoothing_mm;
#else
const float backlash_smoothing_mm = 3;
const float backlash_smoothing_mm = 3;
#endif
_FIELD_TEST(backlash_distance_mm);
EEPROM_WRITE(backlash_distance_mm[X_AXIS]);
@@ -1486,6 +1510,19 @@ void MarlinSettings::postprocess() {
EEPROM_READ(servo_angles_arr);
}
//
// BLTOUCH
//
{
_FIELD_TEST(bltouch_last_written_mode);
#if ENABLED(BLTOUCH)
bool &bltouch_last_written_mode = bltouch.last_written_mode;
#else
bool bltouch_last_written_mode;
#endif
EEPROM_READ(bltouch_last_written_mode);
}
//
// DELTA Geometry or Dual Endstops offsets
//
@@ -1739,46 +1776,45 @@ void MarlinSettings::postprocess() {
EEPROM_READ(tmc_hybrid_threshold);
#if ENABLED(HYBRID_THRESHOLD)
#define TMC_SET_PWMTHRS(A,Q) tmc_set_pwmthrs(stepper##Q, tmc_hybrid_threshold.Q, planner.settings.axis_steps_per_mm[_AXIS(A)])
if (!validating) {
#if AXIS_HAS_STEALTHCHOP(X)
TMC_SET_PWMTHRS(X, X);
stepperX.set_pwm_thrs(tmc_hybrid_threshold.X);
#endif
#if AXIS_HAS_STEALTHCHOP(Y)
TMC_SET_PWMTHRS(Y, Y);
stepperY.set_pwm_thrs(tmc_hybrid_threshold.Y);
#endif
#if AXIS_HAS_STEALTHCHOP(Z)
TMC_SET_PWMTHRS(Z, Z);
stepperZ.set_pwm_thrs(tmc_hybrid_threshold.Z);
#endif
#if AXIS_HAS_STEALTHCHOP(X2)
TMC_SET_PWMTHRS(X, X2);
stepperX2.set_pwm_thrs(tmc_hybrid_threshold.X2);
#endif
#if AXIS_HAS_STEALTHCHOP(Y2)
TMC_SET_PWMTHRS(Y, Y2);
stepperY2.set_pwm_thrs(tmc_hybrid_threshold.Y2);
#endif
#if AXIS_HAS_STEALTHCHOP(Z2)
TMC_SET_PWMTHRS(Z, Z2);
stepperZ2.set_pwm_thrs(tmc_hybrid_threshold.Z2);
#endif
#if AXIS_HAS_STEALTHCHOP(Z3)
TMC_SET_PWMTHRS(Z, Z3);
stepperZ3.set_pwm_thrs(tmc_hybrid_threshold.Z3);
#endif
#if AXIS_HAS_STEALTHCHOP(E0)
TMC_SET_PWMTHRS(E, E0);
stepperE0.set_pwm_thrs(tmc_hybrid_threshold.E0);
#endif
#if AXIS_HAS_STEALTHCHOP(E1)
TMC_SET_PWMTHRS(E, E1);
stepperE1.set_pwm_thrs(tmc_hybrid_threshold.E1);
#endif
#if AXIS_HAS_STEALTHCHOP(E2)
TMC_SET_PWMTHRS(E, E2);
stepperE2.set_pwm_thrs(tmc_hybrid_threshold.E2);
#endif
#if AXIS_HAS_STEALTHCHOP(E3)
TMC_SET_PWMTHRS(E, E3);
stepperE3.set_pwm_thrs(tmc_hybrid_threshold.E3);
#endif
#if AXIS_HAS_STEALTHCHOP(E4)
TMC_SET_PWMTHRS(E, E4);
stepperE4.set_pwm_thrs(tmc_hybrid_threshold.E4);
#endif
#if AXIS_HAS_STEALTHCHOP(E5)
TMC_SET_PWMTHRS(E, E5);
stepperE5.set_pwm_thrs(tmc_hybrid_threshold.E5);
#endif
}
#endif
@@ -1962,17 +1998,20 @@ void MarlinSettings::postprocess() {
// Backlash Compensation
//
{
#if ENABLED(BACKLASH_COMPENSATION)
float (&backlash_distance_mm)[XYZ] = backlash.distance_mm;
uint8_t &backlash_correction = backlash.correction;
#ifdef BACKLASH_DISTANCE_MM
float (&backlash_distance_mm)[XYZ] = backlash.distance_mm;
#else
float backlash_distance_mm[XYZ];
#endif
#if ENABLED(BACKLASH_COMPENSATION)
uint8_t &backlash_correction = backlash.correction;
#else
float backlash_distance_mm[XYZ];
uint8_t backlash_correction;
#endif
#ifdef BACKLASH_SMOOTHING_MM
float &backlash_smoothing_mm = backlash.smoothing_mm;
#else
float backlash_smoothing_mm;
float backlash_smoothing_mm;
#endif
_FIELD_TEST(backlash_distance_mm);
EEPROM_READ(backlash_distance_mm[X_AXIS]);
@@ -2309,6 +2348,13 @@ void MarlinSettings::reset() {
COPY(servo_angles, base_servo_angles);
#endif
//
// BLTOUCH
//
//#if ENABLED(BLTOUCH)
// bltouch.last_written_mode;
//#endif
//
// Endstop Adjustments
//
@@ -3143,13 +3189,13 @@ void MarlinSettings::reset() {
say_M913();
#endif
#if AXIS_HAS_STEALTHCHOP(X)
SERIAL_ECHOPAIR(" X", TMC_GET_PWMTHRS(X, X));
SERIAL_ECHOPAIR(" X", stepperX.get_pwm_thrs());
#endif
#if AXIS_HAS_STEALTHCHOP(Y)
SERIAL_ECHOPAIR(" Y", TMC_GET_PWMTHRS(Y, Y));
SERIAL_ECHOPAIR(" Y", stepperY.get_pwm_thrs());
#endif
#if AXIS_HAS_STEALTHCHOP(Z)
SERIAL_ECHOPAIR(" Z", TMC_GET_PWMTHRS(Z, Z));
SERIAL_ECHOPAIR(" Z", stepperZ.get_pwm_thrs());
#endif
#if AXIS_HAS_STEALTHCHOP(X) || AXIS_HAS_STEALTHCHOP(Y) || AXIS_HAS_STEALTHCHOP(Z)
SERIAL_EOL();
@@ -3160,13 +3206,13 @@ void MarlinSettings::reset() {
SERIAL_ECHOPGM(" I1");
#endif
#if AXIS_HAS_STEALTHCHOP(X2)
SERIAL_ECHOPAIR(" X", TMC_GET_PWMTHRS(X, X2));
SERIAL_ECHOPAIR(" X", stepperX2.get_pwm_thrs());
#endif
#if AXIS_HAS_STEALTHCHOP(Y2)
SERIAL_ECHOPAIR(" Y", TMC_GET_PWMTHRS(Y, Y2));
SERIAL_ECHOPAIR(" Y", stepperY2.get_pwm_thrs());
#endif
#if AXIS_HAS_STEALTHCHOP(Z2)
SERIAL_ECHOPAIR(" Z", TMC_GET_PWMTHRS(Z, Z2));
SERIAL_ECHOPAIR(" Z", stepperZ2.get_pwm_thrs());
#endif
#if AXIS_HAS_STEALTHCHOP(X2) || AXIS_HAS_STEALTHCHOP(Y2) || AXIS_HAS_STEALTHCHOP(Z2)
SERIAL_EOL();
@@ -3174,32 +3220,32 @@ void MarlinSettings::reset() {
#if AXIS_HAS_STEALTHCHOP(Z3)
say_M913();
SERIAL_ECHOLNPAIR(" I2 Z", TMC_GET_PWMTHRS(Z, Z3));
SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.get_pwm_thrs());
#endif
#if AXIS_HAS_STEALTHCHOP(E0)
say_M913();
SERIAL_ECHOLNPAIR(" T0 E", TMC_GET_PWMTHRS(E, E0));
SERIAL_ECHOLNPAIR(" T0 E", stepperE0.get_pwm_thrs());
#endif
#if AXIS_HAS_STEALTHCHOP(E1)
say_M913();
SERIAL_ECHOLNPAIR(" T1 E", TMC_GET_PWMTHRS(E, E1));
SERIAL_ECHOLNPAIR(" T1 E", stepperE1.get_pwm_thrs());
#endif
#if AXIS_HAS_STEALTHCHOP(E2)
say_M913();
SERIAL_ECHOLNPAIR(" T2 E", TMC_GET_PWMTHRS(E, E2));
SERIAL_ECHOLNPAIR(" T2 E", stepperE2.get_pwm_thrs());
#endif
#if AXIS_HAS_STEALTHCHOP(E3)
say_M913();
SERIAL_ECHOLNPAIR(" T3 E", TMC_GET_PWMTHRS(E, E3));
SERIAL_ECHOLNPAIR(" T3 E", stepperE3.get_pwm_thrs());
#endif
#if AXIS_HAS_STEALTHCHOP(E4)
say_M913();
SERIAL_ECHOLNPAIR(" T4 E", TMC_GET_PWMTHRS(E, E4));
SERIAL_ECHOLNPAIR(" T4 E", stepperE4.get_pwm_thrs());
#endif
#if AXIS_HAS_STEALTHCHOP(E5)
say_M913();
SERIAL_ECHOLNPAIR(" T5 E", TMC_GET_PWMTHRS(E, E5));
SERIAL_ECHOLNPAIR(" T5 E", stepperE5.get_pwm_thrs());
#endif
SERIAL_EOL();
#endif // HYBRID_THRESHOLD
+1 -2
View File
@@ -465,8 +465,7 @@ void _O2 Endstops::M119() {
#endif
#endif
#if ENABLED(BLTOUCH)
bltouch._reset();
if (enabled_globally) bltouch._stow();
bltouch._reset_SW_mode();
#endif
} // Endstops::M119

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