Bump to head
This commit is contained in:
+85
-28
@@ -27,9 +27,6 @@
|
||||
//#define E_SpreadCycle
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enable if you install a KEENOVO AC BED with Solid State Relay
|
||||
*/
|
||||
@@ -870,7 +867,7 @@
|
||||
//
|
||||
#define JUNCTION_DEVIATION
|
||||
#if ENABLED(JUNCTION_DEVIATION)
|
||||
#define JUNCTION_DEVIATION_MM 0.02 // (mm) Distance from real junction edge
|
||||
#define JUNCTION_DEVIATION_MM 0.08 // (mm) Distance from real junction edge
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -903,7 +900,7 @@
|
||||
*
|
||||
* See https://github.com/synthetos/TinyG/wiki/Jerk-Controlled-Motion-Explained
|
||||
*/
|
||||
#define S_CURVE_ACCELERATION
|
||||
//#define S_CURVE_ACCELERATION
|
||||
|
||||
//===========================================================================
|
||||
//============================= Z Probe Options =============================
|
||||
@@ -971,15 +968,71 @@
|
||||
*/
|
||||
#define BLTOUCH
|
||||
#if ENABLED(BLTOUCH)
|
||||
//#define BLTOUCH_DELAY 500 // Minimum Command delay (ms). Enable and increase if needed
|
||||
/**
|
||||
* 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
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Settings for BLTOUCH Classic 1.2, 1.3 or BLTouch Smart 1.0, 2.0, 2.2, 3.0, 3.1, and most clones:
|
||||
*/
|
||||
//#define BLTOUCH_FORCE_5V_MODE
|
||||
#endif
|
||||
|
||||
// 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
|
||||
|
||||
// A probe that is deployed and stowed with a solenoid pin (SOL1_PIN)
|
||||
//#define SOLENOID_PROBE
|
||||
@@ -1000,23 +1053,23 @@
|
||||
//
|
||||
|
||||
/**
|
||||
* Z Probe to nozzle (X,Y) offset, relative to (0, 0).
|
||||
* X and Y offsets must be integers.
|
||||
* Z Probe to nozzle (X,Y) offset, relative to (0, 0).
|
||||
* X and Y offsets must be integers.
|
||||
*
|
||||
* In the following example the X and Y offsets are both positive:
|
||||
* #define X_PROBE_OFFSET_FROM_EXTRUDER 10
|
||||
* #define Y_PROBE_OFFSET_FROM_EXTRUDER 10
|
||||
* In the following example the X and Y offsets are both positive:
|
||||
* #define X_PROBE_OFFSET_FROM_EXTRUDER 10
|
||||
* #define Y_PROBE_OFFSET_FROM_EXTRUDER 10
|
||||
*
|
||||
* +-- BACK ---+
|
||||
* | |
|
||||
* L | (+) P | R <-- probe (20,20)
|
||||
* E | | I
|
||||
* F | (-) N (+) | G <-- nozzle (10,10)
|
||||
* T | | H
|
||||
* | (-) | T
|
||||
* | |
|
||||
* O-- FRONT --+
|
||||
* (0,0)
|
||||
* +-- BACK ---+
|
||||
* | |
|
||||
* L | (+) P | R <-- probe (20,20)
|
||||
* E | | I
|
||||
* F | (-) N (+) | G <-- nozzle (10,10)
|
||||
* T | | H
|
||||
* | (-) | T
|
||||
* | |
|
||||
* O-- FRONT --+
|
||||
* (0,0)
|
||||
*/
|
||||
#define X_PROBE_OFFSET_FROM_EXTRUDER -22 // X offset: -left +right [of the nozzle]
|
||||
#define Y_PROBE_OFFSET_FROM_EXTRUDER 0 // Y offset: -front +behind [the nozzle]
|
||||
@@ -1565,7 +1618,7 @@
|
||||
//
|
||||
// M100 Free Memory Watcher
|
||||
//
|
||||
//#define M100_FREE_MEMORY_WATCHER // Add M100 (Free Memory Watcher) to debug memory usage
|
||||
#define M100_FREE_MEMORY_WATCHER // Add M100 (Free Memory Watcher) to debug memory usage
|
||||
|
||||
//
|
||||
// G20/G21 Inch mode support
|
||||
@@ -1701,7 +1754,7 @@
|
||||
*
|
||||
* View the current statistics with M78.
|
||||
*/
|
||||
#define PRINTCOUNTER
|
||||
//#define PRINTCOUNTER
|
||||
|
||||
//=============================================================================
|
||||
//============================= LCD and SD support ============================
|
||||
@@ -2265,6 +2318,10 @@
|
||||
#define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once.
|
||||
#define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255)
|
||||
//#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup
|
||||
|
||||
// Use a single Neopixel LED for static (background) lighting
|
||||
//#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use
|
||||
//#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -316,7 +316,7 @@
|
||||
* If left undefined this defaults to F = F_CPU/(2*255*1)
|
||||
* ie F = 31.4 Khz on 16 MHz microcontrollers or F = 39.2 KHz on 20 MHz microcontrollers
|
||||
* These defaults are the same as with the old FAST_PWM_FAN implementation - no migration is required
|
||||
* NOTE: Setting very low frequencies (< 10 Hz) may result in unexpected timer behaviour.
|
||||
* NOTE: Setting very low frequencies (< 10 Hz) may result in unexpected timer behavior.
|
||||
*
|
||||
* USE_OCR2A_AS_TOP [undefined by default]
|
||||
* Boards that use TIMER2 for PWM have limitations resulting in only a few possible frequencies on TIMER2:
|
||||
@@ -386,10 +386,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
//============================ Mechanical Settings ==========================
|
||||
//===========================================================================
|
||||
|
||||
// @section homing
|
||||
|
||||
// If you want endstops to stay on (by default) even when not homing
|
||||
@@ -749,6 +745,7 @@
|
||||
* A (A shifted) B (B shifted) IC
|
||||
* Smoothie 0x2C (0x58) 0x2D (0x5A) MCP4451
|
||||
* AZTEEG_X3_PRO 0x2C (0x58) 0x2E (0x5C) MCP4451
|
||||
* AZTEEG_X5_MINI 0x2C (0x58) 0x2E (0x5C) MCP4451
|
||||
* AZTEEG_X5_MINI_WIFI 0x58 0x5C MCP4451
|
||||
* MIGHTYBOARD_REVE 0x2F (0x5E) MCP4018
|
||||
*/
|
||||
@@ -1046,6 +1043,7 @@
|
||||
#define STATUS_HOTEND_INVERTED // Show solid nozzle bitmaps when heating (Requires STATUS_HOTEND_ANIM)
|
||||
#define STATUS_HOTEND_ANIM // Use a second bitmap to indicate hotend heating
|
||||
#define STATUS_BED_ANIM // Use a second bitmap to indicate bed heating
|
||||
#define STATUS_CHAMBER_ANIM // Use a second bitmap to indicate chamber heating
|
||||
//#define STATUS_ALT_BED_BITMAP // Use the alternative bed bitmap
|
||||
//#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap
|
||||
//#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames
|
||||
@@ -1235,7 +1233,8 @@
|
||||
/**
|
||||
* Minimum stepper driver pulse width (in µs)
|
||||
* 0 : Smallest possible width the MCU can produce, compatible with TMC2xxx drivers
|
||||
* 1 : Minimum for A4988, A5984, and LV8729 stepper drivers
|
||||
* 0 : Minimum 500ns for LV8729, adjusted in stepper.h
|
||||
* 1 : Minimum for A4988 and A5984 stepper drivers
|
||||
* 2 : Minimum for DRV8825 stepper drivers
|
||||
* 3 : Minimum for TB6600 stepper drivers
|
||||
* 30 : Minimum for TB6560 stepper drivers
|
||||
@@ -1250,8 +1249,8 @@
|
||||
* 500000 : Maximum for A4988 stepper driver
|
||||
* 400000 : Maximum for TMC2xxx stepper drivers
|
||||
* 250000 : Maximum for DRV8825 stepper driver
|
||||
* 200000 : Maximum for LV8729 stepper driver
|
||||
* 150000 : Maximum for TB6600 stepper driver
|
||||
* 130000 : Maximum for LV8729 stepper driver
|
||||
* 15000 : Maximum for TB6560 stepper driver
|
||||
*
|
||||
* Override the default value based on the driver type set in Configuration.h.
|
||||
@@ -2298,7 +2297,7 @@
|
||||
|
||||
//#define I2CPE_ERR_THRESH_ABORT 100.0 // Threshold size for error (in mm) error on any given
|
||||
// axis after which the printer will abort. Comment out to
|
||||
// disable abort behaviour.
|
||||
// disable abort behavior.
|
||||
|
||||
#define I2CPE_TIME_TRUSTED 10000 // After an encoder fault, there must be no further fault
|
||||
// for this amount of time (in ms) before the encoder
|
||||
@@ -2358,7 +2357,7 @@
|
||||
//#define NANODLP_Z_SYNC
|
||||
#if ENABLED(NANODLP_Z_SYNC)
|
||||
//#define NANODLP_ALL_AXIS // Enables "Z_move_comp" output on any axis move.
|
||||
// Default behaviour is limited to Z axis only.
|
||||
// Default behavior is limited to Z axis only.
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -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__
|
||||
|
||||
|
||||
@@ -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
@@ -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__
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
|
||||
#define NUM_HARDWARE_TIMERS 9
|
||||
|
||||
#define PRESCALER 2
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
@@ -87,5 +87,21 @@
|
||||
#define HANDLER_FOR_TIMER5 TC0_Handler
|
||||
#endif
|
||||
|
||||
//typedef enum { _timer1, _timer2, _timer3, _timer4, _timer5, _Nbr_16timers } timer16_Sequence_t;
|
||||
typedef enum { _timer3, _timer5, _Nbr_16timers } timer16_Sequence_t;
|
||||
typedef enum : unsigned char {
|
||||
#ifdef _useTimer1
|
||||
_timer1,
|
||||
#endif
|
||||
#ifdef _useTimer2
|
||||
_timer2,
|
||||
#endif
|
||||
#ifdef _useTimer3
|
||||
_timer3,
|
||||
#endif
|
||||
#ifdef _useTimer4
|
||||
_timer4,
|
||||
#endif
|
||||
#ifdef _useTimer5
|
||||
_timer5,
|
||||
#endif
|
||||
_Nbr_16timers
|
||||
} timer16_Sequence_t;
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -26,19 +26,22 @@
|
||||
*
|
||||
* Available chip select pins for HW SPI are 4 10 52 77
|
||||
*/
|
||||
#if (SDSS == 4) || (SDSS == 10) || (SDSS == 52) || (SDSS == 77)
|
||||
#if (SDSS == 4)
|
||||
#if SDSS == 4 || SDSS == 10 || SDSS == 52 || SDSS == 77 || SDSS == 87
|
||||
#if SDSS == 4
|
||||
#define SPI_PIN 87
|
||||
#define SPI_CHAN 1
|
||||
#elif (SDSS == 10)
|
||||
#elif SDSS == 10
|
||||
#define SPI_PIN 77
|
||||
#define SPI_CHAN 0
|
||||
#elif (SDSS == 52)
|
||||
#elif SDSS == 52
|
||||
#define SPI_PIN 86
|
||||
#define SPI_CHAN 2
|
||||
#else
|
||||
#elif SDSS == 77
|
||||
#define SPI_PIN 77
|
||||
#define SPI_CHAN 0
|
||||
#else
|
||||
#define SPI_PIN 87
|
||||
#define SPI_CHAN 1
|
||||
#endif
|
||||
#define SCK_PIN 76
|
||||
#define MISO_PIN 74
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -67,9 +67,9 @@ UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = {
|
||||
.bLength = sizeof(usb_dev_desc_t),
|
||||
.bDescriptorType = USB_DT_DEVICE,
|
||||
.bcdUSB = LE16(USB_V2_0),
|
||||
.bDeviceClass = 0,
|
||||
.bDeviceSubClass = 0,
|
||||
.bDeviceProtocol = 0,
|
||||
.bDeviceClass = CDC_CLASS_MULTI,
|
||||
.bDeviceSubClass = CDC_SUBCLASS_ACM,
|
||||
.bDeviceProtocol = CDC_PROTOCOL_V25TER,
|
||||
.bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
|
||||
.idVendor = LE16(USB_DEVICE_VENDOR_ID),
|
||||
.idProduct = LE16(USB_DEVICE_PRODUCT_ID),
|
||||
@@ -101,9 +101,9 @@ UDC_DESC_STORAGE usb_dev_qual_desc_t udc_device_qual = {
|
||||
.bLength = sizeof(usb_dev_qual_desc_t),
|
||||
.bDescriptorType = USB_DT_DEVICE_QUALIFIER,
|
||||
.bcdUSB = LE16(USB_V2_0),
|
||||
.bDeviceClass = 0,
|
||||
.bDeviceSubClass = 0,
|
||||
.bDeviceProtocol = 0,
|
||||
.bDeviceClass = CDC_CLASS_MULTI,
|
||||
.bDeviceSubClass = CDC_SUBCLASS_ACM,
|
||||
.bDeviceProtocol = CDC_PROTOCOL_V25TER,
|
||||
.bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
|
||||
.bNumConfigurations = 1
|
||||
};
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
#define CDC_CLASS_DEVICE 0x02 //!< USB Communication Device Class
|
||||
#define CDC_CLASS_COMM 0x02 //!< CDC Communication Class Interface
|
||||
#define CDC_CLASS_DATA 0x0A //!< CDC Data Class Interface
|
||||
#define CDC_CLASS_MULTI 0xEF //!< CDC Multi-interface Function
|
||||
|
||||
//@}
|
||||
|
||||
//! \name USB CDC Subclass IDs
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#if ENABLED(WEBSUPPORT)
|
||||
|
||||
#include "SPIFFS.h"
|
||||
#include <SPIFFS.h>
|
||||
#include "wifi.h"
|
||||
|
||||
AsyncEventSource events("/events"); // event source (Server-Sent events)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -49,7 +49,7 @@ void Heater::update() {
|
||||
last = now;
|
||||
heat += (heater_state - heat) * (delta / 1000000000.0);
|
||||
|
||||
if (heat < room_temp_raw) heat = room_temp_raw;
|
||||
NOLESS(heat, room_temp_raw);
|
||||
Gpio::pin_map[analogInputToDigitalPin(adc_pin)].value = 0xFFFF - (uint16_t)heat;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
+2
-2
@@ -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
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
@@ -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 @@
|
||||
#error "Debug pins is not yet supported for STM32!"
|
||||
#error "PINS_DEBUGGING is not yet supported for STM32!"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) && PIN_EXISTS(FSMC_CS) // FSMC on 100/144 pins SoCs
|
||||
|
||||
#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);
|
||||
|
||||
@@ -267,4 +272,4 @@ uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) {
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
|
||||
#endif // ARDUINO_ARCH_STM32F1 && (STM32_HIGH_DENSITY || STM32_XL_DENSITY)
|
||||
#endif // ARDUINO_ARCH_STM32F1 && FSMC_CS_PIN
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 @@
|
||||
#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!"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -1058,7 +1058,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if ENABLED(BLTOUCH)
|
||||
bltouch.init();
|
||||
bltouch.init(/*set_voltage=*/true);
|
||||
#endif
|
||||
|
||||
#if ENABLED(I2C_POSITION_ENCODERS)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -58,7 +58,7 @@ void mcp4728_init() {
|
||||
* Write input resister value to specified channel using fastwrite method.
|
||||
* Channel : 0-3, Values : 0-4095
|
||||
*/
|
||||
uint8_t mcp4728_analogWrite(uint8_t channel, uint16_t value) {
|
||||
uint8_t mcp4728_analogWrite(const uint8_t channel, const uint16_t value) {
|
||||
mcp4728_values[channel] = value;
|
||||
return mcp4728_fastWrite();
|
||||
}
|
||||
@@ -81,7 +81,7 @@ uint8_t mcp4728_eepromWrite() {
|
||||
/**
|
||||
* Write Voltage reference setting to all input regiters
|
||||
*/
|
||||
uint8_t mcp4728_setVref_all(uint8_t value) {
|
||||
uint8_t mcp4728_setVref_all(const uint8_t value) {
|
||||
Wire.beginTransmission(I2C_ADDRESS(DAC_DEV_ADDRESS));
|
||||
Wire.write(VREFWRITE | (value ? 0x0F : 0x00));
|
||||
return Wire.endTransmission();
|
||||
@@ -89,7 +89,7 @@ uint8_t mcp4728_setVref_all(uint8_t value) {
|
||||
/**
|
||||
* Write Gain setting to all input regiters
|
||||
*/
|
||||
uint8_t mcp4728_setGain_all(uint8_t value) {
|
||||
uint8_t mcp4728_setGain_all(const uint8_t value) {
|
||||
Wire.beginTransmission(I2C_ADDRESS(DAC_DEV_ADDRESS));
|
||||
Wire.write(GAINWRITE | (value ? 0x0F : 0x00));
|
||||
return Wire.endTransmission();
|
||||
@@ -98,25 +98,24 @@ uint8_t mcp4728_setGain_all(uint8_t value) {
|
||||
/**
|
||||
* Return Input Register value
|
||||
*/
|
||||
uint16_t mcp4728_getValue(uint8_t channel) { return mcp4728_values[channel]; }
|
||||
uint16_t mcp4728_getValue(const uint8_t channel) { return mcp4728_values[channel]; }
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Steph: Might be useful in the future
|
||||
* Return Vout
|
||||
*/
|
||||
uint16_t mcp4728_getVout(uint8_t channel) {
|
||||
uint32_t vref = 2048,
|
||||
vOut = (vref * mcp4728_values[channel] * (_DAC_STEPPER_GAIN + 1)) / 4096;
|
||||
if (vOut > defaultVDD) vOut = defaultVDD;
|
||||
return vOut;
|
||||
uint16_t mcp4728_getVout(const uint8_t channel) {
|
||||
const uint32_t vref = 2048,
|
||||
vOut = (vref * mcp4728_values[channel] * (_DAC_STEPPER_GAIN + 1)) / 4096;
|
||||
return MIN(vOut, defaultVDD);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns DAC values as a 0-100 percentage of drive strength
|
||||
*/
|
||||
uint8_t mcp4728_getDrvPct(uint8_t channel) { return uint8_t(100.0 * mcp4728_values[channel] / (DAC_STEPPER_MAX) + 0.5); }
|
||||
uint8_t mcp4728_getDrvPct(const uint8_t channel) { return uint8_t(100.0 * mcp4728_values[channel] / (DAC_STEPPER_MAX) + 0.5); }
|
||||
|
||||
/**
|
||||
* Receives all Drive strengths as 0-100 percent values, updates
|
||||
@@ -144,7 +143,7 @@ uint8_t mcp4728_fastWrite() {
|
||||
/**
|
||||
* Common function for simple general commands
|
||||
*/
|
||||
uint8_t mcp4728_simpleCommand(byte simpleCommand) {
|
||||
uint8_t mcp4728_simpleCommand(const byte simpleCommand) {
|
||||
Wire.beginTransmission(I2C_ADDRESS(GENERALCALL));
|
||||
Wire.write(simpleCommand);
|
||||
return Wire.endTransmission();
|
||||
|
||||
@@ -46,12 +46,12 @@
|
||||
#define DAC_DEV_ADDRESS (BASE_ADDR | DAC_OR_ADDRESS)
|
||||
|
||||
void mcp4728_init();
|
||||
uint8_t mcp4728_analogWrite(uint8_t channel, uint16_t value);
|
||||
uint8_t mcp4728_analogWrite(const uint8_t channel, const uint16_t value);
|
||||
uint8_t mcp4728_eepromWrite();
|
||||
uint8_t mcp4728_setVref_all(uint8_t value);
|
||||
uint8_t mcp4728_setGain_all(uint8_t value);
|
||||
uint16_t mcp4728_getValue(uint8_t channel);
|
||||
uint8_t mcp4728_setVref_all(const uint8_t value);
|
||||
uint8_t mcp4728_setGain_all(const uint8_t value);
|
||||
uint16_t mcp4728_getValue(const uint8_t channel);
|
||||
uint8_t mcp4728_fastWrite();
|
||||
uint8_t mcp4728_simpleCommand(byte simpleCommand);
|
||||
uint8_t mcp4728_getDrvPct(uint8_t channel);
|
||||
uint8_t mcp4728_simpleCommand(const byte simpleCommand);
|
||||
uint8_t mcp4728_getDrvPct(const uint8_t channel);
|
||||
void mcp4728_setDrvPct(uint8_t pct[XYZE]);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -681,7 +681,8 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
|
||||
// Resume the print job timer if it was running
|
||||
if (print_job_timer.isPaused()) print_job_timer.start();
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
#if HAS_DISPLAY
|
||||
ui.reset_status();
|
||||
ui.return_to_status();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -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: ");
|
||||
|
||||
@@ -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];
|
||||
|
||||
+53
-123
@@ -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;
|
||||
@@ -562,24 +565,16 @@
|
||||
case TMC_VSENSE: print_vsense(st); break;
|
||||
case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break;
|
||||
case TMC_TSTEP: {
|
||||
uint32_t tstep_value = st.TSTEP();
|
||||
if (tstep_value == 0xFFFFF) SERIAL_ECHOPGM("max");
|
||||
else SERIAL_ECHO(tstep_value);
|
||||
}
|
||||
break;
|
||||
case TMC_TPWMTHRS: {
|
||||
uint32_t tpwmthrs_val = st.TPWMTHRS();
|
||||
SERIAL_ECHO(tpwmthrs_val);
|
||||
}
|
||||
break;
|
||||
case TMC_TPWMTHRS_MMS: {
|
||||
uint32_t tpwmthrs_val = st.TPWMTHRS();
|
||||
if (tpwmthrs_val)
|
||||
SERIAL_ECHO(12650000UL * st.microsteps() / (256 * tpwmthrs_val * spmm));
|
||||
else
|
||||
SERIAL_CHAR('-');
|
||||
}
|
||||
break;
|
||||
const uint32_t tstep_value = st.TSTEP();
|
||||
if (tstep_value != 0xFFFFF) SERIAL_ECHO(tstep_value); else SERIAL_ECHOPGM("max");
|
||||
} break;
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
case TMC_TPWMTHRS: SERIAL_ECHO(uint32_t(st.TPWMTHRS())); break;
|
||||
case TMC_TPWMTHRS_MMS: {
|
||||
const uint32_t tpwmthrs_val = st.get_pwm_thrs();
|
||||
if (tpwmthrs_val) SERIAL_ECHO(tpwmthrs_val); else SERIAL_CHAR('-');
|
||||
} break;
|
||||
#endif
|
||||
case TMC_OTPW: serialprint_truefalse(st.otpw()); break;
|
||||
#if ENABLED(MONITOR_DRIVER_STATUS)
|
||||
case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break;
|
||||
@@ -588,13 +583,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 +644,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 +852,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 +1093,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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -55,6 +55,10 @@
|
||||
#include "../../../lcd/extensible_ui/ui_api.h"
|
||||
#endif
|
||||
|
||||
#if HOTENDS > 1
|
||||
#include "../../../module/tool_change.h"
|
||||
#endif
|
||||
|
||||
#if ABL_GRID
|
||||
#if ENABLED(PROBE_Y_FIRST)
|
||||
#define PR_OUTER_VAR xCount
|
||||
@@ -280,7 +284,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||
*/
|
||||
if (!g29_in_progress) {
|
||||
|
||||
#if ENABLED(DUAL_X_CARRIAGE)
|
||||
#if HOTENDS > 1
|
||||
if (active_extruder != 0) tool_change(0);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ void GcodeSuite::G29() {
|
||||
BUZZ(100, 659);
|
||||
BUZZ(100, 698);
|
||||
|
||||
gcode.home_all_axes();
|
||||
home_all_axes();
|
||||
set_bed_leveling_enabled(true);
|
||||
|
||||
#if ENABLED(MESH_G28_REST_ORIGIN)
|
||||
|
||||
@@ -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)
|
||||
@@ -264,13 +260,9 @@ void GcodeSuite::G28(const bool always_home_all) {
|
||||
|
||||
#else // NOT DELTA
|
||||
|
||||
const bool homeX = always_home_all || parser.seen('X'),
|
||||
homeY = always_home_all || parser.seen('Y'),
|
||||
homeZ = always_home_all || parser.seen('Z'),
|
||||
home_all = (!homeX && !homeY && !homeZ) || (homeX && homeY && homeZ),
|
||||
doX = home_all || homeX,
|
||||
doY = home_all || homeY,
|
||||
doZ = home_all || homeZ;
|
||||
const bool homeX = parser.seen('X'), homeY = parser.seen('Y'), homeZ = parser.seen('Z'),
|
||||
home_all = always_home_all || (homeX == homeY && homeX == homeZ),
|
||||
doX = home_all || homeX, doY = home_all || homeY, doZ = home_all || homeZ;
|
||||
|
||||
set_destination_from_current();
|
||||
|
||||
@@ -353,6 +345,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
|
||||
|
||||
@@ -74,7 +74,7 @@ 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.");
|
||||
SERIAL_ECHOLNPGM("Home XY first");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -142,6 +142,14 @@ void GcodeSuite::G34() {
|
||||
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) {
|
||||
|
||||
#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)
|
||||
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES + 7);
|
||||
#endif
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -229,15 +237,19 @@ 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
|
||||
|
||||
gcode.G28(false);
|
||||
|
||||
} while(0);
|
||||
|
||||
@@ -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
|
||||
|
||||
+132
-104
@@ -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,153 @@ 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
|
||||
SERIAL_ECHOPGM(". Pulse width");
|
||||
if (probe_counter == 15)
|
||||
SERIAL_ECHOLNPGM(": 30ms or more");
|
||||
else
|
||||
SERIAL_ECHOLNPAIR(" (+/- 4ms): ", probe_counter * 2);
|
||||
|
||||
if (probe_counter == 0) SERIAL_ECHOLNPGM("trigger not detected");
|
||||
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)");
|
||||
SERIAL_ECHOLNPGM(" detected.");
|
||||
}
|
||||
else SERIAL_ECHOLNPGM("FAIL: Noise detected - please re-run test");
|
||||
|
||||
} // measure active signal length
|
||||
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][1]); // Stow
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
if (!probe_counter) SERIAL_ECHOLNPGM("FAIL: No trigger detected");
|
||||
|
||||
#endif // HAS_Z_SERVO_PROBE
|
||||
|
||||
} // servo_probe_test
|
||||
|
||||
@@ -239,12 +274,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 +286,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 +311,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 +334,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 +346,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
DEBUG_ECHOPAIR("\nX2 Home X: ", x_home_pos(1), "\nX2_MIN_POS=", int(X2_MIN_POS), "\nX2_MAX_POS=", int(X2_MAX_POS));
|
||||
DEBUG_ECHOPAIR("\nX2_HOME_DIR=", int(X2_HOME_DIR), "\nX2_HOME_POS=", int(X2_HOME_POS));
|
||||
DEBUG_ECHOPAIR("\nDEFAULT_DUAL_X_CARRIAGE_MODE=", STRINGIFY(DEFAULT_DUAL_X_CARRIAGE_MODE));
|
||||
DEBUG_ECHOPAIR("\nTOOLCHANGE_ZRAISE=", float(TOOLCHANGE_ZRAISE));
|
||||
DEBUG_ECHOPAIR("\toolchange_settings.z_raise=", toolchange_settings.z_raise);
|
||||
DEBUG_ECHOPAIR("\nDEFAULT_DUPLICATION_X_OFFSET=", int(DEFAULT_DUPLICATION_X_OFFSET));
|
||||
DEBUG_EOL();
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -106,10 +106,10 @@ void GcodeSuite::M916() {
|
||||
|
||||
// turn the motor(s) both directions
|
||||
sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, final_feedrate);
|
||||
gcode.process_subcommands_now_P(gcode_string);
|
||||
process_subcommands_now_P(gcode_string);
|
||||
|
||||
sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_max, final_feedrate);
|
||||
gcode.process_subcommands_now_P(gcode_string);
|
||||
process_subcommands_now_P(gcode_string);
|
||||
|
||||
// get the status after the motors have stopped
|
||||
planner.synchronize();
|
||||
@@ -226,10 +226,10 @@ void GcodeSuite::M917() {
|
||||
DEBUG_ECHOLNPAIR(" OCD threshold : ", (ocd_th_val + 1) * 375);
|
||||
|
||||
sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, final_feedrate);
|
||||
gcode.process_subcommands_now_P(gcode_string);
|
||||
process_subcommands_now_P(gcode_string);
|
||||
|
||||
sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_max, final_feedrate);
|
||||
gcode.process_subcommands_now_P(gcode_string);
|
||||
process_subcommands_now_P(gcode_string);
|
||||
|
||||
planner.synchronize();
|
||||
|
||||
@@ -263,7 +263,7 @@ void GcodeSuite::M917() {
|
||||
L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
|
||||
}
|
||||
DEBUG_ECHOLNPGM(".");
|
||||
gcode.reset_stepper_timeout(); // reset_stepper_timeout to keep steppers powered
|
||||
reset_stepper_timeout(); // reset_stepper_timeout to keep steppers powered
|
||||
watchdog_reset(); // beat the dog
|
||||
safe_delay(5000);
|
||||
status_composite_temp = 0;
|
||||
@@ -518,10 +518,10 @@ void GcodeSuite::M918() {
|
||||
DEBUG_ECHOLNPAIR("...feedrate = ", current_feedrate);
|
||||
|
||||
sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, current_feedrate);
|
||||
gcode.process_subcommands_now_P(gcode_string);
|
||||
process_subcommands_now_P(gcode_string);
|
||||
|
||||
sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_max, current_feedrate);
|
||||
gcode.process_subcommands_now_P(gcode_string);
|
||||
process_subcommands_now_P(gcode_string);
|
||||
|
||||
planner.synchronize();
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ void GcodeSuite::M600() {
|
||||
|
||||
#if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
|
||||
// Don't allow filament change without homing first
|
||||
if (axis_unhomed_error()) gcode.home_all_axes();
|
||||
if (axis_unhomed_error()) home_all_axes();
|
||||
#endif
|
||||
|
||||
#if EXTRUDERS > 1
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
+23
-16
@@ -30,11 +30,11 @@
|
||||
* -----------------
|
||||
*
|
||||
* Helpful G-code references:
|
||||
* - http://linuxcnc.org/handbook/gcode/g-code.html
|
||||
* - http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
|
||||
* - http://marlinfw.org/meta/gcode
|
||||
* - https://reprap.org/wiki/G-code
|
||||
* - http://linuxcnc.org/docs/html/gcode.html
|
||||
*
|
||||
* Help to document Marlin's G-codes online:
|
||||
* - http://reprap.org/wiki/G-code
|
||||
* - https://github.com/MarlinFirmware/MarlinDocumentation
|
||||
*
|
||||
* -----------------
|
||||
@@ -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);
|
||||
|
||||
};
|
||||
|
||||
@@ -405,9 +405,6 @@
|
||||
#define E_MANUAL EXTRUDERS
|
||||
#elif ENABLED(PRUSA_MMU2)
|
||||
#define E_STEPPERS 1
|
||||
#ifndef TOOLCHANGE_ZRAISE
|
||||
#define TOOLCHANGE_ZRAISE 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// No inactive extruders with MK2_MULTIPLEXER or SWITCHING_NOZZLE
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -694,7 +694,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
|
||||
#endif
|
||||
|
||||
#ifndef TOOLCHANGE_ZRAISE
|
||||
#error "TOOLCHANGE_ZRAISE required for EXTRUDERS > 1. Please update your Configuration."
|
||||
#error "TOOLCHANGE_ZRAISE required for EXTRUDERS > 1. Please update your Configuration_adv.h."
|
||||
#endif
|
||||
|
||||
#elif ENABLED(MK2_MULTIPLEXER)
|
||||
@@ -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
|
||||
|
||||
@@ -1366,9 +1369,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
|
||||
#error "TEMP_SENSOR_4 1000 requires HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS and HOTEND4_BETA in Configuration_adv.h."
|
||||
#elif ENABLED(HEATER_5_USER_THERMISTOR) && !(defined(HOTEND5_PULLUP_RESISTOR_OHMS) && defined(HOTEND5_RESISTANCE_25C_OHMS) && defined(HOTEND5_BETA))
|
||||
#error "TEMP_SENSOR_5 1000 requires HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS and HOTEND5_BETA in Configuration_adv.h."
|
||||
#elif ENABLED(BED_USER_THERMISTOR) && !(defined(BED_PULLUP_RESISTOR_OHMS) && defined(BED_RESISTANCE_25C_OHMS) && defined(BED_BETA))
|
||||
#elif ENABLED(HEATER_BED_USER_THERMISTOR) && !(defined(BED_PULLUP_RESISTOR_OHMS) && defined(BED_RESISTANCE_25C_OHMS) && defined(BED_BETA))
|
||||
#error "TEMP_SENSOR_BED 1000 requires BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS and BED_BETA in Configuration_adv.h."
|
||||
#elif ENABLED(CHAMBER_USER_THERMISTOR) && !(defined(CHAMBER_PULLUP_RESISTOR_OHMS) && defined(CHAMBER_RESISTANCE_25C_OHMS) && defined(CHAMBER_BETA))
|
||||
#elif ENABLED(HEATER_CHAMBER_USER_THERMISTOR) && !(defined(CHAMBER_PULLUP_RESISTOR_OHMS) && defined(CHAMBER_RESISTANCE_25C_OHMS) && defined(CHAMBER_BETA))
|
||||
#error "TEMP_SENSOR_CHAMBER 1000 requires CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS and CHAMBER_BETA in Configuration_adv.h."
|
||||
#endif
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
/**
|
||||
* Marlin release version identifier
|
||||
*/
|
||||
#define SHORT_BUILD_VERSION "2.0.x_R14"
|
||||
#define SHORT_BUILD_VERSION "2.0.x_R15"
|
||||
|
||||
/**
|
||||
* Verbose version identifier which should contain a reference to the location
|
||||
@@ -51,7 +51,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-31"
|
||||
|
||||
/**
|
||||
* Required minimum Configuration.h and Configuration_adv.h file versions.
|
||||
|
||||
@@ -659,6 +659,63 @@
|
||||
|
||||
#endif // !STATUS_BED_WIDTH && !STATUS_COMBINE_HEATERS && HAS_HEATED_BED && HOTENDS < 4
|
||||
|
||||
#if HAS_HEATED_CHAMBER
|
||||
|
||||
#define STATUS_CHAMBER_WIDTH 16
|
||||
|
||||
#ifdef STATUS_CHAMBER_ANIM
|
||||
|
||||
const unsigned char status_chamber_bmp[] PROGMEM = {
|
||||
B11111111,B11111111,
|
||||
B10000000,B00000001,
|
||||
B10000000,B00000001,
|
||||
B10000000,B00000001,
|
||||
B10000000,B00000001,
|
||||
B10000000,B00000001,
|
||||
B10000000,B00000001,
|
||||
B10000000,B00000001,
|
||||
B10000000,B00000001,
|
||||
B10000000,B00000001,
|
||||
B11111111,B11111111,
|
||||
B11111111,B11111111
|
||||
};
|
||||
|
||||
const unsigned char status_chamber_on_bmp[] PROGMEM = {
|
||||
B11111111,B11111111,
|
||||
B10000000,B00000001,
|
||||
B10000100,B00100001,
|
||||
B10000010,B00010001,
|
||||
B10000010,B00010001,
|
||||
B10000100,B00100001,
|
||||
B10001000,B01000001,
|
||||
B10001000,B01000001,
|
||||
B10000100,B00100001,
|
||||
B10000000,B00000001,
|
||||
B11111111,B11111111,
|
||||
B11111111,B11111111
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
const unsigned char status_chamber_bmp[] PROGMEM = {
|
||||
B11111111,B11111111,
|
||||
B10000000,B00000001,
|
||||
B10000100,B00100001,
|
||||
B10000010,B00010001,
|
||||
B10000010,B00010001,
|
||||
B10000100,B00100001,
|
||||
B10001000,B01000001,
|
||||
B10001000,B01000001,
|
||||
B10000100,B00100001,
|
||||
B10000000,B00000001,
|
||||
B11111111,B11111111,
|
||||
B11111111,B11111111
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // HAS_HEATED_CHAMBER
|
||||
|
||||
// Can also be overridden in Configuration.h
|
||||
// If you can afford it, try the 3-frame fan animation!
|
||||
// Don't compile in the fan animation with no fan
|
||||
@@ -1302,6 +1359,50 @@
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Chamber Bitmap Properties
|
||||
//
|
||||
#ifndef STATUS_CHAMBER_WIDTH
|
||||
#define STATUS_CHAMBER_WIDTH 0
|
||||
#endif
|
||||
#ifndef STATUS_CHAMBER_BYTEWIDTH
|
||||
#define STATUS_CHAMBER_BYTEWIDTH BW(STATUS_CHAMBER_WIDTH)
|
||||
#endif
|
||||
#if STATUS_CHAMBER_WIDTH && !STATUS_HEATERS_WIDTH
|
||||
|
||||
#ifndef STATUS_CHAMBER_X
|
||||
#define STATUS_CHAMBER_X (128 - (STATUS_FAN_BYTEWIDTH + STATUS_CHAMBER_BYTEWIDTH) * 8)
|
||||
#endif
|
||||
|
||||
#ifndef STATUS_CHAMBER_HEIGHT
|
||||
#ifdef STATUS_CHAMBER_ANIM
|
||||
#define STATUS_CHAMBER_HEIGHT(S) ((S) ? sizeof(status_chamber_on_bmp) / (STATUS_CHAMBER_BYTEWIDTH) : sizeof(status_chamber_bmp) / (STATUS_CHAMBER_BYTEWIDTH))
|
||||
#else
|
||||
#define STATUS_CHAMBER_HEIGHT(S) (sizeof(status_chamber_bmp) / (STATUS_CHAMBER_BYTEWIDTH))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef STATUS_CHAMBER_Y
|
||||
#define STATUS_CHAMBER_Y(S) (20 - STATUS_CHAMBER_HEIGHT(S))
|
||||
#endif
|
||||
|
||||
#ifndef STATUS_CHAMBER_TEXT_X
|
||||
#define STATUS_CHAMBER_TEXT_X (STATUS_CHAMBER_X + 7)
|
||||
#endif
|
||||
|
||||
static_assert(
|
||||
sizeof(status_chamber_bmp) == (STATUS_CHAMBER_BYTEWIDTH) * (STATUS_CHAMBER_HEIGHT(0)),
|
||||
"Status chamber bitmap (status_chamber_bmp) dimensions don't match data."
|
||||
);
|
||||
#ifdef STATUS_CHAMBER_ANIM
|
||||
static_assert(
|
||||
sizeof(status_chamber_on_bmp) == (STATUS_CHAMBER_BYTEWIDTH) * (STATUS_CHAMBER_HEIGHT(1)),
|
||||
"Status chamber bitmap (status_chamber_on_bmp) dimensions don't match data."
|
||||
);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Bed Bitmap Properties
|
||||
//
|
||||
@@ -1314,7 +1415,7 @@
|
||||
#if STATUS_BED_WIDTH && !STATUS_HEATERS_WIDTH
|
||||
|
||||
#ifndef STATUS_BED_X
|
||||
#define STATUS_BED_X (128 - (STATUS_FAN_BYTEWIDTH + STATUS_BED_BYTEWIDTH) * 8)
|
||||
#define STATUS_BED_X (128 - (STATUS_CHAMBER_BYTEWIDTH + STATUS_FAN_BYTEWIDTH + STATUS_BED_BYTEWIDTH) * 8)
|
||||
#endif
|
||||
|
||||
#ifndef STATUS_BED_HEIGHT
|
||||
|
||||
@@ -74,6 +74,7 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
|
||||
#define DO_DRAW_FAN (HAS_FAN0 && STATUS_FAN_WIDTH && STATUS_FAN_FRAMES)
|
||||
#define ANIM_HOTEND (HOTENDS && ENABLED(STATUS_HOTEND_ANIM))
|
||||
#define ANIM_BED (DO_DRAW_BED && ENABLED(STATUS_BED_ANIM))
|
||||
#define ANIM_CHAMBER (HAS_HEATED_CHAMBER && ENABLED(STATUS_CHAMBER_ANIM))
|
||||
|
||||
#if ANIM_HOTEND || ANIM_BED
|
||||
uint8_t heat_bits;
|
||||
@@ -88,6 +89,11 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
|
||||
#else
|
||||
#define BED_ALT() false
|
||||
#endif
|
||||
#if ANIM_CHAMBER
|
||||
#define CHAMBER_ALT() TEST(heat_bits, 6)
|
||||
#else
|
||||
#define CHAMBER_ALT() false
|
||||
#endif
|
||||
|
||||
#define MAX_HOTEND_DRAW MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE)))
|
||||
#define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1)
|
||||
@@ -126,6 +132,27 @@ FORCE_INLINE void _draw_heater_status(const int8_t heater, const bool blink) {
|
||||
target = IFBED(thermalManager.degTargetBed(), thermalManager.degTargetHotend(heater));
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_CHAMBER
|
||||
FORCE_INLINE void _draw_chamber_status(const bool blink) {
|
||||
const float temp = thermalManager.degChamber(),
|
||||
target = thermalManager.degTargetChamber();
|
||||
#if !HEATER_IDLE_HANDLER
|
||||
UNUSED(blink);
|
||||
#endif
|
||||
if (PAGE_UNDER(7)) {
|
||||
#if HEATER_IDLE_HANDLER
|
||||
const bool is_idle = false, // thermalManager.chamber_idle.timed_out,
|
||||
dodraw = (blink || !is_idle);
|
||||
#else
|
||||
constexpr bool dodraw = true;
|
||||
#endif
|
||||
if (dodraw) _draw_centered_temp(target + 0.5, STATUS_CHAMBER_TEXT_X, 7);
|
||||
}
|
||||
if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
|
||||
_draw_centered_temp(temp + 0.5f, STATUS_CHAMBER_TEXT_X, 28);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DISABLED(STATUS_HOTEND_ANIM)
|
||||
#define STATIC_HOTEND true
|
||||
#define HOTEND_DOT isHeat
|
||||
@@ -271,7 +298,7 @@ void MarlinUI::draw_status_screen() {
|
||||
|
||||
// At the first page, generate new display values
|
||||
if (first_page) {
|
||||
#if ANIM_HOTEND || ANIM_BED
|
||||
#if ANIM_HOTEND || ANIM_BED || ANIM_CHAMBER
|
||||
uint8_t new_bits = 0;
|
||||
#if ANIM_HOTEND
|
||||
HOTEND_LOOP() if (thermalManager.isHeatingHotend(e) ^ SHOW_ON_STATE) SBI(new_bits, e);
|
||||
@@ -279,6 +306,9 @@ void MarlinUI::draw_status_screen() {
|
||||
#if ANIM_BED
|
||||
if (thermalManager.isHeatingBed() ^ SHOW_ON_STATE) SBI(new_bits, 7);
|
||||
#endif
|
||||
#if ANIM_CHAMBER
|
||||
if (thermalManager.isHeatingChamber() ^ SHOW_ON_STATE) SBI(new_bits, 6);
|
||||
#endif
|
||||
heat_bits = new_bits;
|
||||
#endif
|
||||
strcpy(xstring, ftostr4sign(LOGICAL_X_POSITION(current_position[X_AXIS])));
|
||||
@@ -326,6 +356,20 @@ void MarlinUI::draw_status_screen() {
|
||||
u8g.drawBitmapP(STATUS_BED_X, bedy, STATUS_BED_BYTEWIDTH, bedh, BED_BITMAP(BED_ALT()));
|
||||
#endif
|
||||
|
||||
#if DO_DRAW_CHAMBER
|
||||
#if ANIM_HAMBER
|
||||
#define CHAMBER_BITMAP(S) ((S) ? status_chamber_on_bmp : status_chamber_bmp)
|
||||
#else
|
||||
#define CHAMBER_BITMAP(S) status_chamber_bmp
|
||||
#endif
|
||||
if (PAGE_CONTAINS(STATUS_CHAMBER_Y, STATUS_CHAMBER_Y + STATUS_CHAMBER_HEIGHT - 1))
|
||||
u8g.drawBitmapP(
|
||||
STATUS_CHAMBER_X, STATUS_CHAMBER_Y,
|
||||
STATUS_CHAMBER_BYTEWIDTH, STATUS_CHAMBER_HEIGHT,
|
||||
CHAMBER_BITMAP(CHAMBER_ALT())
|
||||
);
|
||||
#endif
|
||||
|
||||
#if DO_DRAW_FAN
|
||||
#if STATUS_FAN_FRAMES > 2
|
||||
static bool old_blink;
|
||||
@@ -366,6 +410,10 @@ void MarlinUI::draw_status_screen() {
|
||||
_draw_heater_status(-1, blink);
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_CHAMBER
|
||||
_draw_chamber_status(blink);
|
||||
#endif
|
||||
|
||||
// Fan, if a bitmap was provided
|
||||
#if DO_DRAW_FAN
|
||||
if (PAGE_CONTAINS(STATUS_FAN_TEXT_Y - INFO_FONT_ASCENT, STATUS_FAN_TEXT_Y - 1)) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user