Skip to content

Commit

Permalink
Merge branch 'bugfix-2.0.x' into 2.0.x-Sapphire-Pro-Stock
Browse files Browse the repository at this point in the history
  • Loading branch information
petrzmax committed Apr 7, 2020
2 parents 1538ee9 + e1fc6f7 commit 7f4fd10
Show file tree
Hide file tree
Showing 119 changed files with 2,697 additions and 1,129 deletions.
133 changes: 109 additions & 24 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1600,18 +1600,11 @@
// Add additional compensation depending on hotend temperature
// Note: this values cannot be calibrated and have to be set manually
#if ENABLED(PROBE_TEMP_COMPENSATION)
// Max temperature that can be reached by heated bed.
// This is required only for the calibration process.
#define PTC_MAX_BED_TEMP BED_MAXTEMP

// Park position to wait for probe cooldown
#define PTC_PARK_POS_X 0.0F
#define PTC_PARK_POS_Y 0.0F
#define PTC_PARK_POS_Z 100.0F
#define PTC_PARK_POS { 0, 0, 100 }

// Probe position to probe and wait for probe to reach target temperature
#define PTC_PROBE_POS_X 90.0F
#define PTC_PROBE_POS_Y 100.0F
#define PTC_PROBE_POS { 90, 100 }

// Enable additional compensation using hotend temperature
// Note: this values cannot be calibrated automatically but have to be set manually
Expand Down Expand Up @@ -2662,31 +2655,123 @@
#define SPINDLE_LASER_ACTIVE_HIGH false // Set to "true" if the on/off function is active HIGH
#define SPINDLE_LASER_PWM true // Set to "true" if your controller supports setting the speed/power
#define SPINDLE_LASER_PWM_INVERT true // Set to "true" if the speed/power goes up when you want it to go slower
#define SPINDLE_LASER_POWERUP_DELAY 5000 // (ms) Delay to allow the spindle/laser to come up to speed/power
#define SPINDLE_LASER_POWERDOWN_DELAY 5000 // (ms) Delay to allow the spindle to stop

#define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC)

/**
* Speed / Power can be set ('M3 S') and displayed in terms of:
* - PWM (S0 - S255)
* - PERCENT (S0 - S100)
* - RPM (S0 - S50000) Best for use with a spindle
*/
#define CUTTER_POWER_DISPLAY PWM

/**
* Relative mode uses relative range (SPEED_POWER_MIN to SPEED_POWER_MAX) instead of normal range (0 to SPEED_POWER_MAX)
* Best use with SuperPID router controller where for example S0 = 5,000 RPM and S255 = 30,000 RPM
*/
//#define CUTTER_POWER_RELATIVE // Set speed proportional to [SPEED_POWER_MIN...SPEED_POWER_MAX] instead of directly

#if ENABLED(SPINDLE_FEATURE)
//#define SPINDLE_CHANGE_DIR // Enable if your spindle controller can change spindle direction
#define SPINDLE_CHANGE_DIR_STOP // Enable if the spindle should stop before changing spin direction
#define SPINDLE_INVERT_DIR false // Set to "true" if the spin direction is reversed

#define SPINDLE_LASER_POWERUP_DELAY 5000 // (ms) Delay to allow the spindle/laser to come up to speed/power
#define SPINDLE_LASER_POWERDOWN_DELAY 5000 // (ms) Delay to allow the spindle to stop

/**
* The M3 & M4 commands use the following equation to convert PWM duty cycle to speed/power
* M3/M4 uses the following equation to convert speed/power to PWM duty cycle
* Power = ((DC / 255 * 100) - SPEED_POWER_INTERCEPT)) * (1 / SPEED_POWER_SLOPE)
* where PWM DC varies from 0 to 255
*
* SPEED/POWER = PWM duty cycle * SPEED_POWER_SLOPE + SPEED_POWER_INTERCEPT
* where PWM duty cycle varies from 0 to 255
*
* set the following for your controller (ALL MUST BE SET)
* Set these required parameters for your controller
*/
#define SPEED_POWER_SLOPE 118.4
#define SPEED_POWER_INTERCEPT 0
#define SPEED_POWER_MIN 5000
#define SPEED_POWER_MAX 30000 // SuperPID router controller 0 - 30,000 RPM
#define SPEED_POWER_SLOPE 118.4 // SPEED_POWER_SLOPE = SPEED_POWER_MAX / 255
#define SPEED_POWER_INTERCEPT 0
#define SPEED_POWER_MIN 5000
#define SPEED_POWER_MAX 30000 // SuperPID router controller 0 - 30,000 RPM
#define SPEED_POWER_STARTUP 25000 // The default value for speed power when M3 is called without arguments

#else
#define SPEED_POWER_SLOPE 0.3922
#define SPEED_POWER_INTERCEPT 0
#define SPEED_POWER_MIN 10
#define SPEED_POWER_MAX 100 // 0-100%

#define SPEED_POWER_SLOPE 0.3922 // SPEED_POWER_SLOPE = SPEED_POWER_MAX / 255
#define SPEED_POWER_INTERCEPT 0
#define SPEED_POWER_MIN 0
#define SPEED_POWER_MAX 100 // 0-100%
#define SPEED_POWER_STARTUP 80 // The default value for speed power when M3 is called without arguments

/**
* Enable inline laser power to be handled in the planner / stepper routines.
* Inline power is specified by the I (inline) flag in an M3 command (e.g., M3 S20 I)
* or by the 'S' parameter in G0/G1/G2/G3 moves (see LASER_MOVE_POWER).
*
* This allows the laser to keep in perfect sync with the planner and removes
* the powerup/down delay since lasers require negligible time.
*/
#define LASER_POWER_INLINE

#if ENABLED(LASER_POWER_INLINE)
/**
* Scale the laser's power in proportion to the movement rate.
*
* - Sets the entry power proportional to the entry speed over the nominal speed.
* - Ramps the power up every N steps to approximate the speed trapezoid.
* - Due to the limited power resolution this is only approximate.
*/
#define LASER_POWER_INLINE_TRAPEZOID
/**
* Continuously calculate the current power (nominal_power * current_rate / nominal_rate).
* Required for accurate power with non-trapezoidal acceleration (e.g., S_CURVE_ACCELERATION).
* This is a costly calculation so this option is discouraged on 8-bit AVR boards.
*
* LASER_POWER_INLINE_TRAPEZOID_CONT_PER defines how many step cycles there are between power updates. If your
* board isn't able to generate steps fast enough (and you are using LASER_POWER_INLINE_TRAPEZOID_CONT), increase this.
* Note that when this is zero it means it occurs every cycle; 1 means a delay wait one cycle then run, etc.
*/
//#define LASER_POWER_INLINE_TRAPEZOID_CONT
/**
* Stepper iterations between power updates. Increase this value if the board
* can't keep up with the processing demands of LASER_POWER_INLINE_TRAPEZOID_CONT.
* Disable (or set to 0) to recalculate power on every stepper iteration.
*/
//#define LASER_POWER_INLINE_TRAPEZOID_CONT_PER 10
/**
* Include laser power in G0/G1/G2/G3/G5 commands with the 'S' parameter
*/
//#define LASER_MOVE_POWER

#if ENABLED(LASER_MOVE_POWER)
// Turn off the laser on G0 moves with no power parameter.
// If a power parameter is provided, use that instead.
//#define LASER_MOVE_G0_OFF
#endif

/**
* Inline flag inverted
*
* WARNING: M5 will NOT turn off the laser unless another move
* is done (so G-code files must end with 'M5 I').
*/
//#define LASER_POWER_INLINE_INVERT

/**
* Continuously apply inline power. ('M3 S3' == 'G1 S3' == 'M3 S3 I')
*
* The laser might do some weird things, so only enable this
* feature if you understand the implications.
*/
//#define LASER_POWER_INLINE_CONTINUOUS

#else

#define SPINDLE_LASER_POWERUP_DELAY 50 // (ms) Delay to allow the spindle/laser to come up to speed/power
#define SPINDLE_LASER_POWERDOWN_DELAY 50 // (ms) Delay to allow the spindle to stop

#endif
#endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ ifeq ($(HARDWARE_VARIANT), Teensy)

else ifeq ($(HARDWARE_VARIANT), archim)
CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT="Archim"'
LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp UARTClass.cpp USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp PluggableUSB.cpp USBCore.cpp
LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp UARTClass.cpp USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp PluggableUSB.cpp USBCore.cpp
LIB_SRC += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c

ifeq ($(U8GLIB), 1)
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/HAL/AVR/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ inline void HAL_adc_init() {
// AVR compatibility
#define strtof strtod

#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment

/**
* set_pwm_frequency
* Sets the frequency of the timer corresponding to the provided pin
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/AVR/fast_pwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "../../inc/MarlinConfigPre.h"

#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_PWM
#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM

#include "HAL.h"

Expand Down Expand Up @@ -278,5 +278,5 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255
}
}

#endif // FAST_PWM_FAN || SPINDLE_LASER_PWM
#endif // NEEDS_HARDWARE_PWM
#endif // __AVR__
4 changes: 2 additions & 2 deletions Marlin/src/HAL/AVR/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@

#define SET_INPUT(IO) _SET_INPUT(IO)
#define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _WRITE(IO, HIGH); }while(0)
#define SET_INPUT_PULLDOWN SET_INPUT
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)

#define SET_PWM(IO) SET_OUTPUT(IO)
#define SET_PWM SET_OUTPUT

#define IS_INPUT(IO) _IS_INPUT(IO)
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/DUE/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
// Set pin as output (wrapper) - reads the pin and sets the output to that value
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
// Set pin as PWM
#define SET_PWM(IO) SET_OUTPUT(IO)
#define SET_PWM SET_OUTPUT

// Check if pin is an input
#define IS_INPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) == 0)
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/ESP32/eeprom_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

#include "../../inc/MarlinConfig.h"

#if ENABLED(EEPROM_SETTINGS) && DISABLED(FLASH_EEPROM_EMULATION)
#if USE_WIRED_EEPROM

#include "../shared/eeprom_api.h"
#include "EEPROM.h"
#include <EEPROM.h>

#define EEPROM_SIZE 4096

Expand Down Expand Up @@ -59,5 +59,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t

size_t PersistentStore::capacity() { return EEPROM_SIZE; }

#endif // EEPROM_SETTINGS
#endif // USE_WIRED_EEPROM
#endif // ARDUINO_ARCH_ESP32
2 changes: 1 addition & 1 deletion Marlin/src/HAL/ESP32/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#define SET_OUTPUT(IO) do{ _SET_OUTPUT(IO); }while(0)

// Set pin as PWM
#define SET_PWM(IO) SET_OUTPUT(IO)
#define SET_PWM SET_OUTPUT

// Set pin as output and init
#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/ESP32/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
#pragma once

// If no real EEPROM, Flash emulation, or SRAM emulation is available fall back to SD emulation
#if ENABLED(EEPROM_SETTINGS) && NONE(USE_WIRED_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION)
#define SDCARD_EEPROM_EMULATION
#undef USE_WIRED_EEPROM
#if ENABLED(EEPROM_SETTINGS) && DISABLED(FLASH_EEPROM_EMULATION)
#define USE_WIRED_EEPROM 1
#endif
2 changes: 2 additions & 0 deletions Marlin/src/HAL/LPC1768/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ void HAL_idletask();
#define PLATFORM_M997_SUPPORT
void flashFirmware(const int16_t);

#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment

/**
* set_pwm_frequency
* Set the frequency of the timer corresponding to the provided pin
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LPC1768/fast_pwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "../../inc/MarlinConfigPre.h"

#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_PWM
#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM

#include <pwm.h>

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LPC1768/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
/// set pin as output wrapper - reads the pin and sets the output to that value
#define SET_OUTPUT(IO) do{ _WRITE(IO, _READ(IO)); _SET_OUTPUT(IO); }while(0)
// set pin as PWM
#define SET_PWM(IO) SET_OUTPUT(IO)
#define SET_PWM SET_OUTPUT

/// check if pin is an input wrapper
#define IS_INPUT(IO) _IS_INPUT(IO)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/SAMD51/QSPIFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#pragma once

#include "Adafruit_SPIFlashBase.h"
#include <Adafruit_SPIFlashBase.h>

// This class extends Adafruit_SPIFlashBase by adding caching support.
//
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/SAMD51/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@
PORT->Group[port].DIRCLR.reg = MASK(pin); \
}while(0)
// Set pin as PWM (push pull)
#define SET_PWM(IO) SET_OUTPUT(IO)
#define SET_PWM SET_OUTPUT
// Set pin as PWM (open drain)
#define SET_PWM_OD(IO) SET_OUTPUT_OD(IO)
#define SET_PWM_OD SET_OUTPUT_OD

// check if pin is an output
#define IS_OUTPUT(IO) ((PORT->Group[(EPortType)GET_SAMD_PORT(IO)].DIR.reg & MASK(GET_SAMD_PIN(IO))) \
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/HAL/TEENSY31_32/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@

#define SET_INPUT(IO) _SET_INPUT(IO)
#define SET_INPUT_PULLUP(IO) _SET_INPUT_PULLUP(IO)
#define SET_INPUT_PULLDOWN SET_INPUT
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
#define SET_PWM(IO) SET_OUTPUT(IO)
#define SET_PWM SET_OUTPUT

#define IS_INPUT(IO) _IS_INPUT(IO)
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/HAL/TEENSY35_36/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@

#define SET_INPUT(IO) _SET_INPUT(IO)
#define SET_INPUT_PULLUP(IO) _SET_INPUT_PULLUP(IO)
#define SET_INPUT_PULLDOWN SET_INPUT
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
#define SET_PWM(IO) SET_OUTPUT(IO)
#define SET_PWM SET_OUTPUT

#define IS_INPUT(IO) _IS_INPUT(IO)
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
Expand Down
Loading

0 comments on commit 7f4fd10

Please sign in to comment.