Upstream Merging
This commit is contained in:
parent
2c6c976fe3
commit
ec8844d744
Binary file not shown.
|
|
@ -6,9 +6,9 @@
|
||||||
#ifdef BLINKM
|
#ifdef BLINKM
|
||||||
|
|
||||||
#if (ARDUINO >= 100)
|
#if (ARDUINO >= 100)
|
||||||
# include "Arduino.h"
|
# include "Arduino.h"
|
||||||
#else
|
#else
|
||||||
# include "WProgram.h"
|
# include "WProgram.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "BlinkM.h"
|
#include "BlinkM.h"
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
Library header file for BlinkM library
|
Library header file for BlinkM library
|
||||||
*/
|
*/
|
||||||
#if (ARDUINO >= 100)
|
#if (ARDUINO >= 100)
|
||||||
# include "Arduino.h"
|
# include "Arduino.h"
|
||||||
#else
|
#else
|
||||||
# include "WProgram.h"
|
# include "WProgram.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Wire.h"
|
#include "Wire.h"
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
#define STR(x) STR_HELPER(x)
|
#define STR(x) STR_HELPER(x)
|
||||||
|
|
||||||
// Firmware version
|
// Firmware version
|
||||||
#define FW_VERSION "5.0.2"
|
#define FW_VERSION "3.5.0-RC1"
|
||||||
#define FW_COMMIT_NR 9999
|
#define FW_COMMIT_NR 1688
|
||||||
// FW_VERSION_UNKNOWN means this is an unofficial build.
|
// FW_VERSION_UNKNOWN means this is an unofficial build.
|
||||||
// The firmware should only be checked into github with this symbol.
|
// The firmware should only be checked into github with this symbol.
|
||||||
#define FW_DEV_VERSION FW_VERSION_UNKNOWN
|
#define FW_DEV_VERSION FW_VERSION_UNKNOWN
|
||||||
|
|
@ -128,14 +128,14 @@
|
||||||
#define BANG_MAX 255 // limits current to nozzle while in bang-bang mode; 255=full current
|
#define BANG_MAX 255 // limits current to nozzle while in bang-bang mode; 255=full current
|
||||||
#define PID_MAX BANG_MAX // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
|
#define PID_MAX BANG_MAX // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
|
||||||
#ifdef PIDTEMP
|
#ifdef PIDTEMP
|
||||||
//#define PID_DEBUG // Sends debug data to the serial port.
|
//#define PID_DEBUG // Sends debug data to the serial port.
|
||||||
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
|
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
|
||||||
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
|
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
|
||||||
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
|
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
|
||||||
// is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
|
// is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
|
||||||
#define PID_INTEGRAL_DRIVE_MAX PID_MAX //limit for the integral term
|
#define PID_INTEGRAL_DRIVE_MAX PID_MAX //limit for the integral term
|
||||||
#define K1 0.95 //smoothing factor within the PID
|
#define K1 0.95 //smoothing factor within the PID
|
||||||
#define PID_dT ((OVERSAMPLENR * 10.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine
|
#define PID_dT ((OVERSAMPLENR * 10.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine
|
||||||
|
|
||||||
// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
|
// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
|
||||||
// Ultimaker
|
// Ultimaker
|
||||||
|
|
@ -215,22 +215,22 @@ your extruder heater takes 2 minutes to hit the target on heating.
|
||||||
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
|
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
|
||||||
|
|
||||||
#ifndef ENDSTOPPULLUPS
|
#ifndef ENDSTOPPULLUPS
|
||||||
// fine endstop settings: Individual pullups. will be ignored if ENDSTOPPULLUPS is defined
|
// fine endstop settings: Individual pullups. will be ignored if ENDSTOPPULLUPS is defined
|
||||||
// #define ENDSTOPPULLUP_XMAX
|
// #define ENDSTOPPULLUP_XMAX
|
||||||
// #define ENDSTOPPULLUP_YMAX
|
// #define ENDSTOPPULLUP_YMAX
|
||||||
// #define ENDSTOPPULLUP_ZMAX
|
// #define ENDSTOPPULLUP_ZMAX
|
||||||
// #define ENDSTOPPULLUP_XMIN
|
// #define ENDSTOPPULLUP_XMIN
|
||||||
// #define ENDSTOPPULLUP_YMIN
|
// #define ENDSTOPPULLUP_YMIN
|
||||||
// #define ENDSTOPPULLUP_ZMIN
|
// #define ENDSTOPPULLUP_ZMIN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENDSTOPPULLUPS
|
#ifdef ENDSTOPPULLUPS
|
||||||
#define ENDSTOPPULLUP_XMAX
|
#define ENDSTOPPULLUP_XMAX
|
||||||
#define ENDSTOPPULLUP_YMAX
|
#define ENDSTOPPULLUP_YMAX
|
||||||
#define ENDSTOPPULLUP_ZMAX
|
#define ENDSTOPPULLUP_ZMAX
|
||||||
#define ENDSTOPPULLUP_XMIN
|
#define ENDSTOPPULLUP_XMIN
|
||||||
#define ENDSTOPPULLUP_YMIN
|
#define ENDSTOPPULLUP_YMIN
|
||||||
#define ENDSTOPPULLUP_ZMIN
|
#define ENDSTOPPULLUP_ZMIN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
|
// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
|
||||||
|
|
@ -243,7 +243,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
|
||||||
|
|
||||||
// Disable max endstops for compatibility with endstop checking routine
|
// Disable max endstops for compatibility with endstop checking routine
|
||||||
#if defined(COREXY) && !defined(DISABLE_MAX_ENDSTOPS)
|
#if defined(COREXY) && !defined(DISABLE_MAX_ENDSTOPS)
|
||||||
#define DISABLE_MAX_ENDSTOPS
|
#define DISABLE_MAX_ENDSTOPS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
|
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
|
||||||
|
|
@ -300,58 +300,58 @@ your extruder heater takes 2 minutes to hit the target on heating.
|
||||||
// Probe 3 arbitrary points on the bed (that aren't colinear)
|
// Probe 3 arbitrary points on the bed (that aren't colinear)
|
||||||
// You must specify the X & Y coordinates of all 3 points
|
// You must specify the X & Y coordinates of all 3 points
|
||||||
|
|
||||||
#define AUTO_BED_LEVELING_GRID
|
#define AUTO_BED_LEVELING_GRID
|
||||||
// with AUTO_BED_LEVELING_GRID, the bed is sampled in a
|
// with AUTO_BED_LEVELING_GRID, the bed is sampled in a
|
||||||
// AUTO_BED_LEVELING_GRID_POINTSxAUTO_BED_LEVELING_GRID_POINTS grid
|
// AUTO_BED_LEVELING_GRID_POINTSxAUTO_BED_LEVELING_GRID_POINTS grid
|
||||||
// and least squares solution is calculated
|
// and least squares solution is calculated
|
||||||
// Note: this feature occupies 10'206 byte
|
// Note: this feature occupies 10'206 byte
|
||||||
#ifdef AUTO_BED_LEVELING_GRID
|
#ifdef AUTO_BED_LEVELING_GRID
|
||||||
|
|
||||||
// set the rectangle in which to probe
|
// set the rectangle in which to probe
|
||||||
#define LEFT_PROBE_BED_POSITION 15
|
#define LEFT_PROBE_BED_POSITION 15
|
||||||
#define RIGHT_PROBE_BED_POSITION 170
|
#define RIGHT_PROBE_BED_POSITION 170
|
||||||
#define BACK_PROBE_BED_POSITION 180
|
#define BACK_PROBE_BED_POSITION 180
|
||||||
#define FRONT_PROBE_BED_POSITION 20
|
#define FRONT_PROBE_BED_POSITION 20
|
||||||
|
|
||||||
// set the number of grid points per dimension
|
// set the number of grid points per dimension
|
||||||
// I wouldn't see a reason to go above 3 (=9 probing points on the bed)
|
// I wouldn't see a reason to go above 3 (=9 probing points on the bed)
|
||||||
#define AUTO_BED_LEVELING_GRID_POINTS 2
|
#define AUTO_BED_LEVELING_GRID_POINTS 2
|
||||||
|
|
||||||
|
|
||||||
#else // not AUTO_BED_LEVELING_GRID
|
#else // not AUTO_BED_LEVELING_GRID
|
||||||
// with no grid, just probe 3 arbitrary points. A simple cross-product
|
// with no grid, just probe 3 arbitrary points. A simple cross-product
|
||||||
// is used to esimate the plane of the print bed
|
// is used to esimate the plane of the print bed
|
||||||
|
|
||||||
#define ABL_PROBE_PT_1_X 15
|
#define ABL_PROBE_PT_1_X 15
|
||||||
#define ABL_PROBE_PT_1_Y 180
|
#define ABL_PROBE_PT_1_Y 180
|
||||||
#define ABL_PROBE_PT_2_X 15
|
#define ABL_PROBE_PT_2_X 15
|
||||||
#define ABL_PROBE_PT_2_Y 20
|
#define ABL_PROBE_PT_2_Y 20
|
||||||
#define ABL_PROBE_PT_3_X 170
|
#define ABL_PROBE_PT_3_X 170
|
||||||
#define ABL_PROBE_PT_3_Y 20
|
#define ABL_PROBE_PT_3_Y 20
|
||||||
|
|
||||||
#endif // AUTO_BED_LEVELING_GRID
|
#endif // AUTO_BED_LEVELING_GRID
|
||||||
|
|
||||||
|
|
||||||
// these are the offsets to the probe relative to the extruder tip (Hotend - Probe)
|
// these are the offsets to the probe relative to the extruder tip (Hotend - Probe)
|
||||||
// X and Y offsets must be integers
|
// X and Y offsets must be integers
|
||||||
#define X_PROBE_OFFSET_FROM_EXTRUDER -25
|
#define X_PROBE_OFFSET_FROM_EXTRUDER -25
|
||||||
#define Y_PROBE_OFFSET_FROM_EXTRUDER -29
|
#define Y_PROBE_OFFSET_FROM_EXTRUDER -29
|
||||||
#define Z_PROBE_OFFSET_FROM_EXTRUDER -12.35
|
#define Z_PROBE_OFFSET_FROM_EXTRUDER -12.35
|
||||||
|
|
||||||
#define Z_RAISE_BEFORE_HOMING 4 // (in mm) Raise Z before homing (G28) for Probe Clearance.
|
#define Z_RAISE_BEFORE_HOMING 4 // (in mm) Raise Z before homing (G28) for Probe Clearance.
|
||||||
// Be sure you have this distance over your Z_MAX_POS in case
|
// Be sure you have this distance over your Z_MAX_POS in case
|
||||||
|
|
||||||
#define XY_TRAVEL_SPEED 8000 // X and Y axis travel speed between probes, in mm/min
|
#define XY_TRAVEL_SPEED 8000 // X and Y axis travel speed between probes, in mm/min
|
||||||
|
|
||||||
#define Z_RAISE_BEFORE_PROBING 15 //How much the extruder will be raised before traveling to the first probing point.
|
#define Z_RAISE_BEFORE_PROBING 15 //How much the extruder will be raised before traveling to the first probing point.
|
||||||
#define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when traveling from between next probing points
|
#define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when traveling from between next probing points
|
||||||
|
|
||||||
//#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell
|
//#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell
|
||||||
//#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like.
|
//#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like.
|
||||||
|
|
||||||
//If defined, the Probe servo will be turned on only during movement and then turned off to avoid jerk
|
//If defined, the Probe servo will be turned on only during movement and then turned off to avoid jerk
|
||||||
//The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it.
|
//The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it.
|
||||||
// You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile.
|
// You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile.
|
||||||
|
|
||||||
// #define PROBE_SERVO_DEACTIVATION_DELAY 300
|
// #define PROBE_SERVO_DEACTIVATION_DELAY 300
|
||||||
|
|
||||||
|
|
@ -359,42 +359,42 @@ your extruder heater takes 2 minutes to hit the target on heating.
|
||||||
//If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing,
|
//If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing,
|
||||||
//it is highly recommended you let this Z_SAFE_HOMING enabled!
|
//it is highly recommended you let this Z_SAFE_HOMING enabled!
|
||||||
|
|
||||||
//#define Z_SAFE_HOMING // This feature is meant to avoid Z homing with probe outside the bed area.
|
//#define Z_SAFE_HOMING // This feature is meant to avoid Z homing with probe outside the bed area.
|
||||||
// When defined, it will:
|
// When defined, it will:
|
||||||
// - Allow Z homing only after X and Y homing AND stepper drivers still enabled
|
// - Allow Z homing only after X and Y homing AND stepper drivers still enabled
|
||||||
// - If stepper drivers timeout, it will need X and Y homing again before Z homing
|
// - If stepper drivers timeout, it will need X and Y homing again before Z homing
|
||||||
// - Position the probe in a defined XY point before Z Homing when homing all axis (G28)
|
// - Position the probe in a defined XY point before Z Homing when homing all axis (G28)
|
||||||
// - Block Z homing only when the probe is outside bed area.
|
// - Block Z homing only when the probe is outside bed area.
|
||||||
|
|
||||||
#ifdef Z_SAFE_HOMING
|
#ifdef Z_SAFE_HOMING
|
||||||
|
|
||||||
#define Z_SAFE_HOMING_X_POINT (X_MAX_LENGTH/2) // X point for Z homing when homing all axis (G28)
|
#define Z_SAFE_HOMING_X_POINT (X_MAX_LENGTH/2) // X point for Z homing when homing all axis (G28)
|
||||||
#define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2) // Y point for Z homing when homing all axis (G28)
|
#define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2) // Y point for Z homing when homing all axis (G28)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef AUTO_BED_LEVELING_GRID // Check if Probe_Offset * Grid Points is greater than Probing Range
|
#ifdef AUTO_BED_LEVELING_GRID // Check if Probe_Offset * Grid Points is greater than Probing Range
|
||||||
#if X_PROBE_OFFSET_FROM_EXTRUDER < 0
|
#if X_PROBE_OFFSET_FROM_EXTRUDER < 0
|
||||||
#if (-(X_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION))
|
#if (-(X_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION))
|
||||||
#error "The X axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
|
#error "The X axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if ((X_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION))
|
#if ((X_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION))
|
||||||
#error "The X axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
|
#error "The X axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if Y_PROBE_OFFSET_FROM_EXTRUDER < 0
|
#if Y_PROBE_OFFSET_FROM_EXTRUDER < 0
|
||||||
#if (-(Y_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION))
|
#if (-(Y_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION))
|
||||||
#error "The Y axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
|
#error "The Y axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if ((Y_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION))
|
#if ((Y_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION))
|
||||||
#error "The Y axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
|
#error "The Y axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // ENABLE_AUTO_BED_LEVELING
|
#endif // ENABLE_AUTO_BED_LEVELING
|
||||||
|
|
||||||
|
|
@ -426,9 +426,9 @@ your extruder heater takes 2 minutes to hit the target on heating.
|
||||||
// Custom M code points
|
// Custom M code points
|
||||||
#define CUSTOM_M_CODES
|
#define CUSTOM_M_CODES
|
||||||
#ifdef CUSTOM_M_CODES
|
#ifdef CUSTOM_M_CODES
|
||||||
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
|
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
|
||||||
#define Z_PROBE_OFFSET_RANGE_MIN -15
|
#define Z_PROBE_OFFSET_RANGE_MIN -15
|
||||||
#define Z_PROBE_OFFSET_RANGE_MAX -5
|
#define Z_PROBE_OFFSET_RANGE_MAX -5
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ static const M500_conf default_conf PROGMEM =
|
||||||
RETRACT_RECOVER_LENGTH,
|
RETRACT_RECOVER_LENGTH,
|
||||||
RETRACT_RECOVER_FEEDRATE,
|
RETRACT_RECOVER_FEEDRATE,
|
||||||
false,
|
false,
|
||||||
{ DEFAULT_NOMINAL_FILAMENT_DIA,
|
{DEFAULT_NOMINAL_FILAMENT_DIA,
|
||||||
#if EXTRUDERS > 1
|
#if EXTRUDERS > 1
|
||||||
DEFAULT_NOMINAL_FILAMENT_DIA,
|
DEFAULT_NOMINAL_FILAMENT_DIA,
|
||||||
#if EXTRUDERS > 2
|
#if EXTRUDERS > 2
|
||||||
|
|
@ -295,9 +295,9 @@ bool Config_RetrieveSettings()
|
||||||
previous_settings_retrieved = false;
|
previous_settings_retrieved = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef EEPROM_CHITCHAT
|
#ifdef EEPROM_CHITCHAT
|
||||||
Config_PrintSettings();
|
Config_PrintSettings();
|
||||||
#endif
|
#endif
|
||||||
return previous_settings_retrieved;
|
return previous_settings_retrieved;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -318,7 +318,7 @@ void Config_ResetDefault()
|
||||||
|
|
||||||
calculate_extruder_multipliers();
|
calculate_extruder_multipliers();
|
||||||
|
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
|
SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,20 +54,11 @@ void Config_StoreSettings();
|
||||||
bool Config_RetrieveSettings();
|
bool Config_RetrieveSettings();
|
||||||
#else
|
#else
|
||||||
FORCE_INLINE void Config_StoreSettings() {}
|
FORCE_INLINE void Config_StoreSettings() {}
|
||||||
FORCE_INLINE void Config_RetrieveSettings() {
|
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }
|
||||||
Config_ResetDefault();
|
|
||||||
Config_PrintSettings();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline uint8_t calibration_status() {
|
inline uint8_t calibration_status() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS); }
|
||||||
return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS);
|
inline void calibration_status_store(uint8_t status) { eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS, status); }
|
||||||
}
|
inline bool calibration_status_pinda() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA); }
|
||||||
inline void calibration_status_store(uint8_t status) {
|
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS, status);
|
|
||||||
}
|
|
||||||
inline bool calibration_status_pinda() {
|
|
||||||
return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif//CONFIG_STORE_H
|
#endif//CONFIG_STORE_H
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
#ifdef BED_LIMIT_SWITCHING
|
#ifdef BED_LIMIT_SWITCHING
|
||||||
#define BED_HYSTERESIS 2 //only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS
|
#define BED_HYSTERESIS 2 //only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS
|
||||||
#endif
|
#endif
|
||||||
#define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control
|
#define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control
|
||||||
|
|
||||||
|
|
@ -19,12 +19,12 @@
|
||||||
//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds
|
//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds
|
||||||
|
|
||||||
#ifdef PIDTEMP
|
#ifdef PIDTEMP
|
||||||
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
|
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
|
||||||
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
|
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
|
||||||
#define PID_ADD_EXTRUSION_RATE
|
#define PID_ADD_EXTRUSION_RATE
|
||||||
#ifdef PID_ADD_EXTRUSION_RATE
|
#ifdef PID_ADD_EXTRUSION_RATE
|
||||||
#define DEFAULT_Kc (1) //heating power=Kc*(e_speed)
|
#define DEFAULT_Kc (1) //heating power=Kc*(e_speed)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
// on an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode
|
// on an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode
|
||||||
//#define AUTOTEMP
|
//#define AUTOTEMP
|
||||||
#ifdef AUTOTEMP
|
#ifdef AUTOTEMP
|
||||||
#define AUTOTEMP_OLDWEIGHT 0.98
|
#define AUTOTEMP_OLDWEIGHT 0.98
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Show Temperature ADC value
|
//Show Temperature ADC value
|
||||||
|
|
@ -83,46 +83,46 @@
|
||||||
//// AUTOSET LOCATIONS OF LIMIT SWITCHES
|
//// AUTOSET LOCATIONS OF LIMIT SWITCHES
|
||||||
//// Added by ZetaPhoenix 09-15-2012
|
//// Added by ZetaPhoenix 09-15-2012
|
||||||
#ifdef MANUAL_HOME_POSITIONS // Use manual limit switch locations
|
#ifdef MANUAL_HOME_POSITIONS // Use manual limit switch locations
|
||||||
#define X_HOME_POS MANUAL_X_HOME_POS
|
#define X_HOME_POS MANUAL_X_HOME_POS
|
||||||
#define Y_HOME_POS MANUAL_Y_HOME_POS
|
#define Y_HOME_POS MANUAL_Y_HOME_POS
|
||||||
#define Z_HOME_POS MANUAL_Z_HOME_POS
|
#define Z_HOME_POS MANUAL_Z_HOME_POS
|
||||||
#else //Set min/max homing switch positions based upon homing direction and min/max travel limits
|
#else //Set min/max homing switch positions based upon homing direction and min/max travel limits
|
||||||
//X axis
|
//X axis
|
||||||
#if X_HOME_DIR == -1
|
#if X_HOME_DIR == -1
|
||||||
#ifdef BED_CENTER_AT_0_0
|
#ifdef BED_CENTER_AT_0_0
|
||||||
#define X_HOME_POS X_MAX_LENGTH * -0.5
|
#define X_HOME_POS X_MAX_LENGTH * -0.5
|
||||||
#else
|
#else
|
||||||
#define X_HOME_POS X_MIN_POS
|
#define X_HOME_POS X_MIN_POS
|
||||||
#endif //BED_CENTER_AT_0_0
|
#endif //BED_CENTER_AT_0_0
|
||||||
#else
|
#else
|
||||||
#ifdef BED_CENTER_AT_0_0
|
#ifdef BED_CENTER_AT_0_0
|
||||||
#define X_HOME_POS X_MAX_LENGTH * 0.5
|
#define X_HOME_POS X_MAX_LENGTH * 0.5
|
||||||
#else
|
#else
|
||||||
#define X_HOME_POS X_MAX_POS
|
#define X_HOME_POS X_MAX_POS
|
||||||
#endif //BED_CENTER_AT_0_0
|
#endif //BED_CENTER_AT_0_0
|
||||||
#endif //X_HOME_DIR == -1
|
#endif //X_HOME_DIR == -1
|
||||||
|
|
||||||
//Y axis
|
//Y axis
|
||||||
#if Y_HOME_DIR == -1
|
#if Y_HOME_DIR == -1
|
||||||
#ifdef BED_CENTER_AT_0_0
|
#ifdef BED_CENTER_AT_0_0
|
||||||
#define Y_HOME_POS Y_MAX_LENGTH * -0.5
|
#define Y_HOME_POS Y_MAX_LENGTH * -0.5
|
||||||
#else
|
#else
|
||||||
#define Y_HOME_POS Y_MIN_POS
|
#define Y_HOME_POS Y_MIN_POS
|
||||||
#endif //BED_CENTER_AT_0_0
|
#endif //BED_CENTER_AT_0_0
|
||||||
#else
|
#else
|
||||||
#ifdef BED_CENTER_AT_0_0
|
#ifdef BED_CENTER_AT_0_0
|
||||||
#define Y_HOME_POS Y_MAX_LENGTH * 0.5
|
#define Y_HOME_POS Y_MAX_LENGTH * 0.5
|
||||||
#else
|
#else
|
||||||
#define Y_HOME_POS Y_MAX_POS
|
#define Y_HOME_POS Y_MAX_POS
|
||||||
#endif //BED_CENTER_AT_0_0
|
#endif //BED_CENTER_AT_0_0
|
||||||
#endif //Y_HOME_DIR == -1
|
#endif //Y_HOME_DIR == -1
|
||||||
|
|
||||||
// Z axis
|
// Z axis
|
||||||
#if Z_HOME_DIR == -1 //BED_CENTER_AT_0_0 not used
|
#if Z_HOME_DIR == -1 //BED_CENTER_AT_0_0 not used
|
||||||
#define Z_HOME_POS Z_MIN_POS
|
#define Z_HOME_POS Z_MIN_POS
|
||||||
#else
|
#else
|
||||||
#define Z_HOME_POS Z_MAX_POS
|
#define Z_HOME_POS Z_MAX_POS
|
||||||
#endif //Z_HOME_DIR == -1
|
#endif //Z_HOME_DIR == -1
|
||||||
#endif //End auto min/max positions
|
#endif //End auto min/max positions
|
||||||
//END AUTOSET LOCATIONS OF LIMIT SWITCHES -ZP
|
//END AUTOSET LOCATIONS OF LIMIT SWITCHES -ZP
|
||||||
|
|
||||||
|
|
@ -135,8 +135,8 @@
|
||||||
//#define Z_DUAL_STEPPER_DRIVERS
|
//#define Z_DUAL_STEPPER_DRIVERS
|
||||||
|
|
||||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||||
#undef EXTRUDERS
|
#undef EXTRUDERS
|
||||||
#define EXTRUDERS 1
|
#define EXTRUDERS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Same again but for Y Axis.
|
// Same again but for Y Axis.
|
||||||
|
|
@ -146,12 +146,12 @@
|
||||||
#define INVERT_Y2_VS_Y_DIR 1
|
#define INVERT_Y2_VS_Y_DIR 1
|
||||||
|
|
||||||
#ifdef Y_DUAL_STEPPER_DRIVERS
|
#ifdef Y_DUAL_STEPPER_DRIVERS
|
||||||
#undef EXTRUDERS
|
#undef EXTRUDERS
|
||||||
#define EXTRUDERS 1
|
#define EXTRUDERS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (Z_DUAL_STEPPER_DRIVERS) && defined (Y_DUAL_STEPPER_DRIVERS)
|
#if defined (Z_DUAL_STEPPER_DRIVERS) && defined (Y_DUAL_STEPPER_DRIVERS)
|
||||||
#error "You cannot have dual drivers for both Y and Z"
|
#error "You cannot have dual drivers for both Y and Z"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
|
//homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
|
||||||
|
|
@ -235,28 +235,28 @@
|
||||||
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
*/
|
*/
|
||||||
#define SDCARD_SORT_ALPHA //Alphabetical sorting of SD files menu
|
#define SDCARD_SORT_ALPHA //Alphabetical sorting of SD files menu
|
||||||
|
|
||||||
// SD Card Sorting options
|
// SD Card Sorting options
|
||||||
// In current firmware Prusa Firmware version,
|
// In current firmware Prusa Firmware version,
|
||||||
// SDSORT_CACHE_NAMES and SDSORT_DYNAMIC_RAM is not supported and must be set to 0.
|
// SDSORT_CACHE_NAMES and SDSORT_DYNAMIC_RAM is not supported and must be set to 0.
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
#define SD_SORT_TIME 0
|
#define SD_SORT_TIME 0
|
||||||
#define SD_SORT_ALPHA 1
|
#define SD_SORT_ALPHA 1
|
||||||
#define SD_SORT_NONE 2
|
#define SD_SORT_NONE 2
|
||||||
|
|
||||||
#define SDSORT_LIMIT 100 // Maximum number of sorted items (10-256).
|
#define SDSORT_LIMIT 100 // Maximum number of sorted items (10-256).
|
||||||
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
#define SDSORT_GCODE 0 // Allow turning sorting on/off with LCD and M34 g-code.
|
#define SDSORT_GCODE 0 // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
#define SDSORT_USES_RAM 0 // Pre-allocate a static array for faster pre-sorting.
|
#define SDSORT_USES_RAM 0 // Pre-allocate a static array for faster pre-sorting.
|
||||||
#define SDSORT_USES_STACK 0 // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
#define SDSORT_USES_STACK 0 // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
#define SDSORT_CACHE_NAMES 0 // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
#define SDSORT_CACHE_NAMES 0 // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
#define SDSORT_DYNAMIC_RAM 0 // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
#define SDSORT_DYNAMIC_RAM 0 // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SDCARD_SORT_ALPHA)
|
#if defined(SDCARD_SORT_ALPHA)
|
||||||
#define HAS_FOLDER_SORTING (FOLDER_SORTING || SDSORT_GCODE)
|
#define HAS_FOLDER_SORTING (FOLDER_SORTING || SDSORT_GCODE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enable the option to stop SD printing when hitting and endstops, needs to be enabled from the LCD menu when this option is enabled.
|
// Enable the option to stop SD printing when hitting and endstops, needs to be enabled from the LCD menu when this option is enabled.
|
||||||
//#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
|
//#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
|
||||||
|
|
@ -266,13 +266,13 @@
|
||||||
// does not respect endstops!
|
// does not respect endstops!
|
||||||
#define BABYSTEPPING
|
#define BABYSTEPPING
|
||||||
#ifdef BABYSTEPPING
|
#ifdef BABYSTEPPING
|
||||||
#define BABYSTEP_XY //not only z, but also XY in the menu. more clutter, more functions
|
#define BABYSTEP_XY //not only z, but also XY in the menu. more clutter, more functions
|
||||||
#define BABYSTEP_INVERT_Z 0 //1 for inverse movements in Z
|
#define BABYSTEP_INVERT_Z 0 //1 for inverse movements in Z
|
||||||
#define BABYSTEP_Z_MULTIPLICATOR 2 //faster z movements
|
#define BABYSTEP_Z_MULTIPLICATOR 2 //faster z movements
|
||||||
|
|
||||||
#ifdef COREXY
|
#ifdef COREXY
|
||||||
#error BABYSTEPPING not implemented for COREXY yet.
|
#error BABYSTEPPING not implemented for COREXY yet.
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -285,9 +285,9 @@
|
||||||
#define LIN_ADVANCE
|
#define LIN_ADVANCE
|
||||||
|
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
#define LIN_ADVANCE_K 0 //Try around 45 for PLA, around 25 for ABS.
|
#define LIN_ADVANCE_K 0 //Try around 45 for PLA, around 25 for ABS.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
|
* Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
|
||||||
* For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
|
* For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
|
||||||
* While this is harmless for normal printing (the fluid nature of the filament will
|
* While this is harmless for normal printing (the fluid nature of the filament will
|
||||||
|
|
@ -312,7 +312,7 @@
|
||||||
* Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
|
* Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
|
||||||
*/
|
*/
|
||||||
#define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
|
#define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
|
||||||
// Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
|
// Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Arc interpretation settings:
|
// Arc interpretation settings:
|
||||||
|
|
@ -331,17 +331,17 @@ const unsigned int dropsegments=5; //everything with less than this number of st
|
||||||
// Power Signal Control Definitions
|
// Power Signal Control Definitions
|
||||||
// By default use ATX definition
|
// By default use ATX definition
|
||||||
#ifndef POWER_SUPPLY
|
#ifndef POWER_SUPPLY
|
||||||
#define POWER_SUPPLY 1
|
#define POWER_SUPPLY 1
|
||||||
#endif
|
#endif
|
||||||
// 1 = ATX
|
// 1 = ATX
|
||||||
#if (POWER_SUPPLY == 1)
|
#if (POWER_SUPPLY == 1)
|
||||||
#define PS_ON_AWAKE LOW
|
#define PS_ON_AWAKE LOW
|
||||||
#define PS_ON_ASLEEP HIGH
|
#define PS_ON_ASLEEP HIGH
|
||||||
#endif
|
#endif
|
||||||
// 2 = X-Box 360 203W
|
// 2 = X-Box 360 203W
|
||||||
#if (POWER_SUPPLY == 2)
|
#if (POWER_SUPPLY == 2)
|
||||||
#define PS_ON_AWAKE HIGH
|
#define PS_ON_AWAKE HIGH
|
||||||
#define PS_ON_ASLEEP LOW
|
#define PS_ON_ASLEEP LOW
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Control heater 0 and heater 1 in parallel.
|
// Control heater 0 and heater 1 in parallel.
|
||||||
|
|
@ -354,9 +354,9 @@ const unsigned int dropsegments=5; //everything with less than this number of st
|
||||||
// The number of linear motions that can be in the plan at any give time.
|
// The number of linear motions that can be in the plan at any give time.
|
||||||
// THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ring-buffering.
|
// THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ring-buffering.
|
||||||
#if defined SDSUPPORT
|
#if defined SDSUPPORT
|
||||||
#define BLOCK_BUFFER_SIZE 16 // SD,LCD,Buttons take more memory, block buffer needs to be smaller
|
#define BLOCK_BUFFER_SIZE 16 // SD,LCD,Buttons take more memory, block buffer needs to be smaller
|
||||||
#else
|
#else
|
||||||
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
|
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -377,23 +377,23 @@ const unsigned int dropsegments=5; //everything with less than this number of st
|
||||||
|
|
||||||
#define FWRETRACT //ONLY PARTIALLY TESTED
|
#define FWRETRACT //ONLY PARTIALLY TESTED
|
||||||
#ifdef FWRETRACT
|
#ifdef FWRETRACT
|
||||||
#define MIN_RETRACT 0.1 //minimum extruded mm to accept a automatic gcode retraction attempt
|
#define MIN_RETRACT 0.1 //minimum extruded mm to accept a automatic gcode retraction attempt
|
||||||
#define RETRACT_LENGTH 3 //default retract length (positive mm)
|
#define RETRACT_LENGTH 3 //default retract length (positive mm)
|
||||||
#define RETRACT_LENGTH_SWAP 13 //default swap retract length (positive mm), for extruder change
|
#define RETRACT_LENGTH_SWAP 13 //default swap retract length (positive mm), for extruder change
|
||||||
#define RETRACT_FEEDRATE 45 //default feedrate for retracting (mm/s)
|
#define RETRACT_FEEDRATE 45 //default feedrate for retracting (mm/s)
|
||||||
#define RETRACT_ZLIFT 0 //default retract Z-lift
|
#define RETRACT_ZLIFT 0 //default retract Z-lift
|
||||||
#define RETRACT_RECOVER_LENGTH 0 //default additional recover length (mm, added to retract length when recovering)
|
#define RETRACT_RECOVER_LENGTH 0 //default additional recover length (mm, added to retract length when recovering)
|
||||||
#define RETRACT_RECOVER_LENGTH_SWAP 0 //default additional swap recover length (mm, added to retract length when recovering from extruder change)
|
#define RETRACT_RECOVER_LENGTH_SWAP 0 //default additional swap recover length (mm, added to retract length when recovering from extruder change)
|
||||||
#define RETRACT_RECOVER_FEEDRATE 8 //default feedrate for recovering from retraction (mm/s)
|
#define RETRACT_RECOVER_FEEDRATE 8 //default feedrate for recovering from retraction (mm/s)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//adds support for experimental filament exchange support M600; requires display
|
//adds support for experimental filament exchange support M600; requires display
|
||||||
|
|
||||||
|
|
||||||
#ifdef FILAMENTCHANGEENABLE
|
#ifdef FILAMENTCHANGEENABLE
|
||||||
#ifdef EXTRUDER_RUNOUT_PREVENT
|
#ifdef EXTRUDER_RUNOUT_PREVENT
|
||||||
#error EXTRUDER_RUNOUT_PREVENT currently incompatible with FILAMENTCHANGE
|
#error EXTRUDER_RUNOUT_PREVENT currently incompatible with FILAMENTCHANGE
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
@ -401,65 +401,65 @@ const unsigned int dropsegments=5; //everything with less than this number of st
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
#if EXTRUDERS > 1 && defined TEMP_SENSOR_1_AS_REDUNDANT
|
#if EXTRUDERS > 1 && defined TEMP_SENSOR_1_AS_REDUNDANT
|
||||||
#error "You cannot use TEMP_SENSOR_1_AS_REDUNDANT if EXTRUDERS > 1"
|
#error "You cannot use TEMP_SENSOR_1_AS_REDUNDANT if EXTRUDERS > 1"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if EXTRUDERS > 1 && defined HEATERS_PARALLEL
|
#if EXTRUDERS > 1 && defined HEATERS_PARALLEL
|
||||||
#error "You cannot use HEATERS_PARALLEL if EXTRUDERS > 1"
|
#error "You cannot use HEATERS_PARALLEL if EXTRUDERS > 1"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TEMP_SENSOR_0 > 0
|
#if TEMP_SENSOR_0 > 0
|
||||||
#define THERMISTORHEATER_0 TEMP_SENSOR_0
|
#define THERMISTORHEATER_0 TEMP_SENSOR_0
|
||||||
#define HEATER_0_USES_THERMISTOR
|
#define HEATER_0_USES_THERMISTOR
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_1 > 0
|
#if TEMP_SENSOR_1 > 0
|
||||||
#define THERMISTORHEATER_1 TEMP_SENSOR_1
|
#define THERMISTORHEATER_1 TEMP_SENSOR_1
|
||||||
#define HEATER_1_USES_THERMISTOR
|
#define HEATER_1_USES_THERMISTOR
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_2 > 0
|
#if TEMP_SENSOR_2 > 0
|
||||||
#define THERMISTORHEATER_2 TEMP_SENSOR_2
|
#define THERMISTORHEATER_2 TEMP_SENSOR_2
|
||||||
#define HEATER_2_USES_THERMISTOR
|
#define HEATER_2_USES_THERMISTOR
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_BED > 0
|
#if TEMP_SENSOR_BED > 0
|
||||||
#define THERMISTORBED TEMP_SENSOR_BED
|
#define THERMISTORBED TEMP_SENSOR_BED
|
||||||
#define BED_USES_THERMISTOR
|
#define BED_USES_THERMISTOR
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_PINDA > 0
|
#if TEMP_SENSOR_PINDA > 0
|
||||||
#define THERMISTORPINDA TEMP_SENSOR_PINDA
|
#define THERMISTORPINDA TEMP_SENSOR_PINDA
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_AMBIENT > 0
|
#if TEMP_SENSOR_AMBIENT > 0
|
||||||
#define THERMISTORAMBIENT TEMP_SENSOR_AMBIENT
|
#define THERMISTORAMBIENT TEMP_SENSOR_AMBIENT
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_0 == -1
|
#if TEMP_SENSOR_0 == -1
|
||||||
#define HEATER_0_USES_AD595
|
#define HEATER_0_USES_AD595
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_1 == -1
|
#if TEMP_SENSOR_1 == -1
|
||||||
#define HEATER_1_USES_AD595
|
#define HEATER_1_USES_AD595
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_2 == -1
|
#if TEMP_SENSOR_2 == -1
|
||||||
#define HEATER_2_USES_AD595
|
#define HEATER_2_USES_AD595
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_BED == -1
|
#if TEMP_SENSOR_BED == -1
|
||||||
#define BED_USES_AD595
|
#define BED_USES_AD595
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_0 == -2
|
#if TEMP_SENSOR_0 == -2
|
||||||
#define HEATER_0_USES_MAX6675
|
#define HEATER_0_USES_MAX6675
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_0 == 0
|
#if TEMP_SENSOR_0 == 0
|
||||||
#undef HEATER_0_MINTEMP
|
#undef HEATER_0_MINTEMP
|
||||||
#undef HEATER_0_MAXTEMP
|
#undef HEATER_0_MAXTEMP
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_1 == 0
|
#if TEMP_SENSOR_1 == 0
|
||||||
#undef HEATER_1_MINTEMP
|
#undef HEATER_1_MINTEMP
|
||||||
#undef HEATER_1_MAXTEMP
|
#undef HEATER_1_MAXTEMP
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_2 == 0
|
#if TEMP_SENSOR_2 == 0
|
||||||
#undef HEATER_2_MINTEMP
|
#undef HEATER_2_MINTEMP
|
||||||
#undef HEATER_2_MAXTEMP
|
#undef HEATER_2_MAXTEMP
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_SENSOR_BED == 0
|
#if TEMP_SENSOR_BED == 0
|
||||||
#undef BED_MINTEMP
|
#undef BED_MINTEMP
|
||||||
#undef BED_MAXTEMP
|
#undef BED_MAXTEMP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,15 +81,9 @@ void print_mem(uint32_t address, uint16_t count, uint8_t type, uint8_t countperl
|
||||||
uint8_t data = 0;
|
uint8_t data = 0;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0: data = *((uint8_t*)address++); break;
|
||||||
data = *((uint8_t*)address++);
|
case 1: data = eeprom_read_byte((uint8_t*)address++); break;
|
||||||
break;
|
case 2: data = pgm_read_byte_far((uint8_t*)address++); break;
|
||||||
case 1:
|
|
||||||
data = eeprom_read_byte((uint8_t*)address++);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
data = pgm_read_byte_far((uint8_t*)address++);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
print_hex_byte(data);
|
print_hex_byte(data);
|
||||||
|
|
@ -129,7 +123,7 @@ void dcode_3()
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
print_mem(address, count, 1);
|
print_mem(address, count, 1);
|
||||||
/* while (count)
|
/* while (count)
|
||||||
{
|
{
|
||||||
print_hex_word(address);
|
print_hex_word(address);
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
|
|
@ -241,7 +235,7 @@ void dcode_2()
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
print_mem(address, count, 0);
|
print_mem(address, count, 0);
|
||||||
/* while (count)
|
/* while (count)
|
||||||
{
|
{
|
||||||
print_hex_word(address);
|
print_hex_word(address);
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
|
|
@ -361,7 +355,7 @@ void dcode_6()
|
||||||
void dcode_7()
|
void dcode_7()
|
||||||
{
|
{
|
||||||
LOG("D7 - Read/Write Bootloader\n");
|
LOG("D7 - Read/Write Bootloader\n");
|
||||||
/*
|
/*
|
||||||
cli();
|
cli();
|
||||||
boot_app_magic = 0x55aa55aa;
|
boot_app_magic = 0x55aa55aa;
|
||||||
boot_app_flags = BOOT_APP_FLG_ERASE | BOOT_APP_FLG_COPY | BOOT_APP_FLG_FLASH;
|
boot_app_flags = BOOT_APP_FLG_ERASE | BOOT_APP_FLG_COPY | BOOT_APP_FLG_FLASH;
|
||||||
|
|
@ -370,7 +364,7 @@ void dcode_7()
|
||||||
boot_dst_addr = (uint32_t)0x0003f400;
|
boot_dst_addr = (uint32_t)0x0003f400;
|
||||||
wdt_enable(WDTO_15MS);
|
wdt_enable(WDTO_15MS);
|
||||||
while(1);
|
while(1);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcode_8()
|
void dcode_8()
|
||||||
|
|
@ -418,20 +412,13 @@ const char* dcode_9_ADC_name(uint8_t i)
|
||||||
{
|
{
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0: return PSTR("TEMP_HEATER0");
|
||||||
return PSTR("TEMP_HEATER0");
|
case 1: return PSTR("TEMP_HEATER1");
|
||||||
case 1:
|
case 2: return PSTR("TEMP_BED");
|
||||||
return PSTR("TEMP_HEATER1");
|
case 3: return PSTR("TEMP_PINDA");
|
||||||
case 2:
|
case 4: return PSTR("VOLT_PWR");
|
||||||
return PSTR("TEMP_BED");
|
case 5: return PSTR("TEMP_AMBIENT");
|
||||||
case 3:
|
case 6: return PSTR("VOLT_BED");
|
||||||
return PSTR("TEMP_PINDA");
|
|
||||||
case 4:
|
|
||||||
return PSTR("VOLT_PWR");
|
|
||||||
case 5:
|
|
||||||
return PSTR("TEMP_AMBIENT");
|
|
||||||
case 6:
|
|
||||||
return PSTR("VOLT_BED");
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -456,25 +443,18 @@ uint16_t dcode_9_ADC_val(uint8_t i)
|
||||||
{
|
{
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0: return current_temperature_raw[0];
|
||||||
return current_temperature_raw[0];
|
case 1: return 0;
|
||||||
case 1:
|
case 2: return current_temperature_bed_raw;
|
||||||
return 0;
|
case 3: return current_temperature_raw_pinda;
|
||||||
case 2:
|
|
||||||
return current_temperature_bed_raw;
|
|
||||||
case 3:
|
|
||||||
return current_temperature_raw_pinda;
|
|
||||||
#ifdef VOLT_PWR_PIN
|
#ifdef VOLT_PWR_PIN
|
||||||
case 4:
|
case 4: return current_voltage_raw_pwr;
|
||||||
return current_voltage_raw_pwr;
|
|
||||||
#endif //VOLT_PWR_PIN
|
#endif //VOLT_PWR_PIN
|
||||||
#ifdef AMBIENT_THERMISTOR
|
#ifdef AMBIENT_THERMISTOR
|
||||||
case 5:
|
case 5: return current_temperature_raw_ambient;
|
||||||
return current_temperature_raw_ambient;
|
|
||||||
#endif //AMBIENT_THERMISTOR
|
#endif //AMBIENT_THERMISTOR
|
||||||
#ifdef VOLT_BED_PIN
|
#ifdef VOLT_BED_PIN
|
||||||
case 6:
|
case 6: return current_voltage_raw_bed;
|
||||||
return current_voltage_raw_bed;
|
|
||||||
#endif //VOLT_BED_PIN
|
#endif //VOLT_BED_PIN
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -506,13 +486,13 @@ void dcode_9()
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcode_10()
|
void dcode_10()
|
||||||
{ //Tell the printer that XYZ calibration went OK
|
{//Tell the printer that XYZ calibration went OK
|
||||||
LOG("D10 - XYZ calibration = OK\n");
|
LOG("D10 - XYZ calibration = OK\n");
|
||||||
calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST);
|
calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcode_12()
|
void dcode_12()
|
||||||
{ //Time
|
{//Time
|
||||||
LOG("D12 - Time\n");
|
LOG("D12 - Time\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -560,28 +540,16 @@ void dcode_2130()
|
||||||
uint8_t axis = 0xff;
|
uint8_t axis = 0xff;
|
||||||
switch (strchr_pointer[1+4])
|
switch (strchr_pointer[1+4])
|
||||||
{
|
{
|
||||||
case 'X':
|
case 'X': axis = X_AXIS; break;
|
||||||
axis = X_AXIS;
|
case 'Y': axis = Y_AXIS; break;
|
||||||
break;
|
case 'Z': axis = Z_AXIS; break;
|
||||||
case 'Y':
|
case 'E': axis = E_AXIS; break;
|
||||||
axis = Y_AXIS;
|
|
||||||
break;
|
|
||||||
case 'Z':
|
|
||||||
axis = Z_AXIS;
|
|
||||||
break;
|
|
||||||
case 'E':
|
|
||||||
axis = E_AXIS;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (axis != 0xff)
|
if (axis != 0xff)
|
||||||
{
|
{
|
||||||
char ch_axis = strchr_pointer[1+4];
|
char ch_axis = strchr_pointer[1+4];
|
||||||
if (strchr_pointer[1+5] == '0') {
|
if (strchr_pointer[1+5] == '0') { tmc2130_set_pwr(axis, 0); }
|
||||||
tmc2130_set_pwr(axis, 0);
|
else if (strchr_pointer[1+5] == '1') { tmc2130_set_pwr(axis, 1); }
|
||||||
}
|
|
||||||
else if (strchr_pointer[1+5] == '1') {
|
|
||||||
tmc2130_set_pwr(axis, 1);
|
|
||||||
}
|
|
||||||
else if (strchr_pointer[1+5] == '+')
|
else if (strchr_pointer[1+5] == '+')
|
||||||
{
|
{
|
||||||
if (strchr_pointer[1+6] == 0)
|
if (strchr_pointer[1+6] == 0)
|
||||||
|
|
@ -683,13 +651,13 @@ void dcode_9125()
|
||||||
printf("x=%d y=%d b=%d s=%d\n", pat9125_x, pat9125_y, pat9125_b, pat9125_s);
|
printf("x=%d y=%d b=%d s=%d\n", pat9125_x, pat9125_y, pat9125_b, pat9125_s);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if (code_seen('R'))
|
if (code_seen('R'))
|
||||||
{
|
{
|
||||||
unsigned char res = (int)code_value();
|
unsigned char res = (int)code_value();
|
||||||
LOG("pat9125_init(xres=yres=%d)=%d\n", res, pat9125_init(res, res));
|
LOG("pat9125_init(xres=yres=%d)=%d\n", res, pat9125_init(res, res));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (code_seen('X'))
|
if (code_seen('X'))
|
||||||
{
|
{
|
||||||
pat9125_x = (int)code_value();
|
pat9125_x = (int)code_value();
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -54,13 +54,13 @@
|
||||||
//#include "WString.h"
|
//#include "WString.h"
|
||||||
|
|
||||||
#ifdef AT90USB
|
#ifdef AT90USB
|
||||||
#ifdef BTENABLED
|
#ifdef BTENABLED
|
||||||
#define MYSERIAL bt
|
#define MYSERIAL bt
|
||||||
|
#else
|
||||||
|
#define MYSERIAL Serial
|
||||||
|
#endif // BTENABLED
|
||||||
#else
|
#else
|
||||||
#define MYSERIAL Serial
|
#define MYSERIAL MSerial
|
||||||
#endif // BTENABLED
|
|
||||||
#else
|
|
||||||
#define MYSERIAL MSerial
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
|
|
@ -129,47 +129,47 @@ void ramming();
|
||||||
void manage_inactivity(bool ignore_stepper_queue=false);
|
void manage_inactivity(bool ignore_stepper_queue=false);
|
||||||
|
|
||||||
#if defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1
|
#if defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1
|
||||||
#define enable_x() WRITE(X_ENABLE_PIN, X_ENABLE_ON)
|
#define enable_x() WRITE(X_ENABLE_PIN, X_ENABLE_ON)
|
||||||
#define disable_x() { WRITE(X_ENABLE_PIN,!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }
|
#define disable_x() { WRITE(X_ENABLE_PIN,!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }
|
||||||
#else
|
#else
|
||||||
#define enable_x() ;
|
#define enable_x() ;
|
||||||
#define disable_x() ;
|
#define disable_x() ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
|
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
|
||||||
#ifdef Y_DUAL_STEPPER_DRIVERS
|
#ifdef Y_DUAL_STEPPER_DRIVERS
|
||||||
#define enable_y() { WRITE(Y_ENABLE_PIN, Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, Y_ENABLE_ON); }
|
#define enable_y() { WRITE(Y_ENABLE_PIN, Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, Y_ENABLE_ON); }
|
||||||
#define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, !Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
|
#define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, !Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
|
||||||
|
#else
|
||||||
|
#define enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
|
||||||
|
#define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
|
#define enable_y() ;
|
||||||
#define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
|
#define disable_y() ;
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define enable_y() ;
|
|
||||||
#define disable_y() ;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
|
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
|
||||||
#if defined(Z_AXIS_ALWAYS_ON)
|
#if defined(Z_AXIS_ALWAYS_ON)
|
||||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||||
#define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
|
#define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
|
||||||
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
|
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
|
||||||
|
#else
|
||||||
|
#define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
|
||||||
|
#define disable_z() {}
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||||
|
#define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
|
||||||
|
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
|
||||||
|
#else
|
||||||
|
#define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
|
||||||
|
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
|
#define enable_z() {}
|
||||||
#define disable_z() {}
|
#define disable_z() {}
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
|
||||||
#define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
|
|
||||||
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
|
|
||||||
#else
|
|
||||||
#define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
|
|
||||||
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define enable_z() {}
|
|
||||||
#define disable_z() {}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -190,27 +190,27 @@ void manage_inactivity(bool ignore_stepper_queue=false);
|
||||||
|
|
||||||
|
|
||||||
#if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
|
#if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
|
||||||
#define enable_e0() WRITE(E0_ENABLE_PIN, E_ENABLE_ON)
|
#define enable_e0() WRITE(E0_ENABLE_PIN, E_ENABLE_ON)
|
||||||
#define disable_e0() WRITE(E0_ENABLE_PIN,!E_ENABLE_ON)
|
#define disable_e0() WRITE(E0_ENABLE_PIN,!E_ENABLE_ON)
|
||||||
#else
|
#else
|
||||||
#define enable_e0() /* nothing */
|
#define enable_e0() /* nothing */
|
||||||
#define disable_e0() /* nothing */
|
#define disable_e0() /* nothing */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (EXTRUDERS > 1) && defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
|
#if (EXTRUDERS > 1) && defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
|
||||||
#define enable_e1() WRITE(E1_ENABLE_PIN, E_ENABLE_ON)
|
#define enable_e1() WRITE(E1_ENABLE_PIN, E_ENABLE_ON)
|
||||||
#define disable_e1() WRITE(E1_ENABLE_PIN,!E_ENABLE_ON)
|
#define disable_e1() WRITE(E1_ENABLE_PIN,!E_ENABLE_ON)
|
||||||
#else
|
#else
|
||||||
#define enable_e1() /* nothing */
|
#define enable_e1() /* nothing */
|
||||||
#define disable_e1() /* nothing */
|
#define disable_e1() /* nothing */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (EXTRUDERS > 2) && defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
|
#if (EXTRUDERS > 2) && defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
|
||||||
#define enable_e2() WRITE(E2_ENABLE_PIN, E_ENABLE_ON)
|
#define enable_e2() WRITE(E2_ENABLE_PIN, E_ENABLE_ON)
|
||||||
#define disable_e2() WRITE(E2_ENABLE_PIN,!E_ENABLE_ON)
|
#define disable_e2() WRITE(E2_ENABLE_PIN,!E_ENABLE_ON)
|
||||||
#else
|
#else
|
||||||
#define enable_e2() /* nothing */
|
#define enable_e2() /* nothing */
|
||||||
#define disable_e2() /* nothing */
|
#define disable_e2() /* nothing */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -262,17 +262,15 @@ void refresh_cmd_timeout(void);
|
||||||
extern volatile unsigned long timer0_millis;
|
extern volatile unsigned long timer0_millis;
|
||||||
// An unsynchronized equivalent to a standard Arduino millis() function.
|
// An unsynchronized equivalent to a standard Arduino millis() function.
|
||||||
// To be used inside an interrupt routine.
|
// To be used inside an interrupt routine.
|
||||||
FORCE_INLINE unsigned long millis_nc() {
|
FORCE_INLINE unsigned long millis_nc() { return timer0_millis; }
|
||||||
return timer0_millis;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef FAST_PWM_FAN
|
#ifdef FAST_PWM_FAN
|
||||||
void setPwmFrequency(uint8_t pin, int val);
|
void setPwmFrequency(uint8_t pin, int val);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CRITICAL_SECTION_START
|
#ifndef CRITICAL_SECTION_START
|
||||||
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
|
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
|
||||||
#define CRITICAL_SECTION_END SREG = _sreg;
|
#define CRITICAL_SECTION_END SREG = _sreg;
|
||||||
#endif //CRITICAL_SECTION_START
|
#endif //CRITICAL_SECTION_START
|
||||||
|
|
||||||
extern float homing_feedrate[];
|
extern float homing_feedrate[];
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ uint8_t selectedSerialPort = 0;
|
||||||
#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
|
#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
|
||||||
|
|
||||||
#if UART_PRESENT(SERIAL_PORT)
|
#if UART_PRESENT(SERIAL_PORT)
|
||||||
ring_buffer rx_buffer = { { 0 }, 0, 0 };
|
ring_buffer rx_buffer = { { 0 }, 0, 0 };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FORCE_INLINE void store_char(unsigned char c)
|
FORCE_INLINE void store_char(unsigned char c)
|
||||||
|
|
@ -380,6 +380,6 @@ MarlinSerial MSerial;
|
||||||
|
|
||||||
// For AT90USB targets use the UART for BT interfacing
|
// For AT90USB targets use the UART for BT interfacing
|
||||||
#if defined(AT90USB) && defined (BTENABLED)
|
#if defined(AT90USB) && defined (BTENABLED)
|
||||||
HardwareSerial bt;
|
HardwareSerial bt;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,13 +83,13 @@ struct ring_buffer
|
||||||
};
|
};
|
||||||
|
|
||||||
#if UART_PRESENT(SERIAL_PORT)
|
#if UART_PRESENT(SERIAL_PORT)
|
||||||
extern ring_buffer rx_buffer;
|
extern ring_buffer rx_buffer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class MarlinSerial //: public Stream
|
class MarlinSerial //: public Stream
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void begin(long);
|
static void begin(long);
|
||||||
static void end();
|
static void end();
|
||||||
static int peek(void);
|
static int peek(void);
|
||||||
|
|
@ -177,12 +177,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void printNumber(unsigned long, uint8_t);
|
static void printNumber(unsigned long, uint8_t);
|
||||||
static void printFloat(double, uint8_t);
|
static void printFloat(double, uint8_t);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static FORCE_INLINE void write(const char *str)
|
static FORCE_INLINE void write(const char *str)
|
||||||
{
|
{
|
||||||
|
|
@ -197,7 +197,7 @@ public:
|
||||||
write(*buffer++);
|
write(*buffer++);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static FORCE_INLINE void print(const String &s)
|
/* static FORCE_INLINE void print(const String &s)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < (int)s.length(); i++) {
|
for (int i = 0; i < (int)s.length(); i++) {
|
||||||
write(s[i]);
|
write(s[i]);
|
||||||
|
|
@ -233,7 +233,7 @@ extern MarlinSerial MSerial;
|
||||||
|
|
||||||
// Use the UART for BT in AT90USB configurations
|
// Use the UART for BT in AT90USB configurations
|
||||||
#if defined(AT90USB) && defined (BTENABLED)
|
#if defined(AT90USB) && defined (BTENABLED)
|
||||||
extern HardwareSerial bt;
|
extern HardwareSerial bt;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -68,7 +68,7 @@ static void spiSend(uint8_t b) {
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/** SPI send block - only one call so force inline */
|
/** SPI send block - only one call so force inline */
|
||||||
static inline __attribute__((always_inline))
|
static inline __attribute__((always_inline))
|
||||||
void spiSendBlock(uint8_t token, const uint8_t* buf) {
|
void spiSendBlock(uint8_t token, const uint8_t* buf) {
|
||||||
SPDR = token;
|
SPDR = token;
|
||||||
for (uint16_t i = 0; i < 512; i += 2) {
|
for (uint16_t i = 0; i < 512; i += 2) {
|
||||||
while (!(SPSR & (1 << SPIF))) { /* Intentionally left empty */ }
|
while (!(SPSR & (1 << SPIF))) { /* Intentionally left empty */ }
|
||||||
|
|
@ -142,7 +142,7 @@ static void spiSend(uint8_t data) {
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/** Soft SPI send block */
|
/** Soft SPI send block */
|
||||||
void spiSendBlock(uint8_t token, const uint8_t* buf) {
|
void spiSendBlock(uint8_t token, const uint8_t* buf) {
|
||||||
spiSend(token);
|
spiSend(token);
|
||||||
for (uint16_t i = 0; i < 512; i++) {
|
for (uint16_t i = 0; i < 512; i++) {
|
||||||
spiSend(buf[i]);
|
spiSend(buf[i]);
|
||||||
|
|
@ -258,7 +258,7 @@ bool Sd2Card::erase(uint32_t firstBlock, uint32_t lastBlock) {
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -359,7 +359,7 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
|
||||||
return true;
|
return true;
|
||||||
#endif // SOFTWARE_SPI
|
#endif // SOFTWARE_SPI
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -377,7 +377,7 @@ bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t* dst) {
|
||||||
uint8_t retryCnt = 3;
|
uint8_t retryCnt = 3;
|
||||||
// use address if not SDHC card
|
// use address if not SDHC card
|
||||||
if (type()!= SD_CARD_TYPE_SDHC) blockNumber <<= 9;
|
if (type()!= SD_CARD_TYPE_SDHC) blockNumber <<= 9;
|
||||||
retry2:
|
retry2:
|
||||||
retryCnt --;
|
retryCnt --;
|
||||||
if (cardCommand(CMD17, blockNumber)) {
|
if (cardCommand(CMD17, blockNumber)) {
|
||||||
error(SD_CARD_ERROR_CMD17);
|
error(SD_CARD_ERROR_CMD17);
|
||||||
|
|
@ -390,7 +390,7 @@ retry2:
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
retry:
|
retry:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
cardCommand(CMD12, 0);//Try sending a stop command, but ignore the result.
|
cardCommand(CMD12, 0);//Try sending a stop command, but ignore the result.
|
||||||
errorCode_ = 0;
|
errorCode_ = 0;
|
||||||
|
|
@ -405,7 +405,7 @@ retry:
|
||||||
return readData(dst, 512);
|
return readData(dst, 512);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -505,7 +505,7 @@ bool Sd2Card::readData(uint8_t* dst, uint16_t count) {
|
||||||
spiSend(0XFF);
|
spiSend(0XFF);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
// Toshiba FlashAir Patch. Purge pending status byte.
|
// Toshiba FlashAir Patch. Purge pending status byte.
|
||||||
if (flash_air_compatible_)
|
if (flash_air_compatible_)
|
||||||
|
|
@ -522,7 +522,7 @@ bool Sd2Card::readRegister(uint8_t cmd, void* buf) {
|
||||||
}
|
}
|
||||||
return readData(dst, 16);
|
return readData(dst, 16);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -546,7 +546,7 @@ bool Sd2Card::readStart(uint32_t blockNumber) {
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -565,7 +565,7 @@ bool Sd2Card::readStop() {
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -599,7 +599,7 @@ bool Sd2Card::waitNotBusy(uint16_t timeoutMillis) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -633,7 +633,7 @@ bool Sd2Card::writeBlock(uint32_t blockNumber, const uint8_t* src) {
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -651,7 +651,7 @@ bool Sd2Card::writeData(const uint8_t* src) {
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
error(SD_CARD_ERROR_WRITE_MULTIPLE);
|
error(SD_CARD_ERROR_WRITE_MULTIPLE);
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -671,7 +671,7 @@ bool Sd2Card::writeData(uint8_t token, const uint8_t* src) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -702,7 +702,7 @@ bool Sd2Card::writeStart(uint32_t blockNumber, uint32_t eraseCount) {
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -720,7 +720,7 @@ bool Sd2Card::writeStop() {
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
error(SD_CARD_ERROR_STOP_TRAN);
|
error(SD_CARD_ERROR_STOP_TRAN);
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -744,7 +744,7 @@ uint8_t Sd2Card::waitStartBlock(void) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -782,7 +782,7 @@ uint8_t Sd2Card::readExt(uint32_t arg, uint8_t* dst, uint16_t count) {
|
||||||
spiSend(0xFF); // dummy clock to force FlashAir finish the command.
|
spiSend(0xFF); // dummy clock to force FlashAir finish the command.
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chipSelectHigh();
|
chipSelectHigh();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ uint8_t const SPI_SCK_PIN = SOFT_SPI_SCK_PIN;
|
||||||
* \brief Raw access to SD and SDHC flash memory cards.
|
* \brief Raw access to SD and SDHC flash memory cards.
|
||||||
*/
|
*/
|
||||||
class Sd2Card {
|
class Sd2Card {
|
||||||
public:
|
public:
|
||||||
/** Construct an instance of Sd2Card. */
|
/** Construct an instance of Sd2Card. */
|
||||||
Sd2Card() : errorCode_(SD_CARD_ERROR_INIT_NOT_CALLED), type_(0), flash_air_compatible_(false) {}
|
Sd2Card() : errorCode_(SD_CARD_ERROR_INIT_NOT_CALLED), type_(0), flash_air_compatible_(false) {}
|
||||||
uint32_t cardSize();
|
uint32_t cardSize();
|
||||||
|
|
@ -170,19 +170,13 @@ public:
|
||||||
* Set SD error code.
|
* Set SD error code.
|
||||||
* \param[in] code value for error code.
|
* \param[in] code value for error code.
|
||||||
*/
|
*/
|
||||||
void error(uint8_t code) {
|
void error(uint8_t code) {errorCode_ = code;}
|
||||||
errorCode_ = code;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* \return error code for last error. See Sd2Card.h for a list of error codes.
|
* \return error code for last error. See Sd2Card.h for a list of error codes.
|
||||||
*/
|
*/
|
||||||
int errorCode() const {
|
int errorCode() const {return errorCode_;}
|
||||||
return errorCode_;
|
|
||||||
}
|
|
||||||
/** \return error data for last error. */
|
/** \return error data for last error. */
|
||||||
int errorData() const {
|
int errorData() const {return status_;}
|
||||||
return status_;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Initialize an SD flash memory card with default clock rate and chip
|
* Initialize an SD flash memory card with default clock rate and chip
|
||||||
* select pin. See sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin).
|
* select pin. See sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin).
|
||||||
|
|
@ -222,9 +216,7 @@ public:
|
||||||
/** Return the card type: SD V1, SD V2 or SDHC
|
/** Return the card type: SD V1, SD V2 or SDHC
|
||||||
* \return 0 - SD V1, 1 - SD V2, or 3 - SDHC.
|
* \return 0 - SD V1, 1 - SD V2, or 3 - SDHC.
|
||||||
*/
|
*/
|
||||||
int type() const {
|
int type() const {return type_;}
|
||||||
return type_;
|
|
||||||
}
|
|
||||||
bool writeBlock(uint32_t blockNumber, const uint8_t* src);
|
bool writeBlock(uint32_t blockNumber, const uint8_t* src);
|
||||||
bool writeData(const uint8_t* src);
|
bool writeData(const uint8_t* src);
|
||||||
bool writeStart(uint32_t blockNumber, uint32_t eraseCount);
|
bool writeStart(uint32_t blockNumber, uint32_t eraseCount);
|
||||||
|
|
@ -233,14 +225,10 @@ public:
|
||||||
// Toshiba FlashAir support
|
// Toshiba FlashAir support
|
||||||
uint8_t readExtMemory(uint8_t mio, uint8_t func, uint32_t addr, uint16_t count, uint8_t* dst);
|
uint8_t readExtMemory(uint8_t mio, uint8_t func, uint32_t addr, uint16_t count, uint8_t* dst);
|
||||||
|
|
||||||
void setFlashAirCompatible(bool flashAirCompatible) {
|
void setFlashAirCompatible(bool flashAirCompatible) { flash_air_compatible_ = flashAirCompatible; }
|
||||||
flash_air_compatible_ = flashAirCompatible;
|
bool getFlashAirCompatible() const { return flash_air_compatible_; }
|
||||||
}
|
|
||||||
bool getFlashAirCompatible() const {
|
|
||||||
return flash_air_compatible_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
uint8_t chipSelectPin_;
|
uint8_t chipSelectPin_;
|
||||||
uint8_t errorCode_;
|
uint8_t errorCode_;
|
||||||
|
|
@ -259,9 +247,7 @@ private:
|
||||||
bool readRegister(uint8_t cmd, void* buf);
|
bool readRegister(uint8_t cmd, void* buf);
|
||||||
void chipSelectHigh();
|
void chipSelectHigh();
|
||||||
void chipSelectLow();
|
void chipSelectLow();
|
||||||
void type(uint8_t value) {
|
void type(uint8_t value) {type_ = value;}
|
||||||
type_ = value;
|
|
||||||
}
|
|
||||||
bool waitNotBusy(uint16_t timeoutMillis);
|
bool waitNotBusy(uint16_t timeoutMillis);
|
||||||
bool writeData(uint8_t token, const uint8_t* src);
|
bool writeData(uint8_t token, const uint8_t* src);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -320,10 +320,10 @@ static const pin_map_t digitalPinMap[] = {
|
||||||
static const uint8_t digitalPinCount = sizeof(digitalPinMap)/sizeof(pin_map_t);
|
static const uint8_t digitalPinCount = sizeof(digitalPinMap)/sizeof(pin_map_t);
|
||||||
|
|
||||||
uint8_t badPinNumber(void)
|
uint8_t badPinNumber(void)
|
||||||
__attribute__((error("Pin number is too large or not a constant")));
|
__attribute__((error("Pin number is too large or not a constant")));
|
||||||
|
|
||||||
static inline __attribute__((always_inline))
|
static inline __attribute__((always_inline))
|
||||||
bool getPinMode(uint8_t pin) {
|
bool getPinMode(uint8_t pin) {
|
||||||
if (__builtin_constant_p(pin) && pin < digitalPinCount) {
|
if (__builtin_constant_p(pin) && pin < digitalPinCount) {
|
||||||
return (*digitalPinMap[pin].ddr >> digitalPinMap[pin].bit) & 1;
|
return (*digitalPinMap[pin].ddr >> digitalPinMap[pin].bit) & 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -331,7 +331,7 @@ bool getPinMode(uint8_t pin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static inline __attribute__((always_inline))
|
static inline __attribute__((always_inline))
|
||||||
void setPinMode(uint8_t pin, uint8_t mode) {
|
void setPinMode(uint8_t pin, uint8_t mode) {
|
||||||
if (__builtin_constant_p(pin) && pin < digitalPinCount) {
|
if (__builtin_constant_p(pin) && pin < digitalPinCount) {
|
||||||
if (mode) {
|
if (mode) {
|
||||||
*digitalPinMap[pin].ddr |= 1 << digitalPinMap[pin].bit;
|
*digitalPinMap[pin].ddr |= 1 << digitalPinMap[pin].bit;
|
||||||
|
|
@ -343,7 +343,7 @@ void setPinMode(uint8_t pin, uint8_t mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static inline __attribute__((always_inline))
|
static inline __attribute__((always_inline))
|
||||||
bool fastDigitalRead(uint8_t pin) {
|
bool fastDigitalRead(uint8_t pin) {
|
||||||
if (__builtin_constant_p(pin) && pin < digitalPinCount) {
|
if (__builtin_constant_p(pin) && pin < digitalPinCount) {
|
||||||
return (*digitalPinMap[pin].pin >> digitalPinMap[pin].bit) & 1;
|
return (*digitalPinMap[pin].pin >> digitalPinMap[pin].bit) & 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -351,7 +351,7 @@ bool fastDigitalRead(uint8_t pin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static inline __attribute__((always_inline))
|
static inline __attribute__((always_inline))
|
||||||
void fastDigitalWrite(uint8_t pin, uint8_t value) {
|
void fastDigitalWrite(uint8_t pin, uint8_t value) {
|
||||||
if (__builtin_constant_p(pin) && pin < digitalPinCount) {
|
if (__builtin_constant_p(pin) && pin < digitalPinCount) {
|
||||||
if (value) {
|
if (value) {
|
||||||
*digitalPinMap[pin].port |= 1 << digitalPinMap[pin].bit;
|
*digitalPinMap[pin].port |= 1 << digitalPinMap[pin].bit;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ bool SdBaseFile::addCluster() {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -69,7 +69,7 @@ bool SdBaseFile::addDirCluster() {
|
||||||
fileSize_ += 512UL << vol_->clusterSizeShift_;
|
fileSize_ += 512UL << vol_->clusterSizeShift_;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -79,7 +79,7 @@ dir_t* SdBaseFile::cacheDirEntry(uint8_t action) {
|
||||||
if (!vol_->cacheRawBlock(dirBlock_, action)) goto fail;
|
if (!vol_->cacheRawBlock(dirBlock_, action)) goto fail;
|
||||||
return vol_->cache()->dir + dirIndex_;
|
return vol_->cache()->dir + dirIndex_;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -125,7 +125,7 @@ bool SdBaseFile::contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -168,7 +168,7 @@ bool SdBaseFile::createContiguous(SdBaseFile* dirFile,
|
||||||
|
|
||||||
return sync();
|
return sync();
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -192,7 +192,7 @@ bool SdBaseFile::dirEntry(dir_t* dir) {
|
||||||
memcpy(dir, p, sizeof(dir_t));
|
memcpy(dir, p, sizeof(dir_t));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -407,7 +407,7 @@ bool SdBaseFile::make83Name(const char* str, uint8_t* name, const char** ptr) {
|
||||||
// must have a file name, extension is optional
|
// must have a file name, extension is optional
|
||||||
return name[0] != ' ';
|
return name[0] != ' ';
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -455,7 +455,7 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const char* path, bool pFlag) {
|
||||||
}
|
}
|
||||||
return mkdir(parent, dname);
|
return mkdir(parent, dname);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -513,11 +513,11 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) {
|
||||||
// write first block
|
// write first block
|
||||||
return vol_->cacheFlush();
|
return vol_->cacheFlush();
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/** Open a file in the current working directory.
|
/** Open a file in the current working directory.
|
||||||
*
|
*
|
||||||
* \param[in] path A path with a valid 8.3 DOS name for a file to be opened.
|
* \param[in] path A path with a valid 8.3 DOS name for a file to be opened.
|
||||||
*
|
*
|
||||||
|
|
@ -527,9 +527,9 @@ fail:
|
||||||
* \return The value one, true, is returned for success and
|
* \return The value one, true, is returned for success and
|
||||||
* the value zero, false, is returned for failure.
|
* the value zero, false, is returned for failure.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::open(const char* path, uint8_t oflag) {
|
bool SdBaseFile::open(const char* path, uint8_t oflag) {
|
||||||
return open(cwd_, path, oflag);
|
return open(cwd_, path, oflag);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/** Open a file or directory by name.
|
/** Open a file or directory by name.
|
||||||
*
|
*
|
||||||
|
|
@ -610,7 +610,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const char* path, uint8_t oflag) {
|
||||||
}
|
}
|
||||||
return open(parent, dname, oflag);
|
return open(parent, dname, oflag);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -689,7 +689,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile,
|
||||||
// open entry in cache
|
// open entry in cache
|
||||||
return openCachedEntry(index, oflag);
|
return openCachedEntry(index, oflag);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -732,7 +732,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) {
|
||||||
// open cached entry
|
// open cached entry
|
||||||
return openCachedEntry(index & 0XF, oflag);
|
return openCachedEntry(index & 0XF, oflag);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -772,7 +772,7 @@ bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) {
|
||||||
if ((oflag & O_TRUNC) && !truncate(0)) return false;
|
if ((oflag & O_TRUNC) && !truncate(0)) return false;
|
||||||
return oflag & O_AT_END ? seekEnd(0) : true;
|
return oflag & O_AT_END ? seekEnd(0) : true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
type_ = FAT_FILE_TYPE_CLOSED;
|
type_ = FAT_FILE_TYPE_CLOSED;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -819,7 +819,7 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -874,7 +874,7 @@ bool SdBaseFile::openParent(SdBaseFile* dir) {
|
||||||
// open parent
|
// open parent
|
||||||
return open(&file, file.curPosition()/32 - 1, O_READ);
|
return open(&file, file.curPosition()/32 - 1, O_READ);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -916,7 +916,7 @@ bool SdBaseFile::openRoot(SdVolume* vol) {
|
||||||
dirIndex_ = 0;
|
dirIndex_ = 0;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -1094,7 +1094,7 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) {
|
||||||
}
|
}
|
||||||
return nbyte;
|
return nbyte;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -1178,7 +1178,7 @@ dir_t* SdBaseFile::readDirCache() {
|
||||||
// return pointer to entry
|
// return pointer to entry
|
||||||
return vol_->cache()->dir + i;
|
return vol_->cache()->dir + i;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -1214,7 +1214,7 @@ bool SdBaseFile::remove() {
|
||||||
return vol_->cacheFlush();
|
return vol_->cacheFlush();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -1240,7 +1240,7 @@ bool SdBaseFile::remove(SdBaseFile* dirFile, const char* path) {
|
||||||
if (!file.open(dirFile, path, O_WRITE)) goto fail;
|
if (!file.open(dirFile, path, O_WRITE)) goto fail;
|
||||||
return file.remove();
|
return file.remove();
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
// can't set iostate - static function
|
// can't set iostate - static function
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1322,14 +1322,14 @@ bool SdBaseFile::rename(SdBaseFile* dirFile, const char* newPath) {
|
||||||
}
|
}
|
||||||
return vol_->cacheFlush();
|
return vol_->cacheFlush();
|
||||||
|
|
||||||
restore:
|
restore:
|
||||||
d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
||||||
if (!d) goto fail;
|
if (!d) goto fail;
|
||||||
// restore entry
|
// restore entry
|
||||||
d->name[0] = entry.name[0];
|
d->name[0] = entry.name[0];
|
||||||
vol_->cacheFlush();
|
vol_->cacheFlush();
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -1370,7 +1370,7 @@ bool SdBaseFile::rmdir() {
|
||||||
flags_ |= O_WRITE;
|
flags_ |= O_WRITE;
|
||||||
return remove();
|
return remove();
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -1429,7 +1429,7 @@ bool SdBaseFile::rmRfStar() {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -1485,10 +1485,10 @@ bool SdBaseFile::seekSet(uint32_t pos) {
|
||||||
}
|
}
|
||||||
curPosition_ = pos;
|
curPosition_ = pos;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -1531,7 +1531,7 @@ bool SdBaseFile::sync() {
|
||||||
}
|
}
|
||||||
return vol_->cacheFlush();
|
return vol_->cacheFlush();
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
writeError = true;
|
writeError = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1571,7 +1571,7 @@ bool SdBaseFile::timestamp(SdBaseFile* file) {
|
||||||
// write back entry
|
// write back entry
|
||||||
return vol_->cacheFlush();
|
return vol_->cacheFlush();
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -1649,7 +1649,7 @@ bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month,
|
||||||
}
|
}
|
||||||
return vol_->cacheFlush();
|
return vol_->cacheFlush();
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -1707,7 +1707,7 @@ bool SdBaseFile::truncate(uint32_t length) {
|
||||||
// set file to correct position
|
// set file to correct position
|
||||||
return seekSet(newPos);
|
return seekSet(newPos);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -1810,7 +1810,7 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
|
||||||
}
|
}
|
||||||
return nbyte;
|
return nbyte;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
// return for write error
|
// return for write error
|
||||||
writeError = true;
|
writeError = true;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -180,13 +180,11 @@ uint16_t const FAT_DEFAULT_TIME = (1 << 11);
|
||||||
* \brief Base class for SdFile with Print and C++ streams.
|
* \brief Base class for SdFile with Print and C++ streams.
|
||||||
*/
|
*/
|
||||||
class SdBaseFile {
|
class SdBaseFile {
|
||||||
public:
|
public:
|
||||||
/** Create an instance. */
|
/** Create an instance. */
|
||||||
SdBaseFile() : writeError(false), type_(FAT_FILE_TYPE_CLOSED) {}
|
SdBaseFile() : writeError(false), type_(FAT_FILE_TYPE_CLOSED) {}
|
||||||
SdBaseFile(const char* path, uint8_t oflag);
|
SdBaseFile(const char* path, uint8_t oflag);
|
||||||
~SdBaseFile() {
|
~SdBaseFile() {if(isOpen()) close();}
|
||||||
if(isOpen()) close();
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* writeError is set to true if an error occurs during a write().
|
* writeError is set to true if an error occurs during a write().
|
||||||
* Set writeError to false before calling print() and/or write() and check
|
* Set writeError to false before calling print() and/or write() and check
|
||||||
|
|
@ -209,17 +207,11 @@ public:
|
||||||
bool createContiguous(SdBaseFile* dirFile,
|
bool createContiguous(SdBaseFile* dirFile,
|
||||||
const char* path, uint32_t size);
|
const char* path, uint32_t size);
|
||||||
/** \return The current cluster number for a file or directory. */
|
/** \return The current cluster number for a file or directory. */
|
||||||
uint32_t curCluster() const {
|
uint32_t curCluster() const {return curCluster_;}
|
||||||
return curCluster_;
|
|
||||||
}
|
|
||||||
/** \return The current position for a file or directory. */
|
/** \return The current position for a file or directory. */
|
||||||
uint32_t curPosition() const {
|
uint32_t curPosition() const {return curPosition_;}
|
||||||
return curPosition_;
|
|
||||||
}
|
|
||||||
/** \return Current working directory */
|
/** \return Current working directory */
|
||||||
static SdBaseFile* cwd() {
|
static SdBaseFile* cwd() {return cwd_;}
|
||||||
return cwd_;
|
|
||||||
}
|
|
||||||
/** Set the date/time callback function
|
/** Set the date/time callback function
|
||||||
*
|
*
|
||||||
* \param[in] dateTime The user's call back function. The callback
|
* \param[in] dateTime The user's call back function. The callback
|
||||||
|
|
@ -252,38 +244,24 @@ public:
|
||||||
dateTime_ = dateTime;
|
dateTime_ = dateTime;
|
||||||
}
|
}
|
||||||
/** Cancel the date/time callback function. */
|
/** Cancel the date/time callback function. */
|
||||||
static void dateTimeCallbackCancel() {
|
static void dateTimeCallbackCancel() {dateTime_ = 0;}
|
||||||
dateTime_ = 0;
|
|
||||||
}
|
|
||||||
bool dirEntry(dir_t* dir);
|
bool dirEntry(dir_t* dir);
|
||||||
static void dirName(const dir_t& dir, char* name);
|
static void dirName(const dir_t& dir, char* name);
|
||||||
bool exists(const char* name);
|
bool exists(const char* name);
|
||||||
int16_t fgets(char* str, int16_t num, char* delim = 0);
|
int16_t fgets(char* str, int16_t num, char* delim = 0);
|
||||||
/** \return The total number of bytes in a file or directory. */
|
/** \return The total number of bytes in a file or directory. */
|
||||||
uint32_t fileSize() const {
|
uint32_t fileSize() const {return fileSize_;}
|
||||||
return fileSize_;
|
|
||||||
}
|
|
||||||
/** \return The first cluster number for a file or directory. */
|
/** \return The first cluster number for a file or directory. */
|
||||||
uint32_t firstCluster() const {
|
uint32_t firstCluster() const {return firstCluster_;}
|
||||||
return firstCluster_;
|
|
||||||
}
|
|
||||||
bool getFilename(char* name);
|
bool getFilename(char* name);
|
||||||
/** \return True if this is a directory else false. */
|
/** \return True if this is a directory else false. */
|
||||||
bool isDir() const {
|
bool isDir() const {return type_ >= FAT_FILE_TYPE_MIN_DIR;}
|
||||||
return type_ >= FAT_FILE_TYPE_MIN_DIR;
|
|
||||||
}
|
|
||||||
/** \return True if this is a normal file else false. */
|
/** \return True if this is a normal file else false. */
|
||||||
bool isFile() const {
|
bool isFile() const {return type_ == FAT_FILE_TYPE_NORMAL;}
|
||||||
return type_ == FAT_FILE_TYPE_NORMAL;
|
|
||||||
}
|
|
||||||
/** \return True if this is an open file/directory else false. */
|
/** \return True if this is an open file/directory else false. */
|
||||||
bool isOpen() const {
|
bool isOpen() const {return type_ != FAT_FILE_TYPE_CLOSED;}
|
||||||
return type_ != FAT_FILE_TYPE_CLOSED;
|
|
||||||
}
|
|
||||||
/** \return True if this is a subdirectory else false. */
|
/** \return True if this is a subdirectory else false. */
|
||||||
bool isSubDir() const {
|
bool isSubDir() const {return type_ == FAT_FILE_TYPE_SUBDIR;}
|
||||||
return type_ == FAT_FILE_TYPE_SUBDIR;
|
|
||||||
}
|
|
||||||
/** \return True if this is the root directory. */
|
/** \return True if this is the root directory. */
|
||||||
bool isRoot() const {
|
bool isRoot() const {
|
||||||
return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32;
|
return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32;
|
||||||
|
|
@ -309,15 +287,11 @@ public:
|
||||||
static bool remove(SdBaseFile* dirFile, const char* path);
|
static bool remove(SdBaseFile* dirFile, const char* path);
|
||||||
bool remove();
|
bool remove();
|
||||||
/** Set the file's current position to zero. */
|
/** Set the file's current position to zero. */
|
||||||
void rewind() {
|
void rewind() {seekSet(0);}
|
||||||
seekSet(0);
|
|
||||||
}
|
|
||||||
bool rename(SdBaseFile* dirFile, const char* newPath);
|
bool rename(SdBaseFile* dirFile, const char* newPath);
|
||||||
bool rmdir();
|
bool rmdir();
|
||||||
// for backward compatibility
|
// for backward compatibility
|
||||||
bool rmDir() {
|
bool rmDir() {return rmdir();}
|
||||||
return rmdir();
|
|
||||||
}
|
|
||||||
bool rmRfStar();
|
bool rmRfStar();
|
||||||
/** Set the files position to current position + \a pos. See seekSet().
|
/** Set the files position to current position + \a pos. See seekSet().
|
||||||
* \param[in] offset The new position in bytes from the current position.
|
* \param[in] offset The new position in bytes from the current position.
|
||||||
|
|
@ -330,9 +304,7 @@ public:
|
||||||
* \param[in] offset The new position in bytes from end-of-file.
|
* \param[in] offset The new position in bytes from end-of-file.
|
||||||
* \return true for success or false for failure.
|
* \return true for success or false for failure.
|
||||||
*/
|
*/
|
||||||
bool seekEnd(int32_t offset = 0) {
|
bool seekEnd(int32_t offset = 0) {return seekSet(fileSize_ + offset);}
|
||||||
return seekSet(fileSize_ + offset);
|
|
||||||
}
|
|
||||||
bool seekSet(uint32_t pos);
|
bool seekSet(uint32_t pos);
|
||||||
bool sync();
|
bool sync();
|
||||||
bool timestamp(SdBaseFile* file);
|
bool timestamp(SdBaseFile* file);
|
||||||
|
|
@ -343,17 +315,13 @@ public:
|
||||||
*
|
*
|
||||||
* \return The file or directory type.
|
* \return The file or directory type.
|
||||||
*/
|
*/
|
||||||
uint8_t type() const {
|
uint8_t type() const {return type_;}
|
||||||
return type_;
|
|
||||||
}
|
|
||||||
bool truncate(uint32_t size);
|
bool truncate(uint32_t size);
|
||||||
/** \return SdVolume that contains this file. */
|
/** \return SdVolume that contains this file. */
|
||||||
SdVolume* volume() const {
|
SdVolume* volume() const {return vol_;}
|
||||||
return vol_;
|
|
||||||
}
|
|
||||||
int16_t write(const void* buf, uint16_t nbyte);
|
int16_t write(const void* buf, uint16_t nbyte);
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
// allow SdFat to set cwd_
|
// allow SdFat to set cwd_
|
||||||
friend class SdFat;
|
friend class SdFat;
|
||||||
// global pointer to cwd dir
|
// global pointer to cwd dir
|
||||||
|
|
@ -397,7 +365,7 @@ private:
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Deprecated functions - suppress cpplint warnings with NOLINT comment
|
// Deprecated functions - suppress cpplint warnings with NOLINT comment
|
||||||
#if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN)
|
#if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN)
|
||||||
public:
|
public:
|
||||||
/** \deprecated Use:
|
/** \deprecated Use:
|
||||||
* bool contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock);
|
* bool contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock);
|
||||||
* \param[out] bgnBlock the first block address for the file.
|
* \param[out] bgnBlock the first block address for the file.
|
||||||
|
|
@ -433,9 +401,7 @@ public:
|
||||||
* \param[out] dir Location for return of the file's directory entry.
|
* \param[out] dir Location for return of the file's directory entry.
|
||||||
* \return true for success or false for failure.
|
* \return true for success or false for failure.
|
||||||
*/
|
*/
|
||||||
bool dirEntry(dir_t& dir) {
|
bool dirEntry(dir_t& dir) {return dirEntry(&dir);} // NOLINT
|
||||||
return dirEntry(&dir); // NOLINT
|
|
||||||
}
|
|
||||||
/** \deprecated Use:
|
/** \deprecated Use:
|
||||||
* bool mkdir(SdBaseFile* dir, const char* path);
|
* bool mkdir(SdBaseFile* dir, const char* path);
|
||||||
* \param[in] dir An open SdFat instance for the directory that will contain
|
* \param[in] dir An open SdFat instance for the directory that will contain
|
||||||
|
|
@ -484,16 +450,12 @@ public:
|
||||||
* \param[in] vol The FAT volume containing the root directory to be opened.
|
* \param[in] vol The FAT volume containing the root directory to be opened.
|
||||||
* \return true for success or false for failure.
|
* \return true for success or false for failure.
|
||||||
*/
|
*/
|
||||||
bool openRoot(SdVolume& vol) {
|
bool openRoot(SdVolume& vol) {return openRoot(&vol);} // NOLINT
|
||||||
return openRoot(&vol); // NOLINT
|
|
||||||
}
|
|
||||||
/** \deprecated Use: int8_t readDir(dir_t* dir);
|
/** \deprecated Use: int8_t readDir(dir_t* dir);
|
||||||
* \param[out] dir The dir_t struct that will receive the data.
|
* \param[out] dir The dir_t struct that will receive the data.
|
||||||
* \return bytes read for success zero for eof or -1 for failure.
|
* \return bytes read for success zero for eof or -1 for failure.
|
||||||
*/
|
*/
|
||||||
int8_t readDir(dir_t& dir, char* longFilename) {
|
int8_t readDir(dir_t& dir, char* longFilename) {return readDir(&dir, longFilename);} // NOLINT
|
||||||
return readDir(&dir, longFilename); // NOLINT
|
|
||||||
}
|
|
||||||
/** \deprecated Use:
|
/** \deprecated Use:
|
||||||
* static uint8_t remove(SdBaseFile* dirFile, const char* path);
|
* static uint8_t remove(SdBaseFile* dirFile, const char* path);
|
||||||
* \param[in] dirFile The directory that contains the file.
|
* \param[in] dirFile The directory that contains the file.
|
||||||
|
|
@ -505,7 +467,7 @@ public:
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// rest are private
|
// rest are private
|
||||||
private:
|
private:
|
||||||
static void (*oldDateTime_)(uint16_t& date, uint16_t& time); // NOLINT
|
static void (*oldDateTime_)(uint16_t& date, uint16_t& time); // NOLINT
|
||||||
static void oldToNew(uint16_t* date, uint16_t* time) {
|
static void oldToNew(uint16_t* date, uint16_t* time) {
|
||||||
uint16_t d;
|
uint16_t d;
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,14 @@
|
||||||
#define PgmPrintln(x) SerialPrintln_P(PSTR(x))
|
#define PgmPrintln(x) SerialPrintln_P(PSTR(x))
|
||||||
|
|
||||||
namespace SdFatUtil {
|
namespace SdFatUtil {
|
||||||
int FreeRam();
|
int FreeRam();
|
||||||
void print_P( PGM_P str);
|
void print_P( PGM_P str);
|
||||||
void println_P( PGM_P str);
|
void println_P( PGM_P str);
|
||||||
void SerialPrint_P(PGM_P str);
|
void SerialPrint_P(PGM_P str);
|
||||||
void SerialPrintln_P(PGM_P str);
|
void SerialPrintln_P(PGM_P str);
|
||||||
void set_stack_guard();
|
void set_stack_guard();
|
||||||
bool test_stack_integrity();
|
bool test_stack_integrity();
|
||||||
uint32_t get_stack_guard_test_value();
|
uint32_t get_stack_guard_test_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace SdFatUtil; // NOLINT
|
using namespace SdFatUtil; // NOLINT
|
||||||
|
|
|
||||||
|
|
@ -33,15 +33,15 @@
|
||||||
* \class SdFile
|
* \class SdFile
|
||||||
* \brief SdBaseFile with Print.
|
* \brief SdBaseFile with Print.
|
||||||
*/
|
*/
|
||||||
class SdFile : public SdBaseFile { /*, public Print*/
|
class SdFile : public SdBaseFile/*, public Print*/ {
|
||||||
public:
|
public:
|
||||||
SdFile() {}
|
SdFile() {}
|
||||||
SdFile(const char* name, uint8_t oflag);
|
SdFile(const char* name, uint8_t oflag);
|
||||||
#if ARDUINO >= 100
|
#if ARDUINO >= 100
|
||||||
size_t write(uint8_t b);
|
size_t write(uint8_t b);
|
||||||
#else
|
#else
|
||||||
void write(uint8_t b);
|
void write(uint8_t b);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int16_t write(const void* buf, uint16_t nbyte);
|
int16_t write(const void* buf, uint16_t nbyte);
|
||||||
void write(const char* str);
|
void write(const char* str);
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ typedef struct CID {
|
||||||
unsigned char always1 : 1;
|
unsigned char always1 : 1;
|
||||||
/** CRC7 checksum */
|
/** CRC7 checksum */
|
||||||
unsigned char crc : 7;
|
unsigned char crc : 7;
|
||||||
} cid_t;
|
}cid_t;
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/** CSD for version 1.00 cards */
|
/** CSD for version 1.00 cards */
|
||||||
typedef struct CSDV1 {
|
typedef struct CSDV1 {
|
||||||
|
|
@ -192,7 +192,7 @@ typedef struct CSDV1 {
|
||||||
// byte 15
|
// byte 15
|
||||||
unsigned char always1 : 1;
|
unsigned char always1 : 1;
|
||||||
unsigned char crc : 7;
|
unsigned char crc : 7;
|
||||||
} csd1_t;
|
}csd1_t;
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/** CSD for version 2.00 cards */
|
/** CSD for version 2.00 cards */
|
||||||
typedef struct CSDV2 {
|
typedef struct CSDV2 {
|
||||||
|
|
@ -274,7 +274,7 @@ typedef struct CSDV2 {
|
||||||
unsigned char always1 : 1;
|
unsigned char always1 : 1;
|
||||||
/** checksum */
|
/** checksum */
|
||||||
unsigned char crc : 7;
|
unsigned char crc : 7;
|
||||||
} csd2_t;
|
}csd2_t;
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/** union of old and new style CSD register */
|
/** union of old and new style CSD register */
|
||||||
union csd_t {
|
union csd_t {
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ bool SdVolume::allocContiguous(uint32_t count, uint32_t* curCluster) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -120,7 +120,7 @@ bool SdVolume::cacheFlush() {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -133,7 +133,7 @@ bool SdVolume::cacheRawBlock(uint32_t blockNumber, bool dirty) {
|
||||||
if (dirty) cacheDirty_ = true;
|
if (dirty) cacheDirty_ = true;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -147,7 +147,7 @@ bool SdVolume::chainSize(uint32_t cluster, uint32_t* size) {
|
||||||
*size = s;
|
*size = s;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -188,7 +188,7 @@ bool SdVolume::fatGet(uint32_t cluster, uint32_t* value) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -247,7 +247,7 @@ bool SdVolume::fatPut(uint32_t cluster, uint32_t value) {
|
||||||
if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_;
|
if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -269,7 +269,7 @@ bool SdVolume::freeChain(uint32_t cluster) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -399,7 +399,7 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -58,7 +58,7 @@ union cache_t {
|
||||||
* \brief Access FAT16 and FAT32 volumes on SD and SDHC cards.
|
* \brief Access FAT16 and FAT32 volumes on SD and SDHC cards.
|
||||||
*/
|
*/
|
||||||
class SdVolume {
|
class SdVolume {
|
||||||
public:
|
public:
|
||||||
/** Create an instance of SdVolume */
|
/** Create an instance of SdVolume */
|
||||||
SdVolume() : fatType_(0) {}
|
SdVolume() : fatType_(0) {}
|
||||||
/** Clear the cache and returns a pointer to the cache. Used by the WaveRP
|
/** Clear the cache and returns a pointer to the cache. Used by the WaveRP
|
||||||
|
|
@ -80,71 +80,45 @@ public:
|
||||||
* failure include not finding a valid partition, not finding a valid
|
* failure include not finding a valid partition, not finding a valid
|
||||||
* FAT file system or an I/O error.
|
* FAT file system or an I/O error.
|
||||||
*/
|
*/
|
||||||
bool init(Sd2Card* dev) {
|
bool init(Sd2Card* dev) { return init(dev, 1) ? true : init(dev, 0);}
|
||||||
return init(dev, 1) ? true : init(dev, 0);
|
|
||||||
}
|
|
||||||
bool init(Sd2Card* dev, uint8_t part);
|
bool init(Sd2Card* dev, uint8_t part);
|
||||||
|
|
||||||
// inline functions that return volume info
|
// inline functions that return volume info
|
||||||
/** \return The volume's cluster size in blocks. */
|
/** \return The volume's cluster size in blocks. */
|
||||||
uint8_t blocksPerCluster() const {
|
uint8_t blocksPerCluster() const {return blocksPerCluster_;}
|
||||||
return blocksPerCluster_;
|
|
||||||
}
|
|
||||||
/** \return The number of blocks in one FAT. */
|
/** \return The number of blocks in one FAT. */
|
||||||
uint32_t blocksPerFat() const {
|
uint32_t blocksPerFat() const {return blocksPerFat_;}
|
||||||
return blocksPerFat_;
|
|
||||||
}
|
|
||||||
/** \return The total number of clusters in the volume. */
|
/** \return The total number of clusters in the volume. */
|
||||||
uint32_t clusterCount() const {
|
uint32_t clusterCount() const {return clusterCount_;}
|
||||||
return clusterCount_;
|
|
||||||
}
|
|
||||||
/** \return The shift count required to multiply by blocksPerCluster. */
|
/** \return The shift count required to multiply by blocksPerCluster. */
|
||||||
uint8_t clusterSizeShift() const {
|
uint8_t clusterSizeShift() const {return clusterSizeShift_;}
|
||||||
return clusterSizeShift_;
|
|
||||||
}
|
|
||||||
/** \return The logical block number for the start of file data. */
|
/** \return The logical block number for the start of file data. */
|
||||||
uint32_t dataStartBlock() const {
|
uint32_t dataStartBlock() const {return dataStartBlock_;}
|
||||||
return dataStartBlock_;
|
|
||||||
}
|
|
||||||
/** \return The number of FAT structures on the volume. */
|
/** \return The number of FAT structures on the volume. */
|
||||||
uint8_t fatCount() const {
|
uint8_t fatCount() const {return fatCount_;}
|
||||||
return fatCount_;
|
|
||||||
}
|
|
||||||
/** \return The logical block number for the start of the first FAT. */
|
/** \return The logical block number for the start of the first FAT. */
|
||||||
uint32_t fatStartBlock() const {
|
uint32_t fatStartBlock() const {return fatStartBlock_;}
|
||||||
return fatStartBlock_;
|
|
||||||
}
|
|
||||||
/** \return The FAT type of the volume. Values are 12, 16 or 32. */
|
/** \return The FAT type of the volume. Values are 12, 16 or 32. */
|
||||||
uint8_t fatType() const {
|
uint8_t fatType() const {return fatType_;}
|
||||||
return fatType_;
|
|
||||||
}
|
|
||||||
int32_t freeClusterCount();
|
int32_t freeClusterCount();
|
||||||
/** \return The number of entries in the root directory for FAT16 volumes. */
|
/** \return The number of entries in the root directory for FAT16 volumes. */
|
||||||
uint32_t rootDirEntryCount() const {
|
uint32_t rootDirEntryCount() const {return rootDirEntryCount_;}
|
||||||
return rootDirEntryCount_;
|
|
||||||
}
|
|
||||||
/** \return The logical block number for the start of the root directory
|
/** \return The logical block number for the start of the root directory
|
||||||
on FAT16 volumes or the first cluster number on FAT32 volumes. */
|
on FAT16 volumes or the first cluster number on FAT32 volumes. */
|
||||||
uint32_t rootDirStart() const {
|
uint32_t rootDirStart() const {return rootDirStart_;}
|
||||||
return rootDirStart_;
|
|
||||||
}
|
|
||||||
/** Sd2Card object for this volume
|
/** Sd2Card object for this volume
|
||||||
* \return pointer to Sd2Card object.
|
* \return pointer to Sd2Card object.
|
||||||
*/
|
*/
|
||||||
Sd2Card* sdCard() {
|
Sd2Card* sdCard() {return sdCard_;}
|
||||||
return sdCard_;
|
|
||||||
}
|
|
||||||
/** Debug access to FAT table
|
/** Debug access to FAT table
|
||||||
*
|
*
|
||||||
* \param[in] n cluster number.
|
* \param[in] n cluster number.
|
||||||
* \param[out] v value of entry
|
* \param[out] v value of entry
|
||||||
* \return true for success or false for failure
|
* \return true for success or false for failure
|
||||||
*/
|
*/
|
||||||
bool dbgFat(uint32_t n, uint32_t* v) {
|
bool dbgFat(uint32_t n, uint32_t* v) {return fatGet(n, v);}
|
||||||
return fatGet(n, v);
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
// Allow SdBaseFile access to SdVolume private data.
|
// Allow SdBaseFile access to SdVolume private data.
|
||||||
friend class SdBaseFile;
|
friend class SdBaseFile;
|
||||||
|
|
||||||
|
|
@ -180,20 +154,13 @@ private:
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool allocContiguous(uint32_t count, uint32_t* curCluster);
|
bool allocContiguous(uint32_t count, uint32_t* curCluster);
|
||||||
uint8_t blockOfCluster(uint32_t position) const {
|
uint8_t blockOfCluster(uint32_t position) const {
|
||||||
return (position >> 9) & (blocksPerCluster_ - 1);
|
return (position >> 9) & (blocksPerCluster_ - 1);}
|
||||||
}
|
|
||||||
uint32_t clusterStartBlock(uint32_t cluster) const {
|
uint32_t clusterStartBlock(uint32_t cluster) const {
|
||||||
return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_);
|
return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_);}
|
||||||
}
|
|
||||||
uint32_t blockNumber(uint32_t cluster, uint32_t position) const {
|
uint32_t blockNumber(uint32_t cluster, uint32_t position) const {
|
||||||
return clusterStartBlock(cluster) + blockOfCluster(position);
|
return clusterStartBlock(cluster) + blockOfCluster(position);}
|
||||||
}
|
cache_t *cache() {return &cacheBuffer_;}
|
||||||
cache_t *cache() {
|
uint32_t cacheBlockNumber() {return cacheBlockNumber_;}
|
||||||
return &cacheBuffer_;
|
|
||||||
}
|
|
||||||
uint32_t cacheBlockNumber() {
|
|
||||||
return cacheBlockNumber_;
|
|
||||||
}
|
|
||||||
#if USE_MULTIPLE_CARDS
|
#if USE_MULTIPLE_CARDS
|
||||||
bool cacheFlush();
|
bool cacheFlush();
|
||||||
bool cacheRawBlock(uint32_t blockNumber, bool dirty);
|
bool cacheRawBlock(uint32_t blockNumber, bool dirty);
|
||||||
|
|
@ -206,9 +173,7 @@ private:
|
||||||
cacheDirty_ = dirty;
|
cacheDirty_ = dirty;
|
||||||
cacheBlockNumber_ = blockNumber;
|
cacheBlockNumber_ = blockNumber;
|
||||||
}
|
}
|
||||||
void cacheSetDirty() {
|
void cacheSetDirty() {cacheDirty_ |= CACHE_FOR_WRITE;}
|
||||||
cacheDirty_ |= CACHE_FOR_WRITE;
|
|
||||||
}
|
|
||||||
bool chainSize(uint32_t beginCluster, uint32_t* size);
|
bool chainSize(uint32_t beginCluster, uint32_t* size);
|
||||||
bool fatGet(uint32_t cluster, uint32_t* value);
|
bool fatGet(uint32_t cluster, uint32_t* value);
|
||||||
bool fatPut(uint32_t cluster, uint32_t value);
|
bool fatPut(uint32_t cluster, uint32_t value);
|
||||||
|
|
@ -222,22 +187,19 @@ private:
|
||||||
return cluster >= FAT32EOC_MIN;
|
return cluster >= FAT32EOC_MIN;
|
||||||
}
|
}
|
||||||
bool readBlock(uint32_t block, uint8_t* dst) {
|
bool readBlock(uint32_t block, uint8_t* dst) {
|
||||||
return sdCard_->readBlock(block, dst);
|
return sdCard_->readBlock(block, dst);}
|
||||||
}
|
|
||||||
bool writeBlock(uint32_t block, const uint8_t* dst) {
|
bool writeBlock(uint32_t block, const uint8_t* dst) {
|
||||||
return sdCard_->writeBlock(block, dst);
|
return sdCard_->writeBlock(block, dst);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Deprecated functions - suppress cpplint warnings with NOLINT comment
|
// Deprecated functions - suppress cpplint warnings with NOLINT comment
|
||||||
#if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN)
|
#if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN)
|
||||||
public:
|
public:
|
||||||
/** \deprecated Use: bool SdVolume::init(Sd2Card* dev);
|
/** \deprecated Use: bool SdVolume::init(Sd2Card* dev);
|
||||||
* \param[in] dev The SD card where the volume is located.
|
* \param[in] dev The SD card where the volume is located.
|
||||||
* \return true for success or false for failure.
|
* \return true for success or false for failure.
|
||||||
*/
|
*/
|
||||||
bool init(Sd2Card& dev) {
|
bool init(Sd2Card& dev) {return init(&dev);} // NOLINT
|
||||||
return init(&dev); // NOLINT
|
|
||||||
}
|
|
||||||
/** \deprecated Use: bool SdVolume::init(Sd2Card* dev, uint8_t vol);
|
/** \deprecated Use: bool SdVolume::init(Sd2Card* dev, uint8_t vol);
|
||||||
* \param[in] dev The SD card where the volume is located.
|
* \param[in] dev The SD card where the volume is located.
|
||||||
* \param[in] part The partition to be used.
|
* \param[in] part The partition to be used.
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
|
||||||
{
|
{
|
||||||
if( Channel[timer] < 0 )
|
if( Channel[timer] < 0 )
|
||||||
*TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer
|
*TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer
|
||||||
else {
|
else{
|
||||||
if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true )
|
if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true )
|
||||||
digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW); // pulse this channel low if activated
|
digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW); // pulse this channel low if activated
|
||||||
}
|
}
|
||||||
|
|
@ -211,19 +211,19 @@ static void finISR(timer16_Sequence_t timer)
|
||||||
//disable use of the given timer
|
//disable use of the given timer
|
||||||
#if defined WIRING // Wiring
|
#if defined WIRING // Wiring
|
||||||
if(timer == _timer1) {
|
if(timer == _timer1) {
|
||||||
#if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
|
#if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
|
||||||
TIMSK1 &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt
|
TIMSK1 &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt
|
||||||
#else
|
#else
|
||||||
TIMSK &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt
|
TIMSK &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt
|
||||||
#endif
|
#endif
|
||||||
timerDetach(TIMER1OUTCOMPAREA_INT);
|
timerDetach(TIMER1OUTCOMPAREA_INT);
|
||||||
}
|
}
|
||||||
else if(timer == _timer3) {
|
else if(timer == _timer3) {
|
||||||
#if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
|
#if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
|
||||||
TIMSK3 &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt
|
TIMSK3 &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt
|
||||||
#else
|
#else
|
||||||
ETIMSK &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt
|
ETIMSK &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt
|
||||||
#endif
|
#endif
|
||||||
timerDetach(TIMER3OUTCOMPAREA_INT);
|
timerDetach(TIMER3OUTCOMPAREA_INT);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
@ -263,8 +263,7 @@ uint8_t Servo::attach(int pin, int min, int max)
|
||||||
{
|
{
|
||||||
if(this->servoIndex < MAX_SERVOS ) {
|
if(this->servoIndex < MAX_SERVOS ) {
|
||||||
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
|
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
|
||||||
if (pin > 0) this->pin = pin;
|
if (pin > 0) this->pin = pin; else pin = this->pin;
|
||||||
else pin = this->pin;
|
|
||||||
#endif
|
#endif
|
||||||
pinMode( pin, OUTPUT) ; // set servo pin to output
|
pinMode( pin, OUTPUT) ; // set servo pin to output
|
||||||
servos[this->servoIndex].Pin.nbr = pin;
|
servos[this->servoIndex].Pin.nbr = pin;
|
||||||
|
|
|
||||||
|
|
@ -19,17 +19,11 @@ class Timer
|
||||||
public:
|
public:
|
||||||
Timer();
|
Timer();
|
||||||
void start();
|
void start();
|
||||||
void stop() {
|
void stop(){m_isRunning = false;}
|
||||||
m_isRunning = false;
|
bool running(){return m_isRunning;}
|
||||||
}
|
|
||||||
bool running() {
|
|
||||||
return m_isRunning;
|
|
||||||
}
|
|
||||||
bool expired(T msPeriod);
|
bool expired(T msPeriod);
|
||||||
protected:
|
protected:
|
||||||
T started() {
|
T started(){return m_started;}
|
||||||
return m_started;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
bool m_isRunning;
|
bool m_isRunning;
|
||||||
T m_started;
|
T m_started;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
class TimerRemaining : public LongTimer
|
class TimerRemaining : public LongTimer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TimerRemaining() : m_period() {}
|
TimerRemaining() : m_period(){}
|
||||||
void start() = delete;
|
void start() = delete;
|
||||||
bool expired(unsigned long msPeriod) = delete;
|
bool expired(unsigned long msPeriod) = delete;
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ uint16_t adc_sim_mask;
|
||||||
|
|
||||||
|
|
||||||
#ifdef ADC_CALLBACK
|
#ifdef ADC_CALLBACK
|
||||||
extern void ADC_CALLBACK(void);
|
extern void ADC_CALLBACK(void);
|
||||||
#endif //ADC_CALLBACK
|
#endif //ADC_CALLBACK
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -38,8 +38,7 @@ void adc_reset(void)
|
||||||
{
|
{
|
||||||
adc_state = 0;
|
adc_state = 0;
|
||||||
adc_count = 0;
|
adc_count = 0;
|
||||||
uint8_t i;
|
uint8_t i; for (i = 0; i < ADC_CHAN_CNT; i++)
|
||||||
for (i = 0; i < ADC_CHAN_CNT; i++)
|
|
||||||
if ((adc_sim_mask & (1 << i)) == 0)
|
if ((adc_sim_mask & (1 << i)) == 0)
|
||||||
adc_values[i] = 0;
|
adc_values[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size)
|
||||||
boot_app_magic = BOOT_APP_MAGIC;
|
boot_app_magic = BOOT_APP_MAGIC;
|
||||||
boot_app_flags |= BOOT_APP_FLG_COPY;
|
boot_app_flags |= BOOT_APP_FLG_COPY;
|
||||||
boot_app_flags |= BOOT_APP_FLG_ERASE;
|
boot_app_flags |= BOOT_APP_FLG_ERASE;
|
||||||
/* uint16_t ui; for (ui = 0; ui < size; ui++)
|
/* uint16_t ui; for (ui = 0; ui < size; ui++)
|
||||||
{
|
{
|
||||||
uint8_t uc = ram_array[ui+rptr];
|
uint8_t uc = ram_array[ui+rptr];
|
||||||
if (pgm_read_byte(ui+fptr) & uc != uc)
|
if (pgm_read_byte(ui+fptr) & uc != uc)
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,14 @@
|
||||||
CardReader::CardReader()
|
CardReader::CardReader()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
sort_count = 0;
|
sort_count = 0;
|
||||||
#if SDSORT_GCODE
|
#if SDSORT_GCODE
|
||||||
sort_alpha = true;
|
sort_alpha = true;
|
||||||
sort_folders = FOLDER_SORTING;
|
sort_folders = FOLDER_SORTING;
|
||||||
//sort_reverse = false;
|
//sort_reverse = false;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
filesize = 0;
|
filesize = 0;
|
||||||
sdpos = 0;
|
sdpos = 0;
|
||||||
|
|
@ -36,10 +36,10 @@ CardReader::CardReader()
|
||||||
autostart_stilltocheck=true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
|
autostart_stilltocheck=true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
|
||||||
lastnr=0;
|
lastnr=0;
|
||||||
//power to SD reader
|
//power to SD reader
|
||||||
#if SDPOWER > -1
|
#if SDPOWER > -1
|
||||||
SET_OUTPUT(SDPOWER);
|
SET_OUTPUT(SDPOWER);
|
||||||
WRITE(SDPOWER,HIGH);
|
WRITE(SDPOWER,HIGH);
|
||||||
#endif //SDPOWER
|
#endif //SDPOWER
|
||||||
|
|
||||||
autostart_atmillis=millis()+5000;
|
autostart_atmillis=millis()+5000;
|
||||||
}
|
}
|
||||||
|
|
@ -169,15 +169,15 @@ void CardReader::initsd()
|
||||||
root.close();
|
root.close();
|
||||||
#ifdef SDSLOW
|
#ifdef SDSLOW
|
||||||
if (!card.init(SPI_HALF_SPEED,SDSS)
|
if (!card.init(SPI_HALF_SPEED,SDSS)
|
||||||
#if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
|
#if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
|
||||||
&& !card.init(SPI_HALF_SPEED,LCD_SDSS)
|
&& !card.init(SPI_HALF_SPEED,LCD_SDSS)
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
#else
|
#else
|
||||||
if (!card.init(SPI_FULL_SPEED,SDSS)
|
if (!card.init(SPI_FULL_SPEED,SDSS)
|
||||||
#if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
|
#if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
|
||||||
&& !card.init(SPI_FULL_SPEED,LCD_SDSS)
|
&& !card.init(SPI_FULL_SPEED,LCD_SDSS)
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
@ -204,9 +204,9 @@ void CardReader::initsd()
|
||||||
workDir=root;
|
workDir=root;
|
||||||
curDir=&root;
|
curDir=&root;
|
||||||
|
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
presort();
|
presort();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if(!workDir.openRoot(&volume))
|
if(!workDir.openRoot(&volume))
|
||||||
|
|
@ -242,9 +242,9 @@ void CardReader::startFileprint()
|
||||||
{
|
{
|
||||||
sdprinting = true;
|
sdprinting = true;
|
||||||
paused = false;
|
paused = false;
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
//flush_presort();
|
//flush_presort();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -276,17 +276,12 @@ uint16_t CardReader::getWorkDirDepth() {
|
||||||
void CardReader::getAbsFilename(char *t)
|
void CardReader::getAbsFilename(char *t)
|
||||||
{
|
{
|
||||||
uint8_t cnt=0;
|
uint8_t cnt=0;
|
||||||
*t='/';
|
*t='/';t++;cnt++;
|
||||||
t++;
|
for(uint8_t i=0;i<workDirDepth;i++)
|
||||||
cnt++;
|
|
||||||
for(uint8_t i=0; i<workDirDepth; i++)
|
|
||||||
{
|
{
|
||||||
workDirParents[i].getFilename(t); //SDBaseFile.getfilename!
|
workDirParents[i].getFilename(t); //SDBaseFile.getfilename!
|
||||||
while(*t!=0 && cnt< MAXPATHNAMELENGTH)
|
while(*t!=0 && cnt< MAXPATHNAMELENGTH)
|
||||||
{
|
{t++;cnt++;} //crawl counter forward.
|
||||||
t++; //crawl counter forward.
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(cnt<MAXPATHNAMELENGTH-13)
|
if(cnt<MAXPATHNAMELENGTH-13)
|
||||||
file.getFilename(t);
|
file.getFilename(t);
|
||||||
|
|
@ -475,9 +470,9 @@ void CardReader::removeFile(const char* name)
|
||||||
SERIAL_PROTOCOLPGM("File deleted:");
|
SERIAL_PROTOCOLPGM("File deleted:");
|
||||||
SERIAL_PROTOCOLLN(fname);
|
SERIAL_PROTOCOLLN(fname);
|
||||||
sdpos = 0;
|
sdpos = 0;
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
presort();
|
presort();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -495,7 +490,7 @@ uint32_t CardReader::getFileSize()
|
||||||
|
|
||||||
void CardReader::getStatus()
|
void CardReader::getStatus()
|
||||||
{
|
{
|
||||||
if(sdprinting) {
|
if(sdprinting){
|
||||||
SERIAL_PROTOCOL(longFilename);
|
SERIAL_PROTOCOL(longFilename);
|
||||||
SERIAL_PROTOCOLPGM("\n");
|
SERIAL_PROTOCOLPGM("\n");
|
||||||
SERIAL_PROTOCOLRPGM(_N("SD printing byte "));////MSG_SD_PRINTING_BYTE c=0 r=0
|
SERIAL_PROTOCOLRPGM(_N("SD printing byte "));////MSG_SD_PRINTING_BYTE c=0 r=0
|
||||||
|
|
@ -574,7 +569,7 @@ void CardReader::checkautostart(bool force)
|
||||||
|
|
||||||
char autoname[30];
|
char autoname[30];
|
||||||
sprintf_P(autoname, PSTR("auto%i.g"), lastnr);
|
sprintf_P(autoname, PSTR("auto%i.g"), lastnr);
|
||||||
for(int8_t i=0; i<(int8_t)strlen(autoname); i++)
|
for(int8_t i=0;i<(int8_t)strlen(autoname);i++)
|
||||||
autoname[i]=tolower(autoname[i]);
|
autoname[i]=tolower(autoname[i]);
|
||||||
dir_t p;
|
dir_t p;
|
||||||
|
|
||||||
|
|
@ -583,7 +578,7 @@ void CardReader::checkautostart(bool force)
|
||||||
bool found=false;
|
bool found=false;
|
||||||
while (root.readDir(p, NULL) > 0)
|
while (root.readDir(p, NULL) > 0)
|
||||||
{
|
{
|
||||||
for(int8_t i=0; i<(int8_t)strlen((char*)p.name); i++)
|
for(int8_t i=0;i<(int8_t)strlen((char*)p.name);i++)
|
||||||
p.name[i]=tolower(p.name[i]);
|
p.name[i]=tolower(p.name[i]);
|
||||||
//Serial.print((char*)p.name);
|
//Serial.print((char*)p.name);
|
||||||
//Serial.print(" ");
|
//Serial.print(" ");
|
||||||
|
|
@ -675,9 +670,9 @@ void CardReader::chdir(const char * relpath)
|
||||||
workDirParents[0]=*parent;
|
workDirParents[0]=*parent;
|
||||||
}
|
}
|
||||||
workDir=newfile;
|
workDir=newfile;
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
presort();
|
presort();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -691,9 +686,9 @@ void CardReader::updir()
|
||||||
{
|
{
|
||||||
workDirParents[d] = workDirParents[d+1];
|
workDirParents[d] = workDirParents[d+1];
|
||||||
}
|
}
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
presort();
|
presort();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -704,9 +699,9 @@ void CardReader::updir()
|
||||||
*/
|
*/
|
||||||
void CardReader::getfilename_sorted(const uint16_t nr) {
|
void CardReader::getfilename_sorted(const uint16_t nr) {
|
||||||
getfilename(
|
getfilename(
|
||||||
#if SDSORT_GCODE
|
#if SDSORT_GCODE
|
||||||
sort_alpha &&
|
sort_alpha &&
|
||||||
#endif
|
#endif
|
||||||
(nr < sort_count) ? sort_order[nr] : nr
|
(nr < sort_count) ? sort_order[nr] : nr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -725,9 +720,9 @@ void CardReader::presort() {
|
||||||
|
|
||||||
if (sdSort == SD_SORT_NONE) return; //sd sort is turned off
|
if (sdSort == SD_SORT_NONE) return; //sd sort is turned off
|
||||||
|
|
||||||
#if SDSORT_GCODE
|
#if SDSORT_GCODE
|
||||||
if (!sort_alpha) return;
|
if (!sort_alpha) return;
|
||||||
#endif
|
#endif
|
||||||
KEEPALIVE_STATE(IN_HANDLER);
|
KEEPALIVE_STATE(IN_HANDLER);
|
||||||
|
|
||||||
// Throw away old sort index
|
// Throw away old sort index
|
||||||
|
|
@ -744,42 +739,42 @@ void CardReader::presort() {
|
||||||
fileCnt = SDSORT_LIMIT;
|
fileCnt = SDSORT_LIMIT;
|
||||||
}
|
}
|
||||||
lcd_clear();
|
lcd_clear();
|
||||||
#if !SDSORT_USES_RAM
|
#if !SDSORT_USES_RAM
|
||||||
lcd_set_progress();
|
lcd_set_progress();
|
||||||
#endif
|
#endif
|
||||||
lcd_puts_at_P(0, 1, _i("Sorting files"));////MSG_SORTING c=20 r=1
|
lcd_puts_at_P(0, 1, _i("Sorting files"));////MSG_SORTING c=20 r=1
|
||||||
|
|
||||||
// Sort order is always needed. May be static or dynamic.
|
// Sort order is always needed. May be static or dynamic.
|
||||||
#if SDSORT_DYNAMIC_RAM
|
#if SDSORT_DYNAMIC_RAM
|
||||||
sort_order = new uint8_t[fileCnt];
|
sort_order = new uint8_t[fileCnt];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Use RAM to store the entire directory during pre-sort.
|
// Use RAM to store the entire directory during pre-sort.
|
||||||
// SDSORT_LIMIT should be set to prevent over-allocation.
|
// SDSORT_LIMIT should be set to prevent over-allocation.
|
||||||
#if SDSORT_USES_RAM
|
#if SDSORT_USES_RAM
|
||||||
|
|
||||||
// If using dynamic ram for names, allocate on the heap.
|
// If using dynamic ram for names, allocate on the heap.
|
||||||
#if SDSORT_CACHE_NAMES
|
#if SDSORT_CACHE_NAMES
|
||||||
#if SDSORT_DYNAMIC_RAM
|
#if SDSORT_DYNAMIC_RAM
|
||||||
sortshort = new char*[fileCnt];
|
sortshort = new char*[fileCnt];
|
||||||
sortnames = new char*[fileCnt];
|
sortnames = new char*[fileCnt];
|
||||||
#endif
|
#endif
|
||||||
#elif SDSORT_USES_STACK
|
#elif SDSORT_USES_STACK
|
||||||
char sortnames[fileCnt][LONG_FILENAME_LENGTH];
|
char sortnames[fileCnt][LONG_FILENAME_LENGTH];
|
||||||
uint16_t creation_time[fileCnt];
|
uint16_t creation_time[fileCnt];
|
||||||
uint16_t creation_date[fileCnt];
|
uint16_t creation_date[fileCnt];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Folder sorting needs 1 bit per entry for flags.
|
// Folder sorting needs 1 bit per entry for flags.
|
||||||
#if HAS_FOLDER_SORTING
|
#if HAS_FOLDER_SORTING
|
||||||
#if SDSORT_DYNAMIC_RAM
|
#if SDSORT_DYNAMIC_RAM
|
||||||
isDir = new uint8_t[(fileCnt + 7) >> 3];
|
isDir = new uint8_t[(fileCnt + 7) >> 3];
|
||||||
#elif SDSORT_USES_STACK
|
#elif SDSORT_USES_STACK
|
||||||
uint8_t isDir[(fileCnt + 7) >> 3];
|
uint8_t isDir[(fileCnt + 7) >> 3];
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else // !SDSORT_USES_RAM
|
#else // !SDSORT_USES_RAM
|
||||||
|
|
||||||
uint32_t positions[fileCnt];
|
uint32_t positions[fileCnt];
|
||||||
|
|
||||||
|
|
@ -790,7 +785,7 @@ void CardReader::presort() {
|
||||||
uint16_t creation_time_bckp;
|
uint16_t creation_time_bckp;
|
||||||
uint16_t creation_date_bckp;
|
uint16_t creation_date_bckp;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
position = 0;
|
position = 0;
|
||||||
if (fileCnt > 1) {
|
if (fileCnt > 1) {
|
||||||
// Init sort order.
|
// Init sort order.
|
||||||
|
|
@ -801,34 +796,34 @@ void CardReader::presort() {
|
||||||
positions[i] = position;
|
positions[i] = position;
|
||||||
getfilename(i);
|
getfilename(i);
|
||||||
// If using RAM then read all filenames now.
|
// If using RAM then read all filenames now.
|
||||||
#if SDSORT_USES_RAM
|
#if SDSORT_USES_RAM
|
||||||
getfilename(i);
|
getfilename(i);
|
||||||
#if SDSORT_DYNAMIC_RAM
|
#if SDSORT_DYNAMIC_RAM
|
||||||
// Use dynamic method to copy long filename
|
// Use dynamic method to copy long filename
|
||||||
sortnames[i] = strdup(LONGEST_FILENAME);
|
sortnames[i] = strdup(LONGEST_FILENAME);
|
||||||
#if SDSORT_CACHE_NAMES
|
#if SDSORT_CACHE_NAMES
|
||||||
// When caching also store the short name, since
|
// When caching also store the short name, since
|
||||||
// we're replacing the getfilename() behavior.
|
// we're replacing the getfilename() behavior.
|
||||||
sortshort[i] = strdup(filename);
|
sortshort[i] = strdup(filename);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
// Copy filenames into the static array
|
// Copy filenames into the static array
|
||||||
strcpy(sortnames[i], LONGEST_FILENAME);
|
strcpy(sortnames[i], LONGEST_FILENAME);
|
||||||
creation_time[i] = creationTime;
|
creation_time[i] = creationTime;
|
||||||
creation_date[i] = creationDate;
|
creation_date[i] = creationDate;
|
||||||
#if SDSORT_CACHE_NAMES
|
#if SDSORT_CACHE_NAMES
|
||||||
strcpy(sortshort[i], filename);
|
strcpy(sortshort[i], filename);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
// char out[30];
|
// char out[30];
|
||||||
// sprintf_P(out, PSTR("---- %i %s %s"), i, filenameIsDir ? "D" : " ", sortnames[i]);
|
// sprintf_P(out, PSTR("---- %i %s %s"), i, filenameIsDir ? "D" : " ", sortnames[i]);
|
||||||
// SERIAL_ECHOLN(out);
|
// SERIAL_ECHOLN(out);
|
||||||
#if HAS_FOLDER_SORTING
|
#if HAS_FOLDER_SORTING
|
||||||
const uint16_t bit = i & 0x07, ind = i >> 3;
|
const uint16_t bit = i & 0x07, ind = i >> 3;
|
||||||
if (bit == 0) isDir[ind] = 0x00;
|
if (bit == 0) isDir[ind] = 0x00;
|
||||||
if (filenameIsDir) isDir[ind] |= _BV(bit);
|
if (filenameIsDir) isDir[ind] |= _BV(bit);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef QUICKSORT
|
#ifdef QUICKSORT
|
||||||
|
|
@ -838,41 +833,41 @@ void CardReader::presort() {
|
||||||
uint16_t total = 0.5*(fileCnt - 1)*(fileCnt);
|
uint16_t total = 0.5*(fileCnt - 1)*(fileCnt);
|
||||||
|
|
||||||
// Compare names from the array or just the two buffered names
|
// Compare names from the array or just the two buffered names
|
||||||
#if SDSORT_USES_RAM
|
#if SDSORT_USES_RAM
|
||||||
#define _SORT_CMP_NODIR() (strcasecmp(sortnames[o1], sortnames[o2]) > 0)
|
#define _SORT_CMP_NODIR() (strcasecmp(sortnames[o1], sortnames[o2]) > 0)
|
||||||
#define _SORT_CMP_TIME_NODIR() (((creation_date[o1] == creation_date[o2]) && (creation_time[o1] < creation_time[o2])) || \
|
#define _SORT_CMP_TIME_NODIR() (((creation_date[o1] == creation_date[o2]) && (creation_time[o1] < creation_time[o2])) || \
|
||||||
(creation_date[o1] < creation_date [o2]))
|
(creation_date[o1] < creation_date [o2]))
|
||||||
#else
|
#else
|
||||||
#define _SORT_CMP_NODIR() (strcasecmp(name1, name2) > 0) //true if lowercase(name1) > lowercase(name2)
|
#define _SORT_CMP_NODIR() (strcasecmp(name1, name2) > 0) //true if lowercase(name1) > lowercase(name2)
|
||||||
#define _SORT_CMP_TIME_NODIR() (((creation_date_bckp == creationDate) && (creation_time_bckp > creationTime)) || \
|
#define _SORT_CMP_TIME_NODIR() (((creation_date_bckp == creationDate) && (creation_time_bckp > creationTime)) || \
|
||||||
(creation_date_bckp > creationDate))
|
(creation_date_bckp > creationDate))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_FOLDER_SORTING
|
#if HAS_FOLDER_SORTING
|
||||||
#if SDSORT_USES_RAM
|
#if SDSORT_USES_RAM
|
||||||
// Folder sorting needs an index and bit to test for folder-ness.
|
// Folder sorting needs an index and bit to test for folder-ness.
|
||||||
const uint8_t ind1 = o1 >> 3, bit1 = o1 & 0x07,
|
const uint8_t ind1 = o1 >> 3, bit1 = o1 & 0x07,
|
||||||
ind2 = o2 >> 3, bit2 = o2 & 0x07;
|
ind2 = o2 >> 3, bit2 = o2 & 0x07;
|
||||||
#define _SORT_CMP_DIR(fs) \
|
#define _SORT_CMP_DIR(fs) \
|
||||||
(((isDir[ind1] & _BV(bit1)) != 0) == ((isDir[ind2] & _BV(bit2)) != 0) \
|
(((isDir[ind1] & _BV(bit1)) != 0) == ((isDir[ind2] & _BV(bit2)) != 0) \
|
||||||
? _SORT_CMP_NODIR() \
|
? _SORT_CMP_NODIR() \
|
||||||
: (isDir[fs > 0 ? ind1 : ind2] & (fs > 0 ? _BV(bit1) : _BV(bit2))) != 0)
|
: (isDir[fs > 0 ? ind1 : ind2] & (fs > 0 ? _BV(bit1) : _BV(bit2))) != 0)
|
||||||
#define _SORT_CMP_TIME_DIR(fs) \
|
#define _SORT_CMP_TIME_DIR(fs) \
|
||||||
(((isDir[ind1] & _BV(bit1)) != 0) == ((isDir[ind2] & _BV(bit2)) != 0) \
|
(((isDir[ind1] & _BV(bit1)) != 0) == ((isDir[ind2] & _BV(bit2)) != 0) \
|
||||||
? _SORT_CMP_TIME_NODIR() \
|
? _SORT_CMP_TIME_NODIR() \
|
||||||
: (isDir[fs > 0 ? ind1 : ind2] & (fs > 0 ? _BV(bit1) : _BV(bit2))) != 0)
|
: (isDir[fs > 0 ? ind1 : ind2] & (fs > 0 ? _BV(bit1) : _BV(bit2))) != 0)
|
||||||
#else
|
#else
|
||||||
#define _SORT_CMP_DIR(fs) ((dir1 == filenameIsDir) ? _SORT_CMP_NODIR() : (fs > 0 ? dir1 : !dir1))
|
#define _SORT_CMP_DIR(fs) ((dir1 == filenameIsDir) ? _SORT_CMP_NODIR() : (fs > 0 ? dir1 : !dir1))
|
||||||
#define _SORT_CMP_TIME_DIR(fs) ((dir1 == filenameIsDir) ? _SORT_CMP_TIME_NODIR() : (fs < 0 ? dir1 : !dir1))
|
#define _SORT_CMP_TIME_DIR(fs) ((dir1 == filenameIsDir) ? _SORT_CMP_TIME_NODIR() : (fs < 0 ? dir1 : !dir1))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (uint16_t i = fileCnt; --i;) {
|
for (uint16_t i = fileCnt; --i;) {
|
||||||
if (!IS_SD_INSERTED) return;
|
if (!IS_SD_INSERTED) return;
|
||||||
bool didSwap = false;
|
bool didSwap = false;
|
||||||
|
|
||||||
#if !SDSORT_USES_RAM //show progresss bar only if slow sorting method is used
|
#if !SDSORT_USES_RAM //show progresss bar only if slow sorting method is used
|
||||||
int8_t percent = (counter * 100) / total;//((counter * 100) / pow((fileCnt-1),2));
|
int8_t percent = (counter * 100) / total;//((counter * 100) / pow((fileCnt-1),2));
|
||||||
for (int column = 0; column < 20; column++) {
|
for (int column = 0; column < 20; column++) {
|
||||||
if (column < (percent / 5))
|
if (column < (percent / 5))
|
||||||
|
|
@ -882,7 +877,7 @@ void CardReader::presort() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
counter++;
|
counter++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//MYSERIAL.println(int(i));
|
//MYSERIAL.println(int(i));
|
||||||
for (uint16_t j = 0; j < i; ++j) {
|
for (uint16_t j = 0; j < i; ++j) {
|
||||||
|
|
@ -892,27 +887,27 @@ void CardReader::presort() {
|
||||||
|
|
||||||
// The most economical method reads names as-needed
|
// The most economical method reads names as-needed
|
||||||
// throughout the loop. Slow if there are many.
|
// throughout the loop. Slow if there are many.
|
||||||
#if !SDSORT_USES_RAM
|
#if !SDSORT_USES_RAM
|
||||||
counter++;
|
counter++;
|
||||||
getfilename_simple(positions[o1]);
|
getfilename_simple(positions[o1]);
|
||||||
strcpy(name1, LONGEST_FILENAME); // save (or getfilename below will trounce it)
|
strcpy(name1, LONGEST_FILENAME); // save (or getfilename below will trounce it)
|
||||||
creation_date_bckp = creationDate;
|
creation_date_bckp = creationDate;
|
||||||
creation_time_bckp = creationTime;
|
creation_time_bckp = creationTime;
|
||||||
#if HAS_FOLDER_SORTING
|
#if HAS_FOLDER_SORTING
|
||||||
bool dir1 = filenameIsDir;
|
bool dir1 = filenameIsDir;
|
||||||
#endif
|
#endif
|
||||||
getfilename_simple(positions[o2]);
|
getfilename_simple(positions[o2]);
|
||||||
char *name2 = LONGEST_FILENAME; // use the string in-place
|
char *name2 = LONGEST_FILENAME; // use the string in-place
|
||||||
|
|
||||||
#endif // !SDSORT_USES_RAM
|
#endif // !SDSORT_USES_RAM
|
||||||
|
|
||||||
// Sort the current pair according to settings.
|
// Sort the current pair according to settings.
|
||||||
if (
|
if (
|
||||||
#if HAS_FOLDER_SORTING
|
#if HAS_FOLDER_SORTING
|
||||||
(sdSort == SD_SORT_TIME && _SORT_CMP_TIME_DIR(FOLDER_SORTING)) || (sdSort == SD_SORT_ALPHA && _SORT_CMP_DIR(FOLDER_SORTING))
|
(sdSort == SD_SORT_TIME && _SORT_CMP_TIME_DIR(FOLDER_SORTING)) || (sdSort == SD_SORT_ALPHA && _SORT_CMP_DIR(FOLDER_SORTING))
|
||||||
#else
|
#else
|
||||||
(sdSort == SD_SORT_TIME && _SORT_CMP_TIME_NODIR()) || (sdSort == SD_SORT_ALPHA && _SORT_CMP_NODIR())
|
(sdSort == SD_SORT_TIME && _SORT_CMP_TIME_NODIR()) || (sdSort == SD_SORT_ALPHA && _SORT_CMP_NODIR())
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
sort_order[j] = o2;
|
sort_order[j] = o2;
|
||||||
|
|
@ -924,31 +919,31 @@ void CardReader::presort() {
|
||||||
} //end of bubble sort loop
|
} //end of bubble sort loop
|
||||||
#endif
|
#endif
|
||||||
// Using RAM but not keeping names around
|
// Using RAM but not keeping names around
|
||||||
#if (SDSORT_USES_RAM && !SDSORT_CACHE_NAMES)
|
#if (SDSORT_USES_RAM && !SDSORT_CACHE_NAMES)
|
||||||
#if SDSORT_DYNAMIC_RAM
|
#if SDSORT_DYNAMIC_RAM
|
||||||
for (uint16_t i = 0; i < fileCnt; ++i) free(sortnames[i]);
|
for (uint16_t i = 0; i < fileCnt; ++i) free(sortnames[i]);
|
||||||
#if HAS_FOLDER_SORTING
|
#if HAS_FOLDER_SORTING
|
||||||
free(isDir);
|
free(isDir);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sort_order[0] = 0;
|
sort_order[0] = 0;
|
||||||
#if (SDSORT_USES_RAM && SDSORT_CACHE_NAMES)
|
#if (SDSORT_USES_RAM && SDSORT_CACHE_NAMES)
|
||||||
getfilename(0);
|
getfilename(0);
|
||||||
#if SDSORT_DYNAMIC_RAM
|
#if SDSORT_DYNAMIC_RAM
|
||||||
sortnames = new char*[1];
|
sortnames = new char*[1];
|
||||||
sortnames[0] = strdup(LONGEST_FILENAME); // malloc
|
sortnames[0] = strdup(LONGEST_FILENAME); // malloc
|
||||||
sortshort = new char*[1];
|
sortshort = new char*[1];
|
||||||
sortshort[0] = strdup(filename); // malloc
|
sortshort[0] = strdup(filename); // malloc
|
||||||
isDir = new uint8_t[1];
|
isDir = new uint8_t[1];
|
||||||
#else
|
#else
|
||||||
strcpy(sortnames[0], LONGEST_FILENAME);
|
strcpy(sortnames[0], LONGEST_FILENAME);
|
||||||
strcpy(sortshort[0], filename);
|
strcpy(sortshort[0], filename);
|
||||||
#endif
|
#endif
|
||||||
isDir[0] = filenameIsDir ? 0x01 : 0x00;
|
isDir[0] = filenameIsDir ? 0x01 : 0x00;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
sort_count = fileCnt;
|
sort_count = fileCnt;
|
||||||
|
|
@ -970,17 +965,17 @@ void CardReader::presort() {
|
||||||
|
|
||||||
void CardReader::flush_presort() {
|
void CardReader::flush_presort() {
|
||||||
if (sort_count > 0) {
|
if (sort_count > 0) {
|
||||||
#if SDSORT_DYNAMIC_RAM
|
#if SDSORT_DYNAMIC_RAM
|
||||||
delete sort_order;
|
delete sort_order;
|
||||||
#if SDSORT_CACHE_NAMES
|
#if SDSORT_CACHE_NAMES
|
||||||
for (uint8_t i = 0; i < sort_count; ++i) {
|
for (uint8_t i = 0; i < sort_count; ++i) {
|
||||||
free(sortshort[i]); // strdup
|
free(sortshort[i]); // strdup
|
||||||
free(sortnames[i]); // strdup
|
free(sortnames[i]); // strdup
|
||||||
}
|
}
|
||||||
delete sortshort;
|
delete sortshort;
|
||||||
delete sortnames;
|
delete sortnames;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
sort_count = 0;
|
sort_count = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1011,9 +1006,9 @@ void CardReader::printingHasFinished()
|
||||||
//enquecommand_P(PSTR(SD_FINISHED_RELEASECOMMAND));
|
//enquecommand_P(PSTR(SD_FINISHED_RELEASECOMMAND));
|
||||||
}
|
}
|
||||||
autotempShutdown();
|
autotempShutdown();
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
//presort();
|
//presort();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,60 +44,30 @@ public:
|
||||||
void updir();
|
void updir();
|
||||||
void setroot();
|
void setroot();
|
||||||
|
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
void presort();
|
void presort();
|
||||||
#ifdef SDSORT_QUICKSORT
|
#ifdef SDSORT_QUICKSORT
|
||||||
void swap(uint8_t left, uint8_t right);
|
void swap(uint8_t left, uint8_t right);
|
||||||
void quicksort(uint8_t left, uint8_t right);
|
void quicksort(uint8_t left, uint8_t right);
|
||||||
#endif //SDSORT_QUICKSORT
|
#endif //SDSORT_QUICKSORT
|
||||||
void getfilename_sorted(const uint16_t nr);
|
void getfilename_sorted(const uint16_t nr);
|
||||||
#if SDSORT_GCODE
|
#if SDSORT_GCODE
|
||||||
FORCE_INLINE void setSortOn(bool b) {
|
FORCE_INLINE void setSortOn(bool b) { sort_alpha = b; presort(); }
|
||||||
sort_alpha = b;
|
FORCE_INLINE void setSortFolders(int i) { sort_folders = i; presort(); }
|
||||||
presort();
|
|
||||||
}
|
|
||||||
FORCE_INLINE void setSortFolders(int i) {
|
|
||||||
sort_folders = i;
|
|
||||||
presort();
|
|
||||||
}
|
|
||||||
//FORCE_INLINE void setSortReverse(bool b) { sort_reverse = b; }
|
//FORCE_INLINE void setSortReverse(bool b) { sort_reverse = b; }
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FORCE_INLINE bool isFileOpen() {
|
FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
|
||||||
return file.isOpen();
|
FORCE_INLINE bool eof() { return sdpos>=filesize ;};
|
||||||
}
|
FORCE_INLINE int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
|
||||||
FORCE_INLINE bool eof() {
|
FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
|
||||||
return sdpos>=filesize ;
|
FORCE_INLINE uint8_t percentDone(){if(!isFileOpen()) return 0; if(filesize) return sdpos/((filesize+99)/100); else return 0;};
|
||||||
};
|
FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
|
||||||
FORCE_INLINE int16_t get() {
|
FORCE_INLINE uint32_t get_sdpos() { if (!isFileOpen()) return 0; else return(sdpos); };
|
||||||
sdpos = file.curPosition();
|
|
||||||
return (int16_t)file.read();
|
|
||||||
};
|
|
||||||
FORCE_INLINE void setIndex(long index) {
|
|
||||||
sdpos = index;
|
|
||||||
file.seekSet(index);
|
|
||||||
};
|
|
||||||
FORCE_INLINE uint8_t percentDone() {
|
|
||||||
if(!isFileOpen()) return 0;
|
|
||||||
if(filesize) return sdpos/((filesize+99)/100);
|
|
||||||
else return 0;
|
|
||||||
};
|
|
||||||
FORCE_INLINE char* getWorkDirName() {
|
|
||||||
workDir.getFilename(filename);
|
|
||||||
return filename;
|
|
||||||
};
|
|
||||||
FORCE_INLINE uint32_t get_sdpos() {
|
|
||||||
if (!isFileOpen()) return 0;
|
|
||||||
else return(sdpos);
|
|
||||||
};
|
|
||||||
|
|
||||||
bool ToshibaFlashAir_isEnabled() const {
|
bool ToshibaFlashAir_isEnabled() const { return card.getFlashAirCompatible(); }
|
||||||
return card.getFlashAirCompatible();
|
void ToshibaFlashAir_enable(bool enable) { card.setFlashAirCompatible(enable); }
|
||||||
}
|
|
||||||
void ToshibaFlashAir_enable(bool enable) {
|
|
||||||
card.setFlashAirCompatible(enable);
|
|
||||||
}
|
|
||||||
bool ToshibaFlashAir_GetIP(uint8_t *ip);
|
bool ToshibaFlashAir_GetIP(uint8_t *ip);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -119,45 +89,45 @@ private:
|
||||||
// Sort files and folders alphabetically.
|
// Sort files and folders alphabetically.
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
uint16_t sort_count; // Count of sorted items in the current directory
|
uint16_t sort_count; // Count of sorted items in the current directory
|
||||||
#if SDSORT_GCODE
|
#if SDSORT_GCODE
|
||||||
bool sort_alpha; // Flag to enable / disable the feature
|
bool sort_alpha; // Flag to enable / disable the feature
|
||||||
int sort_folders; // Flag to enable / disable folder sorting
|
int sort_folders; // Flag to enable / disable folder sorting
|
||||||
//bool sort_reverse; // Flag to enable / disable reverse sorting
|
//bool sort_reverse; // Flag to enable / disable reverse sorting
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// By default the sort index is static
|
// By default the sort index is static
|
||||||
#if SDSORT_DYNAMIC_RAM
|
#if SDSORT_DYNAMIC_RAM
|
||||||
uint8_t *sort_order;
|
uint8_t *sort_order;
|
||||||
#else
|
#else
|
||||||
uint8_t sort_order[SDSORT_LIMIT];
|
uint8_t sort_order[SDSORT_LIMIT];
|
||||||
#endif
|
#endif
|
||||||
// Cache filenames to speed up SD menus.
|
// Cache filenames to speed up SD menus.
|
||||||
#if SDSORT_USES_RAM
|
#if SDSORT_USES_RAM
|
||||||
|
|
||||||
// If using dynamic ram for names, allocate on the heap.
|
// If using dynamic ram for names, allocate on the heap.
|
||||||
#if SDSORT_CACHE_NAMES
|
#if SDSORT_CACHE_NAMES
|
||||||
#if SDSORT_DYNAMIC_RAM
|
#if SDSORT_DYNAMIC_RAM
|
||||||
char **sortshort, **sortnames;
|
char **sortshort, **sortnames;
|
||||||
#else
|
#else
|
||||||
char sortshort[SDSORT_LIMIT][FILENAME_LENGTH];
|
char sortshort[SDSORT_LIMIT][FILENAME_LENGTH];
|
||||||
char sortnames[SDSORT_LIMIT][FILENAME_LENGTH];
|
char sortnames[SDSORT_LIMIT][FILENAME_LENGTH];
|
||||||
#endif
|
#endif
|
||||||
#elif !SDSORT_USES_STACK
|
#elif !SDSORT_USES_STACK
|
||||||
char sortnames[SDSORT_LIMIT][FILENAME_LENGTH];
|
char sortnames[SDSORT_LIMIT][FILENAME_LENGTH];
|
||||||
uint16_t creation_time[SDSORT_LIMIT];
|
uint16_t creation_time[SDSORT_LIMIT];
|
||||||
uint16_t creation_date[SDSORT_LIMIT];
|
uint16_t creation_date[SDSORT_LIMIT];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Folder sorting uses an isDir array when caching items.
|
// Folder sorting uses an isDir array when caching items.
|
||||||
#if HAS_FOLDER_SORTING
|
#if HAS_FOLDER_SORTING
|
||||||
#if SDSORT_DYNAMIC_RAM
|
#if SDSORT_DYNAMIC_RAM
|
||||||
uint8_t *isDir;
|
uint8_t *isDir;
|
||||||
#elif (SDSORT_CACHE_NAMES) || !(SDSORT_USES_STACK)
|
#elif (SDSORT_CACHE_NAMES) || !(SDSORT_USES_STACK)
|
||||||
uint8_t isDir[(SDSORT_LIMIT + 7) >> 3];
|
uint8_t isDir[(SDSORT_LIMIT + 7) >> 3];
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // SDSORT_USES_RAM
|
#endif // SDSORT_USES_RAM
|
||||||
|
|
||||||
#endif // SDCARD_SORT_ALPHA
|
#endif // SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
|
@ -169,8 +139,8 @@ public:
|
||||||
private:
|
private:
|
||||||
SdVolume volume;
|
SdVolume volume;
|
||||||
SdFile file;
|
SdFile file;
|
||||||
#define SD_PROCEDURE_DEPTH 1
|
#define SD_PROCEDURE_DEPTH 1
|
||||||
#define MAXPATHNAMELENGTH (13*MAX_DIR_DEPTH+MAX_DIR_DEPTH+1)
|
#define MAXPATHNAMELENGTH (13*MAX_DIR_DEPTH+MAX_DIR_DEPTH+1)
|
||||||
uint8_t file_subcall_ctr;
|
uint8_t file_subcall_ctr;
|
||||||
uint32_t filespos[SD_PROCEDURE_DEPTH];
|
uint32_t filespos[SD_PROCEDURE_DEPTH];
|
||||||
char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
|
char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
|
||||||
|
|
|
||||||
|
|
@ -385,7 +385,7 @@ void get_command()
|
||||||
while (MYSERIAL.available() > 0 && !saved_printing) { //is print is saved (crash detection or filament detection), dont process data from serial line
|
while (MYSERIAL.available() > 0 && !saved_printing) { //is print is saved (crash detection or filament detection), dont process data from serial line
|
||||||
|
|
||||||
char serial_char = MYSERIAL.read();
|
char serial_char = MYSERIAL.read();
|
||||||
/* if (selectedSerialPort == 1)
|
/* if (selectedSerialPort == 1)
|
||||||
{
|
{
|
||||||
selectedSerialPort = 0;
|
selectedSerialPort = 0;
|
||||||
MYSERIAL.write(serial_char); // for debuging serial line 2 in farm_mode
|
MYSERIAL.write(serial_char); // for debuging serial line 2 in farm_mode
|
||||||
|
|
@ -409,7 +409,7 @@ void get_command()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cmdbuffer[bufindw+serial_count+CMDHDRSIZE] = 0; //terminate string
|
cmdbuffer[bufindw+serial_count+CMDHDRSIZE] = 0; //terminate string
|
||||||
if(!comment_mode) {
|
if(!comment_mode){
|
||||||
|
|
||||||
gcode_N = 0;
|
gcode_N = 0;
|
||||||
|
|
||||||
|
|
@ -526,7 +526,7 @@ void get_command()
|
||||||
}
|
}
|
||||||
} // end of serial line processing loop
|
} // end of serial line processing loop
|
||||||
|
|
||||||
if(farm_mode) {
|
if(farm_mode){
|
||||||
TimeNow = millis();
|
TimeNow = millis();
|
||||||
if ( ((TimeNow - TimeSent) > 800) && (serial_count > 0) ) {
|
if ( ((TimeNow - TimeSent) > 800) && (serial_count > 0) ) {
|
||||||
cmdbuffer[bufindw+serial_count+CMDHDRSIZE] = 0;
|
cmdbuffer[bufindw+serial_count+CMDHDRSIZE] = 0;
|
||||||
|
|
@ -544,8 +544,8 @@ void get_command()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SDSUPPORT
|
#ifdef SDSUPPORT
|
||||||
if(!card.sdprinting || serial_count!=0) {
|
if(!card.sdprinting || serial_count!=0){
|
||||||
// If there is a half filled buffer from serial line, wait until return before
|
// If there is a half filled buffer from serial line, wait until return before
|
||||||
// continuing with the serial line.
|
// continuing with the serial line.
|
||||||
return;
|
return;
|
||||||
|
|
@ -574,7 +574,7 @@ void get_command()
|
||||||
((serial_char == '#' || serial_char == ':') && comment_mode == false) ||
|
((serial_char == '#' || serial_char == ':') && comment_mode == false) ||
|
||||||
serial_count >= (MAX_CMD_SIZE - 1) || n==-1)
|
serial_count >= (MAX_CMD_SIZE - 1) || n==-1)
|
||||||
{
|
{
|
||||||
if(card.eof()) {
|
if(card.eof()){
|
||||||
SERIAL_PROTOCOLLNRPGM(_n("Done printing file"));////MSG_FILE_PRINTED c=0 r=0
|
SERIAL_PROTOCOLLNRPGM(_n("Done printing file"));////MSG_FILE_PRINTED c=0 r=0
|
||||||
stoptime=millis();
|
stoptime=millis();
|
||||||
char time[30];
|
char time[30];
|
||||||
|
|
@ -656,7 +656,7 @@ void get_command()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //SDSUPPORT
|
#endif //SDSUPPORT
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t cmdqueue_calc_sd_length()
|
uint16_t cmdqueue_calc_sd_length()
|
||||||
|
|
|
||||||
|
|
@ -71,24 +71,12 @@ extern void get_command();
|
||||||
extern uint16_t cmdqueue_calc_sd_length();
|
extern uint16_t cmdqueue_calc_sd_length();
|
||||||
|
|
||||||
// Return True if a character was found
|
// Return True if a character was found
|
||||||
static inline bool code_seen(char code) {
|
static inline bool code_seen(char code) { return (strchr_pointer = strchr(CMDBUFFER_CURRENT_STRING, code)) != NULL; }
|
||||||
return (strchr_pointer = strchr(CMDBUFFER_CURRENT_STRING, code)) != NULL;
|
static inline bool code_seen(const char *code) { return (strchr_pointer = strstr(CMDBUFFER_CURRENT_STRING, code)) != NULL; }
|
||||||
}
|
static inline float code_value() { return strtod(strchr_pointer+1, NULL);}
|
||||||
static inline bool code_seen(const char *code) {
|
static inline long code_value_long() { return strtol(strchr_pointer+1, NULL, 10); }
|
||||||
return (strchr_pointer = strstr(CMDBUFFER_CURRENT_STRING, code)) != NULL;
|
static inline int16_t code_value_short() { return int16_t(strtol(strchr_pointer+1, NULL, 10)); };
|
||||||
}
|
static inline uint8_t code_value_uint8() { return uint8_t(strtol(strchr_pointer+1, NULL, 10)); };
|
||||||
static inline float code_value() {
|
|
||||||
return strtod(strchr_pointer+1, NULL);
|
|
||||||
}
|
|
||||||
static inline long code_value_long() {
|
|
||||||
return strtol(strchr_pointer+1, NULL, 10);
|
|
||||||
}
|
|
||||||
static inline int16_t code_value_short() {
|
|
||||||
return int16_t(strtol(strchr_pointer+1, NULL, 10));
|
|
||||||
};
|
|
||||||
static inline uint8_t code_value_uint8() {
|
|
||||||
return uint8_t(strtol(strchr_pointer+1, NULL, 10));
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline float code_value_float()
|
static inline float code_value_float()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@
|
||||||
#define CMD_DIAGNOSTICS //Show cmd queue length on printer display
|
#define CMD_DIAGNOSTICS //Show cmd queue length on printer display
|
||||||
#endif /* DEBUG_BUILD */
|
#endif /* DEBUG_BUILD */
|
||||||
|
|
||||||
#define FSENSOR_QUALITY
|
//#define FSENSOR_QUALITY
|
||||||
|
|
||||||
|
|
||||||
#define LINEARITY_CORRECTION
|
#define LINEARITY_CORRECTION
|
||||||
|
|
@ -261,6 +261,8 @@
|
||||||
|
|
||||||
#define TMC2130_STEALTH_Z
|
#define TMC2130_STEALTH_Z
|
||||||
|
|
||||||
|
//#define TMC2130_SERVICE_CODES_M910_M918
|
||||||
|
|
||||||
//#define TMC2130_DEBUG
|
//#define TMC2130_DEBUG
|
||||||
//#define TMC2130_DEBUG_WR
|
//#define TMC2130_DEBUG_WR
|
||||||
//#define TMC2130_DEBUG_RD
|
//#define TMC2130_DEBUG_RD
|
||||||
|
|
@ -339,12 +341,13 @@
|
||||||
#define FILAMENTCHANGE_FIRSTRETRACT -2
|
#define FILAMENTCHANGE_FIRSTRETRACT -2
|
||||||
#define FILAMENTCHANGE_FINALRETRACT -80
|
#define FILAMENTCHANGE_FINALRETRACT -80
|
||||||
|
|
||||||
#define FILAMENTCHANGE_FIRSTFEED 70
|
#define FILAMENTCHANGE_FIRSTFEED 70 //E distance in mm for fast filament loading sequence used used in filament change (M600)
|
||||||
#define FILAMENTCHANGE_FINALFEED 50
|
#define FILAMENTCHANGE_FINALFEED 25 //E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701)
|
||||||
#define FILAMENTCHANGE_RECFEED 5
|
#define FILAMENTCHANGE_RECFEED 5
|
||||||
|
|
||||||
#define FILAMENTCHANGE_XYFEED 50
|
#define FILAMENTCHANGE_XYFEED 50
|
||||||
#define FILAMENTCHANGE_EFEED 20
|
#define FILAMENTCHANGE_EFEED_FIRST 20 // feedrate in mm/s for fast filament loading sequence used in filament change (M600)
|
||||||
|
#define FILAMENTCHANGE_EFEED_FINAL 3.3f // feedrate in mm/s for slow filament loading sequence used in filament change (M600) and filament load (M701)
|
||||||
//#define FILAMENTCHANGE_RFEED 400
|
//#define FILAMENTCHANGE_RFEED 400
|
||||||
#define FILAMENTCHANGE_RFEED 7000 / 60
|
#define FILAMENTCHANGE_RFEED 7000 / 60
|
||||||
#define FILAMENTCHANGE_EXFEED 2
|
#define FILAMENTCHANGE_EXFEED 2
|
||||||
|
|
@ -374,16 +377,8 @@
|
||||||
MOTOR CURRENT SETTINGS
|
MOTOR CURRENT SETTINGS
|
||||||
*------------------------------------*/
|
*------------------------------------*/
|
||||||
|
|
||||||
// Motor Current setting for BIG RAMBo
|
// Motor Current settings for Einsy/tmc = 0..63
|
||||||
#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
|
#define MOTOR_CURRENT_PWM_RANGE 63
|
||||||
#define DIGIPOT_MOTOR_CURRENT_LOUD {135,135,135,135,135}
|
|
||||||
|
|
||||||
// Motor Current settings for RAMBo mini PWM value = MotorCurrentSetting * 255 / range
|
|
||||||
#if MOTHERBOARD == BOARD_RAMBO_MINI_1_0 || MOTHERBOARD == BOARD_RAMBO_MINI_1_3
|
|
||||||
#define MOTOR_CURRENT_PWM_RANGE 2000
|
|
||||||
#define DEFAULT_PWM_MOTOR_CURRENT {400, 750, 750} // {XY,Z,E}
|
|
||||||
#define DEFAULT_PWM_MOTOR_CURRENT_LOUD {400, 750, 750} // {XY,Z,E}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*------------------------------------
|
/*------------------------------------
|
||||||
BED SETTINGS
|
BED SETTINGS
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,6 @@ bool fsensor_check_autoload(void)
|
||||||
// if ((fsensor_autoload_c >= 15) && (fsensor_autoload_sum > 30))
|
// if ((fsensor_autoload_c >= 15) && (fsensor_autoload_sum > 30))
|
||||||
if ((fsensor_autoload_c >= 12) && (fsensor_autoload_sum > 20))
|
if ((fsensor_autoload_c >= 12) && (fsensor_autoload_sum > 20))
|
||||||
{
|
{
|
||||||
//puts_P(_N("fsensor_check_autoload = true !!!\n"));
|
|
||||||
if (mmu_enabled) mmu_command(MMU_CMD_FS);
|
if (mmu_enabled) mmu_command(MMU_CMD_FS);
|
||||||
fsensor_autoload_check_stop();
|
fsensor_autoload_check_stop();
|
||||||
fsensor_autoload_enabled = false;
|
fsensor_autoload_enabled = false;
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,6 @@ extern bool fsensor_not_responding;
|
||||||
//enable/disable quality meassurement
|
//enable/disable quality meassurement
|
||||||
extern bool fsensor_oq_meassure_enabled;
|
extern bool fsensor_oq_meassure_enabled;
|
||||||
|
|
||||||
//extern bool mmuFilamentMK3Moving;
|
|
||||||
extern bool mmuFSensorLoading;
|
|
||||||
|
|
||||||
|
|
||||||
//! @name save restore printing
|
//! @name save restore printing
|
||||||
//! @{
|
//! @{
|
||||||
|
|
|
||||||
|
|
@ -17,22 +17,12 @@ uint8_t lang_selected = 0;
|
||||||
|
|
||||||
#if (LANG_MODE == 0) //primary language only
|
#if (LANG_MODE == 0) //primary language only
|
||||||
|
|
||||||
uint8_t lang_select(uint8_t lang) {
|
uint8_t lang_select(uint8_t lang) { return 0; }
|
||||||
return 0;
|
uint8_t lang_get_count() { return 1; }
|
||||||
}
|
uint16_t lang_get_code(uint8_t lang) { return LANG_CODE_EN; }
|
||||||
uint8_t lang_get_count() {
|
const char* lang_get_name_by_code(uint16_t code) { return _n("English"); }
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
uint16_t lang_get_code(uint8_t lang) {
|
|
||||||
return LANG_CODE_EN;
|
|
||||||
}
|
|
||||||
const char* lang_get_name_by_code(uint16_t code) {
|
|
||||||
return _n("English");
|
|
||||||
}
|
|
||||||
void lang_reset(void) { }
|
void lang_reset(void) { }
|
||||||
uint8_t lang_is_selected(void) {
|
uint8_t lang_is_selected(void) { return 1; }
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else //(LANG_MODE == 0) //secondary languages in progmem or xflash
|
#else //(LANG_MODE == 0) //secondary languages in progmem or xflash
|
||||||
|
|
||||||
|
|
@ -106,8 +96,7 @@ uint8_t lang_check(uint16_t addr)
|
||||||
uint16_t sum = 0;
|
uint16_t sum = 0;
|
||||||
uint16_t size = pgm_read_word((uint16_t*)(addr + 4));
|
uint16_t size = pgm_read_word((uint16_t*)(addr + 4));
|
||||||
uint16_t lt_sum = pgm_read_word((uint16_t*)(addr + 8));
|
uint16_t lt_sum = pgm_read_word((uint16_t*)(addr + 8));
|
||||||
uint16_t i;
|
uint16_t i; for (i = 0; i < size; i++)
|
||||||
for (i = 0; i < size; i++)
|
|
||||||
sum += (uint16_t)pgm_read_byte((uint8_t*)(addr + i)) << ((i & 1)?0:8);
|
sum += (uint16_t)pgm_read_byte((uint8_t*)(addr + i)) << ((i & 1)?0:8);
|
||||||
sum -= lt_sum; //subtract checksum
|
sum -= lt_sum; //subtract checksum
|
||||||
sum = (sum >> 8) | ((sum & 0xff) << 8); //swap bytes
|
sum = (sum >> 8) | ((sum & 0xff) << 8); //swap bytes
|
||||||
|
|
@ -214,20 +203,13 @@ const char* lang_get_name_by_code(uint16_t code)
|
||||||
{
|
{
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case LANG_CODE_EN:
|
case LANG_CODE_EN: return _n("English");
|
||||||
return _n("English");
|
case LANG_CODE_CZ: return _n("Cestina");
|
||||||
case LANG_CODE_CZ:
|
case LANG_CODE_DE: return _n("Deutsch");
|
||||||
return _n("Cestina");
|
case LANG_CODE_ES: return _n("Espanol");
|
||||||
case LANG_CODE_DE:
|
case LANG_CODE_FR: return _n("Francais");
|
||||||
return _n("Deutsch");
|
case LANG_CODE_IT: return _n("Italiano");
|
||||||
case LANG_CODE_ES:
|
case LANG_CODE_PL: return _n("Polski");
|
||||||
return _n("Espanol");
|
|
||||||
case LANG_CODE_FR:
|
|
||||||
return _n("Francais");
|
|
||||||
case LANG_CODE_IT:
|
|
||||||
return _n("Italiano");
|
|
||||||
case LANG_CODE_PL:
|
|
||||||
return _n("Polski");
|
|
||||||
}
|
}
|
||||||
return _n("??");
|
return _n("??");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,11 @@
|
||||||
#define PROTOCOL_VERSION "1.0"
|
#define PROTOCOL_VERSION "1.0"
|
||||||
|
|
||||||
#ifndef CUSTOM_MENDEL_NAME
|
#ifndef CUSTOM_MENDEL_NAME
|
||||||
#define MACHINE_NAME "Mendel"
|
#define MACHINE_NAME "Mendel"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MACHINE_UUID
|
#ifndef MACHINE_UUID
|
||||||
#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
|
#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MSG_FW_VERSION "Firmware"
|
#define MSG_FW_VERSION "Firmware"
|
||||||
|
|
|
||||||
|
|
@ -419,10 +419,8 @@ uint8_t lcd_escape_write(uint8_t chr)
|
||||||
case 2:
|
case 2:
|
||||||
switch (chr)
|
switch (chr)
|
||||||
{
|
{
|
||||||
case '2':
|
case '2': return 1; // escape = "\x1b[2"
|
||||||
return 1; // escape = "\x1b[2"
|
case '?': return 1; // escape = "\x1b[?"
|
||||||
case '?':
|
|
||||||
return 1; // escape = "\x1b[?"
|
|
||||||
default:
|
default:
|
||||||
if (chr_is_num) return 1; // escape = "\x1b[%1d"
|
if (chr_is_num) return 1; // escape = "\x1b[%1d"
|
||||||
}
|
}
|
||||||
|
|
@ -435,11 +433,7 @@ uint8_t lcd_escape_write(uint8_t chr)
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
if (chr == 'J') // escape = "\x1b[2J"
|
if (chr == 'J') // escape = "\x1b[2J"
|
||||||
{
|
{ lcd_clear(); lcd_currline = 0; break; } // EraseScreen
|
||||||
lcd_clear(); // EraseScreen
|
|
||||||
lcd_currline = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
if (e_2_is_num && // escape = "\x1b[%1d"
|
if (e_2_is_num && // escape = "\x1b[%1d"
|
||||||
((chr == ';') || // escape = "\x1b[%1d;"
|
((chr == ';') || // escape = "\x1b[%1d;"
|
||||||
|
|
@ -712,8 +706,8 @@ void lcd_beeper_quick_feedback(void)
|
||||||
{
|
{
|
||||||
SET_OUTPUT(BEEPER);
|
SET_OUTPUT(BEEPER);
|
||||||
//-//
|
//-//
|
||||||
Sound_MakeSound(e_SOUND_TYPE_ButtonEcho);
|
Sound_MakeSound(e_SOUND_TYPE_ButtonEcho);
|
||||||
/*
|
/*
|
||||||
for(int8_t i = 0; i < 10; i++)
|
for(int8_t i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
WRITE(BEEPER,HIGH);
|
WRITE(BEEPER,HIGH);
|
||||||
|
|
@ -721,7 +715,7 @@ void lcd_beeper_quick_feedback(void)
|
||||||
WRITE(BEEPER,LOW);
|
WRITE(BEEPER,LOW);
|
||||||
delayMicroseconds(100);
|
delayMicroseconds(100);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_quick_feedback(void)
|
void lcd_quick_feedback(void)
|
||||||
|
|
@ -867,8 +861,7 @@ const uint8_t lcd_chardata_bedTemp[8] PROGMEM = {
|
||||||
B10101,
|
B10101,
|
||||||
B11111,
|
B11111,
|
||||||
B00000,
|
B00000,
|
||||||
B00000
|
B00000}; //thanks Sonny Mounicou
|
||||||
}; //thanks Sonny Mounicou
|
|
||||||
|
|
||||||
const uint8_t lcd_chardata_degree[8] PROGMEM = {
|
const uint8_t lcd_chardata_degree[8] PROGMEM = {
|
||||||
B01100,
|
B01100,
|
||||||
|
|
@ -878,8 +871,7 @@ const uint8_t lcd_chardata_degree[8] PROGMEM = {
|
||||||
B00000,
|
B00000,
|
||||||
B00000,
|
B00000,
|
||||||
B00000,
|
B00000,
|
||||||
B00000
|
B00000};
|
||||||
};
|
|
||||||
|
|
||||||
const uint8_t lcd_chardata_thermometer[8] PROGMEM = {
|
const uint8_t lcd_chardata_thermometer[8] PROGMEM = {
|
||||||
B00100,
|
B00100,
|
||||||
|
|
@ -889,8 +881,7 @@ const uint8_t lcd_chardata_thermometer[8] PROGMEM = {
|
||||||
B01010,
|
B01010,
|
||||||
B10001,
|
B10001,
|
||||||
B10001,
|
B10001,
|
||||||
B01110
|
B01110};
|
||||||
};
|
|
||||||
|
|
||||||
const uint8_t lcd_chardata_uplevel[8] PROGMEM = {
|
const uint8_t lcd_chardata_uplevel[8] PROGMEM = {
|
||||||
B00100,
|
B00100,
|
||||||
|
|
@ -900,8 +891,7 @@ const uint8_t lcd_chardata_uplevel[8] PROGMEM = {
|
||||||
B11100,
|
B11100,
|
||||||
B00000,
|
B00000,
|
||||||
B00000,
|
B00000,
|
||||||
B00000
|
B00000}; //thanks joris
|
||||||
}; //thanks joris
|
|
||||||
|
|
||||||
const uint8_t lcd_chardata_refresh[8] PROGMEM = {
|
const uint8_t lcd_chardata_refresh[8] PROGMEM = {
|
||||||
B00000,
|
B00000,
|
||||||
|
|
@ -911,8 +901,7 @@ const uint8_t lcd_chardata_refresh[8] PROGMEM = {
|
||||||
B00011,
|
B00011,
|
||||||
B10011,
|
B10011,
|
||||||
B01100,
|
B01100,
|
||||||
B00000
|
B00000}; //thanks joris
|
||||||
}; //thanks joris
|
|
||||||
|
|
||||||
const uint8_t lcd_chardata_folder[8] PROGMEM = {
|
const uint8_t lcd_chardata_folder[8] PROGMEM = {
|
||||||
B00000,
|
B00000,
|
||||||
|
|
@ -922,8 +911,7 @@ const uint8_t lcd_chardata_folder[8] PROGMEM = {
|
||||||
B10001,
|
B10001,
|
||||||
B11111,
|
B11111,
|
||||||
B00000,
|
B00000,
|
||||||
B00000
|
B00000}; //thanks joris
|
||||||
}; //thanks joris
|
|
||||||
|
|
||||||
/*const uint8_t lcd_chardata_feedrate[8] PROGMEM = {
|
/*const uint8_t lcd_chardata_feedrate[8] PROGMEM = {
|
||||||
B11100,
|
B11100,
|
||||||
|
|
@ -963,8 +951,7 @@ const uint8_t lcd_chardata_feedrate[8] PROGMEM = {
|
||||||
B10010,
|
B10010,
|
||||||
B00100,
|
B00100,
|
||||||
B00000,
|
B00000,
|
||||||
B00000
|
B00000};
|
||||||
};
|
|
||||||
|
|
||||||
const uint8_t lcd_chardata_clock[8] PROGMEM = {
|
const uint8_t lcd_chardata_clock[8] PROGMEM = {
|
||||||
B00000,
|
B00000,
|
||||||
|
|
@ -974,8 +961,7 @@ const uint8_t lcd_chardata_clock[8] PROGMEM = {
|
||||||
B10001,
|
B10001,
|
||||||
B01110,
|
B01110,
|
||||||
B00000,
|
B00000,
|
||||||
B00000
|
B00000}; //thanks Sonny Mounicou
|
||||||
}; //thanks Sonny Mounicou
|
|
||||||
|
|
||||||
const uint8_t lcd_chardata_arrup[8] PROGMEM = {
|
const uint8_t lcd_chardata_arrup[8] PROGMEM = {
|
||||||
B00100,
|
B00100,
|
||||||
|
|
@ -985,8 +971,7 @@ const uint8_t lcd_chardata_arrup[8] PROGMEM = {
|
||||||
B00000,
|
B00000,
|
||||||
B00000,
|
B00000,
|
||||||
B00000,
|
B00000,
|
||||||
B00000
|
B00000};
|
||||||
};
|
|
||||||
|
|
||||||
const uint8_t lcd_chardata_arrdown[8] PROGMEM = {
|
const uint8_t lcd_chardata_arrdown[8] PROGMEM = {
|
||||||
B00000,
|
B00000,
|
||||||
|
|
@ -996,8 +981,7 @@ const uint8_t lcd_chardata_arrdown[8] PROGMEM = {
|
||||||
B00000,
|
B00000,
|
||||||
B10001,
|
B10001,
|
||||||
B01010,
|
B01010,
|
||||||
B00100
|
B00100};
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1028,8 +1012,7 @@ const uint8_t lcd_chardata_progress[8] PROGMEM = {
|
||||||
B11111,
|
B11111,
|
||||||
B11111,
|
B11111,
|
||||||
B11111,
|
B11111,
|
||||||
B11111
|
B11111};
|
||||||
};
|
|
||||||
|
|
||||||
void lcd_set_custom_characters_progress(void)
|
void lcd_set_custom_characters_progress(void)
|
||||||
{
|
{
|
||||||
|
|
@ -1044,8 +1027,7 @@ const uint8_t lcd_chardata_arr2down[8] PROGMEM = {
|
||||||
B00100,
|
B00100,
|
||||||
B10001,
|
B10001,
|
||||||
B01010,
|
B01010,
|
||||||
B00100
|
B00100};
|
||||||
};
|
|
||||||
|
|
||||||
const uint8_t lcd_chardata_confirm[8] PROGMEM = {
|
const uint8_t lcd_chardata_confirm[8] PROGMEM = {
|
||||||
B00000,
|
B00000,
|
||||||
|
|
@ -1054,8 +1036,7 @@ const uint8_t lcd_chardata_confirm[8] PROGMEM = {
|
||||||
B10110,
|
B10110,
|
||||||
B11100,
|
B11100,
|
||||||
B01000,
|
B01000,
|
||||||
B00000
|
B00000};
|
||||||
};
|
|
||||||
|
|
||||||
void lcd_set_custom_characters_nextpage(void)
|
void lcd_set_custom_characters_nextpage(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -129,9 +129,7 @@ const float bed_ref_points[] PROGMEM = {
|
||||||
|
|
||||||
#endif //not HEATBED_V2
|
#endif //not HEATBED_V2
|
||||||
|
|
||||||
static inline float sqr(float x) {
|
static inline float sqr(float x) { return x * x; }
|
||||||
return x * x;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HEATBED_V2
|
#ifdef HEATBED_V2
|
||||||
static inline bool point_on_1st_row(const uint8_t /*i*/)
|
static inline bool point_on_1st_row(const uint8_t /*i*/)
|
||||||
|
|
@ -215,10 +213,10 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
verbosity_level
|
verbosity_level
|
||||||
#endif //SUPPORT_VERBOSITY
|
#endif //SUPPORT_VERBOSITY
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
float angleDiff;
|
float angleDiff;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) {
|
if (verbosity_level >= 10) {
|
||||||
SERIAL_ECHOLNPGM("calculate machine skew and offset LS");
|
SERIAL_ECHOLNPGM("calculate machine skew and offset LS");
|
||||||
|
|
||||||
|
|
@ -260,7 +258,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
}
|
}
|
||||||
delay_keep_alive(100);
|
delay_keep_alive(100);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
// Run some iterations of the Gauss-Newton method of non-linear least squares.
|
// Run some iterations of the Gauss-Newton method of non-linear least squares.
|
||||||
// Initial set of parameters:
|
// Initial set of parameters:
|
||||||
|
|
@ -362,7 +360,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
a1 += h[2];
|
a1 += h[2];
|
||||||
a2 += h[3];
|
a2 += h[3];
|
||||||
|
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM("iteration: ");
|
SERIAL_ECHOPGM("iteration: ");
|
||||||
MYSERIAL.print(int(iter));
|
MYSERIAL.print(int(iter));
|
||||||
|
|
@ -386,7 +384,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
MYSERIAL.print(180.f * a2 / M_PI, 5);
|
MYSERIAL.print(180.f * a2 / M_PI, 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
|
|
||||||
vec_x[0] = cos(a1) * MACHINE_AXIS_SCALE_X;
|
vec_x[0] = cos(a1) * MACHINE_AXIS_SCALE_X;
|
||||||
|
|
@ -406,7 +404,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
fabs(a2) > bed_skew_angle_extreme)
|
fabs(a2) > bed_skew_angle_extreme)
|
||||||
result = BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME;
|
result = BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME;
|
||||||
}
|
}
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 1) {
|
if (verbosity_level >= 1) {
|
||||||
SERIAL_ECHOPGM("correction angles: ");
|
SERIAL_ECHOPGM("correction angles: ");
|
||||||
MYSERIAL.print(180.f * a1 / M_PI, 5);
|
MYSERIAL.print(180.f * a1 / M_PI, 5);
|
||||||
|
|
@ -438,7 +436,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
|
|
||||||
SERIAL_ECHOLNPGM("Error after correction: ");
|
SERIAL_ECHOLNPGM("Error after correction: ");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Measure the error after correction.
|
// Measure the error after correction.
|
||||||
for (uint8_t i = 0; i < npts; ++i) {
|
for (uint8_t i = 0; i < npts; ++i) {
|
||||||
float x = vec_x[0] * measured_pts[i * 2] + vec_y[0] * measured_pts[i * 2 + 1] + cntr[0];
|
float x = vec_x[0] * measured_pts[i * 2] + vec_y[0] * measured_pts[i * 2 + 1] + cntr[0];
|
||||||
|
|
@ -446,44 +444,44 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
float errX = sqr(pgm_read_float(true_pts + i * 2) - x);
|
float errX = sqr(pgm_read_float(true_pts + i * 2) - x);
|
||||||
float errY = sqr(pgm_read_float(true_pts + i * 2 + 1) - y);
|
float errY = sqr(pgm_read_float(true_pts + i * 2 + 1) - y);
|
||||||
float err = sqrt(errX + errY);
|
float err = sqrt(errX + errY);
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) {
|
if (verbosity_level >= 10) {
|
||||||
SERIAL_ECHOPGM("point #");
|
SERIAL_ECHOPGM("point #");
|
||||||
MYSERIAL.print(int(i));
|
MYSERIAL.print(int(i));
|
||||||
SERIAL_ECHOLNPGM(":");
|
SERIAL_ECHOLNPGM(":");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
if (point_on_1st_row(i)) {
|
if (point_on_1st_row(i)) {
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if(verbosity_level >= 20) SERIAL_ECHOPGM("Point on first row");
|
if(verbosity_level >= 20) SERIAL_ECHOPGM("Point on first row");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
float w = point_weight_y(i, measured_pts[2 * i + 1]);
|
float w = point_weight_y(i, measured_pts[2 * i + 1]);
|
||||||
if (sqrt(errX) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_X ||
|
if (sqrt(errX) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_X ||
|
||||||
(w != 0.f && sqrt(errY) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_Y)) {
|
(w != 0.f && sqrt(errY) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_Y)) {
|
||||||
result = BED_SKEW_OFFSET_DETECTION_FITTING_FAILED;
|
result = BED_SKEW_OFFSET_DETECTION_FITTING_FAILED;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM(", weigth Y: ");
|
SERIAL_ECHOPGM(", weigth Y: ");
|
||||||
MYSERIAL.print(w);
|
MYSERIAL.print(w);
|
||||||
if (sqrt(errX) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_X) SERIAL_ECHOPGM(", error X > max. error X");
|
if (sqrt(errX) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_X) SERIAL_ECHOPGM(", error X > max. error X");
|
||||||
if (w != 0.f && sqrt(errY) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_Y) SERIAL_ECHOPGM(", error Y > max. error Y");
|
if (w != 0.f && sqrt(errY) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_Y) SERIAL_ECHOPGM(", error Y > max. error Y");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if(verbosity_level >=20 ) SERIAL_ECHOPGM("Point not on first row");
|
if(verbosity_level >=20 ) SERIAL_ECHOPGM("Point not on first row");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
if (err > BED_CALIBRATION_POINT_OFFSET_MAX_EUCLIDIAN) {
|
if (err > BED_CALIBRATION_POINT_OFFSET_MAX_EUCLIDIAN) {
|
||||||
result = BED_SKEW_OFFSET_DETECTION_FITTING_FAILED;
|
result = BED_SKEW_OFFSET_DETECTION_FITTING_FAILED;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if(verbosity_level >= 20) SERIAL_ECHOPGM(", error > max. error euclidian");
|
if(verbosity_level >= 20) SERIAL_ECHOPGM(", error > max. error euclidian");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) {
|
if (verbosity_level >= 10) {
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOPGM("measured: (");
|
SERIAL_ECHOPGM("measured: (");
|
||||||
|
|
@ -508,9 +506,9 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("Max. errors:");
|
SERIAL_ECHOLNPGM("Max. errors:");
|
||||||
SERIAL_ECHOPGM("Max. error X:");
|
SERIAL_ECHOPGM("Max. error X:");
|
||||||
|
|
@ -521,26 +519,26 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
MYSERIAL.println(BED_CALIBRATION_POINT_OFFSET_MAX_EUCLIDIAN);
|
MYSERIAL.println(BED_CALIBRATION_POINT_OFFSET_MAX_EUCLIDIAN);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (result == BED_SKEW_OFFSET_DETECTION_PERFECT && fabs(a1) < bed_skew_angle_mild && fabs(a2) < bed_skew_angle_mild) {
|
if (result == BED_SKEW_OFFSET_DETECTION_PERFECT && fabs(a1) < bed_skew_angle_mild && fabs(a2) < bed_skew_angle_mild) {
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level > 0)
|
if (verbosity_level > 0)
|
||||||
SERIAL_ECHOLNPGM("Very little skew detected. Disabling skew correction.");
|
SERIAL_ECHOLNPGM("Very little skew detected. Disabling skew correction.");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Just disable the skew correction.
|
// Just disable the skew correction.
|
||||||
vec_x[0] = MACHINE_AXIS_SCALE_X;
|
vec_x[0] = MACHINE_AXIS_SCALE_X;
|
||||||
vec_x[1] = 0.f;
|
vec_x[1] = 0.f;
|
||||||
vec_y[0] = 0.f;
|
vec_y[0] = 0.f;
|
||||||
vec_y[1] = MACHINE_AXIS_SCALE_Y;
|
vec_y[1] = MACHINE_AXIS_SCALE_Y;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (result == BED_SKEW_OFFSET_DETECTION_PERFECT) {
|
if (result == BED_SKEW_OFFSET_DETECTION_PERFECT) {
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level > 0)
|
if (verbosity_level > 0)
|
||||||
SERIAL_ECHOLNPGM("Very little skew detected. Orthogonalizing the axes.");
|
SERIAL_ECHOLNPGM("Very little skew detected. Orthogonalizing the axes.");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Orthogonalize the axes.
|
// Orthogonalize the axes.
|
||||||
a1 = 0.5f * (a1 + a2);
|
a1 = 0.5f * (a1 + a2);
|
||||||
vec_x[0] = cos(a1) * MACHINE_AXIS_SCALE_X;
|
vec_x[0] = cos(a1) * MACHINE_AXIS_SCALE_X;
|
||||||
|
|
@ -558,7 +556,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
float w = point_weight_x(i, y);
|
float w = point_weight_x(i, y);
|
||||||
cntr[0] += w * (pgm_read_float(true_pts + i * 2) - x);
|
cntr[0] += w * (pgm_read_float(true_pts + i * 2) - x);
|
||||||
wx += w;
|
wx += w;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
MYSERIAL.print(i);
|
MYSERIAL.print(i);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
|
|
@ -571,11 +569,11 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
SERIAL_ECHOLNPGM("wx:");
|
SERIAL_ECHOLNPGM("wx:");
|
||||||
MYSERIAL.print(wx);
|
MYSERIAL.print(wx);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
w = point_weight_y(i, y);
|
w = point_weight_y(i, y);
|
||||||
cntr[1] += w * (pgm_read_float(true_pts + i * 2 + 1) - y);
|
cntr[1] += w * (pgm_read_float(true_pts + i * 2 + 1) - y);
|
||||||
wy += w;
|
wy += w;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOLNPGM("Weight_y:");
|
SERIAL_ECHOLNPGM("Weight_y:");
|
||||||
|
|
@ -589,12 +587,12 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
}
|
}
|
||||||
cntr[0] /= wx;
|
cntr[0] /= wx;
|
||||||
cntr[1] /= wy;
|
cntr[1] /= wy;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOLNPGM("Final cntr values:");
|
SERIAL_ECHOLNPGM("Final cntr values:");
|
||||||
|
|
@ -605,9 +603,9 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
MYSERIAL.print(cntr[1]);
|
MYSERIAL.print(cntr[1]);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Invert the transformation matrix made of vec_x, vec_y and cntr.
|
// Invert the transformation matrix made of vec_x, vec_y and cntr.
|
||||||
{
|
{
|
||||||
|
|
@ -627,7 +625,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
cntr[0] = cntrInv[0];
|
cntr[0] = cntrInv[0];
|
||||||
cntr[1] = cntrInv[1];
|
cntr[1] = cntrInv[1];
|
||||||
}
|
}
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 1) {
|
if (verbosity_level >= 1) {
|
||||||
// Show the adjusted state, before the fitting.
|
// Show the adjusted state, before the fitting.
|
||||||
SERIAL_ECHOPGM("X vector, adjusted: ");
|
SERIAL_ECHOPGM("X vector, adjusted: ");
|
||||||
|
|
@ -682,7 +680,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
||||||
}
|
}
|
||||||
delay_keep_alive(100);
|
delay_keep_alive(100);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -975,9 +973,9 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i
|
||||||
FORCE_HIGH_POWER_START;
|
FORCE_HIGH_POWER_START;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if(verbosity_level >= 10) SERIAL_ECHOLNPGM("find bed induction sensor point z");
|
if(verbosity_level >= 10) SERIAL_ECHOLNPGM("find bed induction sensor point z");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
bool endstops_enabled = enable_endstops(true);
|
bool endstops_enabled = enable_endstops(true);
|
||||||
bool endstop_z_enabled = enable_z_endstop(false);
|
bool endstop_z_enabled = enable_z_endstop(false);
|
||||||
float z = 0.f;
|
float z = 0.f;
|
||||||
|
|
@ -1065,9 +1063,9 @@ inline bool find_bed_induction_sensor_point_xy(int
|
||||||
#ifdef NEW_XYZCAL
|
#ifdef NEW_XYZCAL
|
||||||
return xyzcal_find_bed_induction_sensor_point_xy();
|
return xyzcal_find_bed_induction_sensor_point_xy();
|
||||||
#else //NEW_XYZCAL
|
#else //NEW_XYZCAL
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) MYSERIAL.println("find bed induction sensor point xy");
|
if (verbosity_level >= 10) MYSERIAL.println("find bed induction sensor point xy");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
float feedrate = homing_feedrate[X_AXIS] / 60.f;
|
float feedrate = homing_feedrate[X_AXIS] / 60.f;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
|
|
@ -1080,27 +1078,27 @@ inline bool find_bed_induction_sensor_point_xy(int
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
if (x0 < X_MIN_POS) {
|
if (x0 < X_MIN_POS) {
|
||||||
x0 = X_MIN_POS;
|
x0 = X_MIN_POS;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("X searching radius lower than X_MIN. Clamping was done.");
|
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("X searching radius lower than X_MIN. Clamping was done.");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
if (x1 > X_MAX_POS) {
|
if (x1 > X_MAX_POS) {
|
||||||
x1 = X_MAX_POS;
|
x1 = X_MAX_POS;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("X searching radius higher than X_MAX. Clamping was done.");
|
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("X searching radius higher than X_MAX. Clamping was done.");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
if (y0 < Y_MIN_POS_FOR_BED_CALIBRATION) {
|
if (y0 < Y_MIN_POS_FOR_BED_CALIBRATION) {
|
||||||
y0 = Y_MIN_POS_FOR_BED_CALIBRATION;
|
y0 = Y_MIN_POS_FOR_BED_CALIBRATION;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Y searching radius lower than Y_MIN. Clamping was done.");
|
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Y searching radius lower than Y_MIN. Clamping was done.");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
if (y1 > Y_MAX_POS) {
|
if (y1 > Y_MAX_POS) {
|
||||||
y1 = Y_MAX_POS;
|
y1 = Y_MAX_POS;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Y searching radius higher than X_MAX. Clamping was done.");
|
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Y searching radius higher than X_MAX. Clamping was done.");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
nsteps_y = int(ceil((y1 - y0) / FIND_BED_INDUCTION_SENSOR_POINT_XY_STEP));
|
nsteps_y = int(ceil((y1 - y0) / FIND_BED_INDUCTION_SENSOR_POINT_XY_STEP));
|
||||||
|
|
||||||
|
|
@ -1160,10 +1158,9 @@ inline bool find_bed_induction_sensor_point_xy(int
|
||||||
goto endloop;
|
goto endloop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endloop:
|
endloop:;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHO("First hit");
|
SERIAL_ECHO("First hit");
|
||||||
SERIAL_ECHO("- X: ");
|
SERIAL_ECHO("- X: ");
|
||||||
|
|
@ -1173,7 +1170,7 @@ endloop:
|
||||||
SERIAL_ECHO("; Z: ");
|
SERIAL_ECHO("; Z: ");
|
||||||
MYSERIAL.println(current_position[Z_AXIS]);
|
MYSERIAL.println(current_position[Z_AXIS]);
|
||||||
}
|
}
|
||||||
#endif //SUPPORT_VERBOSITY
|
#endif //SUPPORT_VERBOSITY
|
||||||
//lcd_show_fullscreen_message_and_wait_P(PSTR("First hit"));
|
//lcd_show_fullscreen_message_and_wait_P(PSTR("First hit"));
|
||||||
//lcd_update_enable(true);
|
//lcd_update_enable(true);
|
||||||
|
|
||||||
|
|
@ -1256,7 +1253,7 @@ endloop:
|
||||||
current_position[Y_AXIS] = 0.5f * (a + b);
|
current_position[Y_AXIS] = 0.5f * (a + b);
|
||||||
go_xy(current_position[X_AXIS], current_position[Y_AXIS], feedrate / 5);
|
go_xy(current_position[X_AXIS], current_position[Y_AXIS], feedrate / 5);
|
||||||
|
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM("ITERATION: ");
|
SERIAL_ECHOPGM("ITERATION: ");
|
||||||
MYSERIAL.println(iteration);
|
MYSERIAL.println(iteration);
|
||||||
|
|
@ -1265,7 +1262,7 @@ endloop:
|
||||||
SERIAL_ECHOPGM("CURRENT POSITION Y: ");
|
SERIAL_ECHOPGM("CURRENT POSITION Y: ");
|
||||||
MYSERIAL.println(current_position[Y_AXIS]);
|
MYSERIAL.println(current_position[Y_AXIS]);
|
||||||
}
|
}
|
||||||
#endif //SUPPORT_VERBOSITY
|
#endif //SUPPORT_VERBOSITY
|
||||||
|
|
||||||
if (iteration > 0) {
|
if (iteration > 0) {
|
||||||
// Average the last 7 measurements.
|
// Average the last 7 measurements.
|
||||||
|
|
@ -1285,21 +1282,21 @@ endloop:
|
||||||
|
|
||||||
current_position[X_AXIS] = avg[X_AXIS];
|
current_position[X_AXIS] = avg[X_AXIS];
|
||||||
current_position[Y_AXIS] = avg[Y_AXIS];
|
current_position[Y_AXIS] = avg[Y_AXIS];
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM("AVG CURRENT POSITION X: ");
|
SERIAL_ECHOPGM("AVG CURRENT POSITION X: ");
|
||||||
MYSERIAL.println(current_position[X_AXIS]);
|
MYSERIAL.println(current_position[X_AXIS]);
|
||||||
SERIAL_ECHOPGM("AVG CURRENT POSITION Y: ");
|
SERIAL_ECHOPGM("AVG CURRENT POSITION Y: ");
|
||||||
MYSERIAL.println(current_position[Y_AXIS]);
|
MYSERIAL.println(current_position[Y_AXIS]);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
go_xy(current_position[X_AXIS], current_position[Y_AXIS], feedrate);
|
go_xy(current_position[X_AXIS], current_position[Y_AXIS], feedrate);
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
lcd_show_fullscreen_message_and_wait_P(PSTR("Final position"));
|
lcd_show_fullscreen_message_and_wait_P(PSTR("Final position"));
|
||||||
lcd_update_enable(true);
|
lcd_update_enable(true);
|
||||||
}
|
}
|
||||||
#endif //SUPPORT_VERBOSITY
|
#endif //SUPPORT_VERBOSITY
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1316,9 +1313,9 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
|
||||||
#ifdef NEW_XYZCAL
|
#ifdef NEW_XYZCAL
|
||||||
return xyzcal_find_bed_induction_sensor_point_xy();
|
return xyzcal_find_bed_induction_sensor_point_xy();
|
||||||
#else //NEW_XYZCAL
|
#else //NEW_XYZCAL
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) MYSERIAL.println("find bed induction sensor point xy");
|
if (verbosity_level >= 10) MYSERIAL.println("find bed induction sensor point xy");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
float feedrate = homing_feedrate[X_AXIS] / 60.f;
|
float feedrate = homing_feedrate[X_AXIS] / 60.f;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
|
|
@ -1331,27 +1328,27 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
if (x0 < X_MIN_POS) {
|
if (x0 < X_MIN_POS) {
|
||||||
x0 = X_MIN_POS;
|
x0 = X_MIN_POS;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("X searching radius lower than X_MIN. Clamping was done.");
|
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("X searching radius lower than X_MIN. Clamping was done.");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
if (x1 > X_MAX_POS) {
|
if (x1 > X_MAX_POS) {
|
||||||
x1 = X_MAX_POS;
|
x1 = X_MAX_POS;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("X searching radius higher than X_MAX. Clamping was done.");
|
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("X searching radius higher than X_MAX. Clamping was done.");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
if (y0 < Y_MIN_POS_FOR_BED_CALIBRATION) {
|
if (y0 < Y_MIN_POS_FOR_BED_CALIBRATION) {
|
||||||
y0 = Y_MIN_POS_FOR_BED_CALIBRATION;
|
y0 = Y_MIN_POS_FOR_BED_CALIBRATION;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Y searching radius lower than Y_MIN. Clamping was done.");
|
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Y searching radius lower than Y_MIN. Clamping was done.");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
if (y1 > Y_MAX_POS) {
|
if (y1 > Y_MAX_POS) {
|
||||||
y1 = Y_MAX_POS;
|
y1 = Y_MAX_POS;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Y searching radius higher than X_MAX. Clamping was done.");
|
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Y searching radius higher than X_MAX. Clamping was done.");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
nsteps_y = int(ceil((y1 - y0) / FIND_BED_INDUCTION_SENSOR_POINT_XY_STEP));
|
nsteps_y = int(ceil((y1 - y0) / FIND_BED_INDUCTION_SENSOR_POINT_XY_STEP));
|
||||||
|
|
||||||
|
|
@ -1383,7 +1380,7 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
|
||||||
goto endloop;
|
goto endloop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endloop:
|
endloop:
|
||||||
// SERIAL_ECHOLN("First hit");
|
// SERIAL_ECHOLN("First hit");
|
||||||
|
|
||||||
// we have to let the planner know where we are right now as it is not where we said to go.
|
// we have to let the planner know where we are right now as it is not where we said to go.
|
||||||
|
|
@ -1664,13 +1661,13 @@ inline bool improve_bed_induction_sensor_point2(bool lift_z_on_min_y, int8_t ver
|
||||||
}
|
}
|
||||||
b = current_position[X_AXIS];
|
b = current_position[X_AXIS];
|
||||||
if (b - a < MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
if (b - a < MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
SERIAL_ECHOPGM("Point width too small: ");
|
SERIAL_ECHOPGM("Point width too small: ");
|
||||||
SERIAL_ECHO(b - a);
|
SERIAL_ECHO(b - a);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
// We force the calibration routine to move the Z axis slightly down to make the response more pronounced.
|
// We force the calibration routine to move the Z axis slightly down to make the response more pronounced.
|
||||||
if (b - a < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
if (b - a < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
||||||
// Don't use the new X value.
|
// Don't use the new X value.
|
||||||
|
|
@ -1681,12 +1678,12 @@ inline bool improve_bed_induction_sensor_point2(bool lift_z_on_min_y, int8_t ver
|
||||||
point_small = true;
|
point_small = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
// Go to the center.
|
// Go to the center.
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
|
|
@ -1739,13 +1736,13 @@ inline bool improve_bed_induction_sensor_point2(bool lift_z_on_min_y, int8_t ver
|
||||||
b = current_position[Y_AXIS];
|
b = current_position[Y_AXIS];
|
||||||
if (b - a < MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
if (b - a < MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
||||||
// We force the calibration routine to move the Z axis slightly down to make the response more pronounced.
|
// We force the calibration routine to move the Z axis slightly down to make the response more pronounced.
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
SERIAL_ECHOPGM("Point height too small: ");
|
SERIAL_ECHOPGM("Point height too small: ");
|
||||||
SERIAL_ECHO(b - a);
|
SERIAL_ECHO(b - a);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
if (b - a < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
if (b - a < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
||||||
// Don't use the new Y value.
|
// Don't use the new Y value.
|
||||||
current_position[Y_AXIS] = center_old_y;
|
current_position[Y_AXIS] = center_old_y;
|
||||||
|
|
@ -1755,12 +1752,12 @@ inline bool improve_bed_induction_sensor_point2(bool lift_z_on_min_y, int8_t ver
|
||||||
point_small = true;
|
point_small = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
debug_output_point(PSTR("top" ), current_position[X_AXIS], a, current_position[Z_AXIS]);
|
debug_output_point(PSTR("top" ), current_position[X_AXIS], a, current_position[Z_AXIS]);
|
||||||
debug_output_point(PSTR("bottom"), current_position[X_AXIS], b, current_position[Z_AXIS]);
|
debug_output_point(PSTR("bottom"), current_position[X_AXIS], b, current_position[Z_AXIS]);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
// Go to the center.
|
// Go to the center.
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
|
|
@ -1795,9 +1792,9 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
||||||
float center_old_y = current_position[Y_AXIS];
|
float center_old_y = current_position[Y_AXIS];
|
||||||
float a, b;
|
float a, b;
|
||||||
bool result = true;
|
bool result = true;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) MYSERIAL.println("Improve bed induction sensor point3");
|
if (verbosity_level >= 20) MYSERIAL.println("Improve bed induction sensor point3");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Was the sensor point detected too far in the minus Y axis?
|
// Was the sensor point detected too far in the minus Y axis?
|
||||||
// If yes, the center of the induction point cannot be reached by the machine.
|
// If yes, the center of the induction point cannot be reached by the machine.
|
||||||
{
|
{
|
||||||
|
|
@ -1815,7 +1812,7 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
||||||
y0 = Y_MIN_POS_FOR_BED_CALIBRATION;
|
y0 = Y_MIN_POS_FOR_BED_CALIBRATION;
|
||||||
if (y1 > Y_MAX_POS)
|
if (y1 > Y_MAX_POS)
|
||||||
y1 = Y_MAX_POS;
|
y1 = Y_MAX_POS;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM("Initial position: ");
|
SERIAL_ECHOPGM("Initial position: ");
|
||||||
SERIAL_ECHO(center_old_x);
|
SERIAL_ECHO(center_old_x);
|
||||||
|
|
@ -1823,7 +1820,7 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
||||||
SERIAL_ECHO(center_old_y);
|
SERIAL_ECHO(center_old_y);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
// Search in the positive Y direction, until a maximum diameter is found.
|
// Search in the positive Y direction, until a maximum diameter is found.
|
||||||
// (the next diameter is smaller than the current one.)
|
// (the next diameter is smaller than the current one.)
|
||||||
|
|
@ -1855,12 +1852,12 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
||||||
// goto canceled;
|
// goto canceled;
|
||||||
}
|
}
|
||||||
b = current_position[X_AXIS];
|
b = current_position[X_AXIS];
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
float d = b - a;
|
float d = b - a;
|
||||||
if (d > dmax) {
|
if (d > dmax) {
|
||||||
xmax1 = 0.5f * (a + b);
|
xmax1 = 0.5f * (a + b);
|
||||||
|
|
@ -1871,10 +1868,10 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dmax == 0.) {
|
if (dmax == 0.) {
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level > 0)
|
if (verbosity_level > 0)
|
||||||
SERIAL_PROTOCOLPGM("failed - not found\n");
|
SERIAL_PROTOCOLPGM("failed - not found\n");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
current_position[X_AXIS] = center_old_x;
|
current_position[X_AXIS] = center_old_x;
|
||||||
current_position[Y_AXIS] = center_old_y;
|
current_position[Y_AXIS] = center_old_y;
|
||||||
goto canceled;
|
goto canceled;
|
||||||
|
|
@ -1891,10 +1888,10 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
||||||
current_position[Y_AXIS] = center_old_y;
|
current_position[Y_AXIS] = center_old_y;
|
||||||
goto canceled;
|
goto canceled;
|
||||||
}
|
}
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5)
|
if (verbosity_level >= 5)
|
||||||
debug_output_point(PSTR("top" ), current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("top" ), current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
y1 = current_position[Y_AXIS];
|
y1 = current_position[Y_AXIS];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1937,12 +1934,12 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
b = current_position[X_AXIS];
|
b = current_position[X_AXIS];
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
float d = b - a;
|
float d = b - a;
|
||||||
if (d > dmax) {
|
if (d > dmax) {
|
||||||
xmax2 = 0.5f * (a + b);
|
xmax2 = 0.5f * (a + b);
|
||||||
|
|
@ -1990,12 +1987,12 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
b = current_position[X_AXIS];
|
b = current_position[X_AXIS];
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
float d = b - a;
|
float d = b - a;
|
||||||
if (d > dmax) {
|
if (d > dmax) {
|
||||||
xmax = 0.5f * (a + b);
|
xmax = 0.5f * (a + b);
|
||||||
|
|
@ -2017,28 +2014,28 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
||||||
current_position[Y_AXIS] = center_old_y;
|
current_position[Y_AXIS] = center_old_y;
|
||||||
goto canceled;
|
goto canceled;
|
||||||
}
|
}
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5)
|
if (verbosity_level >= 5)
|
||||||
debug_output_point(PSTR("top" ), current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("top" ), current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
if (current_position[Y_AXIS] - Y_MIN_POS_FOR_BED_CALIBRATION < 0.5f * dmax) {
|
if (current_position[Y_AXIS] - Y_MIN_POS_FOR_BED_CALIBRATION < 0.5f * dmax) {
|
||||||
// Probably not even a half circle was detected. The induction point is likely too far in the minus Y direction.
|
// Probably not even a half circle was detected. The induction point is likely too far in the minus Y direction.
|
||||||
// First verify, if the measurement has been done at a sufficient height. If no, lower the Z axis a bit.
|
// First verify, if the measurement has been done at a sufficient height. If no, lower the Z axis a bit.
|
||||||
if (current_position[Y_AXIS] < ymax || dmax < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
if (current_position[Y_AXIS] < ymax || dmax < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
SERIAL_ECHOPGM("Partial point diameter too small: ");
|
SERIAL_ECHOPGM("Partial point diameter too small: ");
|
||||||
SERIAL_ECHO(dmax);
|
SERIAL_ECHO(dmax);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
result = false;
|
result = false;
|
||||||
} else {
|
} else {
|
||||||
// Estimate the circle radius from the maximum diameter and height:
|
// Estimate the circle radius from the maximum diameter and height:
|
||||||
float h = current_position[Y_AXIS] - ymax;
|
float h = current_position[Y_AXIS] - ymax;
|
||||||
float r = dmax * dmax / (8.f * h) + 0.5f * h;
|
float r = dmax * dmax / (8.f * h) + 0.5f * h;
|
||||||
if (r < 0.8f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
if (r < 0.8f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
SERIAL_ECHOPGM("Partial point estimated radius too small: ");
|
SERIAL_ECHOPGM("Partial point estimated radius too small: ");
|
||||||
SERIAL_ECHO(r);
|
SERIAL_ECHO(r);
|
||||||
|
|
@ -2048,7 +2045,7 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
||||||
SERIAL_ECHO(h);
|
SERIAL_ECHO(h);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
result = false;
|
result = false;
|
||||||
} else {
|
} else {
|
||||||
// The point may end up outside of the machine working space.
|
// The point may end up outside of the machine working space.
|
||||||
|
|
@ -2075,7 +2072,7 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
current_position[X_AXIS] = xmax;
|
current_position[X_AXIS] = xmax;
|
||||||
current_position[Y_AXIS] = ymax;
|
current_position[Y_AXIS] = ymax;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM("Adjusted position: ");
|
SERIAL_ECHOPGM("Adjusted position: ");
|
||||||
SERIAL_ECHO(current_position[X_AXIS]);
|
SERIAL_ECHO(current_position[X_AXIS]);
|
||||||
|
|
@ -2083,7 +2080,7 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
||||||
SERIAL_ECHO(current_position[Y_AXIS]);
|
SERIAL_ECHO(current_position[Y_AXIS]);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
// Don't clamp current_position[Y_AXIS], because the out-of-reach Y coordinate may actually be true.
|
// Don't clamp current_position[Y_AXIS], because the out-of-reach Y coordinate may actually be true.
|
||||||
// Only clamp the coordinate to go.
|
// Only clamp the coordinate to go.
|
||||||
|
|
@ -2181,7 +2178,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
|
|
||||||
SERIAL_ECHOPGM("Iteration: ");
|
SERIAL_ECHOPGM("Iteration: ");
|
||||||
MYSERIAL.println(int(iteration + 1));
|
MYSERIAL.println(int(iteration + 1));
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("Vectors: ");
|
SERIAL_ECHOLNPGM("Vectors: ");
|
||||||
|
|
||||||
|
|
@ -2204,7 +2201,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
MYSERIAL.print(cntr[1], 5);
|
MYSERIAL.print(cntr[1], 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
#ifdef MESH_BED_CALIBRATION_SHOW_LCD
|
#ifdef MESH_BED_CALIBRATION_SHOW_LCD
|
||||||
uint8_t next_line;
|
uint8_t next_line;
|
||||||
lcd_display_message_fullscreen_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1), next_line);
|
lcd_display_message_fullscreen_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1), next_line);
|
||||||
|
|
@ -2231,7 +2228,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
// Go up to z_initial.
|
// Go up to z_initial.
|
||||||
|
|
||||||
go_to_current(homing_feedrate[Z_AXIS] / 60.f);
|
go_to_current(homing_feedrate[Z_AXIS] / 60.f);
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
// Go to Y0, wait, then go to Y-4.
|
// Go to Y0, wait, then go to Y-4.
|
||||||
current_position[Y_AXIS] = 0.f;
|
current_position[Y_AXIS] = 0.f;
|
||||||
|
|
@ -2243,7 +2240,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
SERIAL_ECHOLNPGM("At Y-4");
|
SERIAL_ECHOLNPGM("At Y-4");
|
||||||
delay_keep_alive(5000);
|
delay_keep_alive(5000);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Go to the measurement point position.
|
// Go to the measurement point position.
|
||||||
//if (iteration == 0) {
|
//if (iteration == 0) {
|
||||||
current_position[X_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2);
|
current_position[X_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2);
|
||||||
|
|
@ -2261,7 +2258,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION;
|
current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION;
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM("current_position[X_AXIS]:");
|
SERIAL_ECHOPGM("current_position[X_AXIS]:");
|
||||||
MYSERIAL.print(current_position[X_AXIS], 5);
|
MYSERIAL.print(current_position[X_AXIS], 5);
|
||||||
|
|
@ -2273,13 +2270,13 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
MYSERIAL.print(current_position[Z_AXIS], 5);
|
MYSERIAL.print(current_position[Z_AXIS], 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
go_to_current(homing_feedrate[X_AXIS] / 60.f);
|
go_to_current(homing_feedrate[X_AXIS] / 60.f);
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10)
|
if (verbosity_level >= 10)
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
if (!find_bed_induction_sensor_point_xy(verbosity_level))
|
if (!find_bed_induction_sensor_point_xy(verbosity_level))
|
||||||
return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
|
return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
|
||||||
#ifndef NEW_XYZCAL
|
#ifndef NEW_XYZCAL
|
||||||
|
|
@ -2306,19 +2303,19 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
}
|
}
|
||||||
#endif //HEATBED_V2
|
#endif //HEATBED_V2
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10)
|
if (verbosity_level >= 10)
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Save the detected point position and then clamp the Y coordinate, which may have been estimated
|
// Save the detected point position and then clamp the Y coordinate, which may have been estimated
|
||||||
// to lie outside the machine working space.
|
// to lie outside the machine working space.
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("Measured:");
|
SERIAL_ECHOLNPGM("Measured:");
|
||||||
MYSERIAL.println(current_position[X_AXIS]);
|
MYSERIAL.println(current_position[X_AXIS]);
|
||||||
MYSERIAL.println(current_position[Y_AXIS]);
|
MYSERIAL.println(current_position[Y_AXIS]);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
pt[0] = (pt[0] * iteration) / (iteration + 1);
|
pt[0] = (pt[0] * iteration) / (iteration + 1);
|
||||||
pt[0] += (current_position[X_AXIS]/(iteration + 1)); //count average
|
pt[0] += (current_position[X_AXIS]/(iteration + 1)); //count average
|
||||||
pt[1] = (pt[1] * iteration) / (iteration + 1);
|
pt[1] = (pt[1] * iteration) / (iteration + 1);
|
||||||
|
|
@ -2331,7 +2328,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
//pt[1] += current_position[Y_AXIS];
|
//pt[1] += current_position[Y_AXIS];
|
||||||
//if (iteration > 0) pt[1] = pt[1] / 2;
|
//if (iteration > 0) pt[1] = pt[1] / 2;
|
||||||
|
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOPGM("pt[0]:");
|
SERIAL_ECHOPGM("pt[0]:");
|
||||||
|
|
@ -2339,7 +2336,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
SERIAL_ECHOPGM("pt[1]:");
|
SERIAL_ECHOPGM("pt[1]:");
|
||||||
MYSERIAL.println(pt[1]);
|
MYSERIAL.println(pt[1]);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
if (current_position[Y_AXIS] < Y_MIN_POS)
|
if (current_position[Y_AXIS] < Y_MIN_POS)
|
||||||
current_position[Y_AXIS] = Y_MIN_POS;
|
current_position[Y_AXIS] = Y_MIN_POS;
|
||||||
|
|
@ -2347,18 +2344,18 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
current_position[Z_AXIS] += 3.f + FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP * iteration * 0.3;
|
current_position[Z_AXIS] += 3.f + FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP * iteration * 0.3;
|
||||||
//cntr[0] += pt[0];
|
//cntr[0] += pt[0];
|
||||||
//cntr[1] += pt[1];
|
//cntr[1] += pt[1];
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10 && k == 0) {
|
if (verbosity_level >= 10 && k == 0) {
|
||||||
// Show the zero. Test, whether the Y motor skipped steps.
|
// Show the zero. Test, whether the Y motor skipped steps.
|
||||||
current_position[Y_AXIS] = MANUAL_Y_HOME_POS;
|
current_position[Y_AXIS] = MANUAL_Y_HOME_POS;
|
||||||
go_to_current(homing_feedrate[X_AXIS] / 60.f);
|
go_to_current(homing_feedrate[X_AXIS] / 60.f);
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity
|
delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity
|
||||||
|
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
// Test the positions. Are the positions reproducible? Now the calibration is active in the planner.
|
// Test the positions. Are the positions reproducible? Now the calibration is active in the planner.
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
|
|
@ -2373,7 +2370,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
if (pts[1] < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH) {
|
if (pts[1] < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH) {
|
||||||
too_far_mask |= 1 << 1; //front center point is out of reach
|
too_far_mask |= 1 << 1; //front center point is out of reach
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
|
|
@ -2396,7 +2393,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
eeprom_update_float((float*)(EEPROM_BED_CALIBRATION_VEC_Y + 0), vec_y[0]);
|
eeprom_update_float((float*)(EEPROM_BED_CALIBRATION_VEC_Y + 0), vec_y[0]);
|
||||||
eeprom_update_float((float*)(EEPROM_BED_CALIBRATION_VEC_Y + 4), vec_y[1]);
|
eeprom_update_float((float*)(EEPROM_BED_CALIBRATION_VEC_Y + 4), vec_y[1]);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) {
|
if (verbosity_level >= 10) {
|
||||||
// Length of the vec_x
|
// Length of the vec_x
|
||||||
float l = sqrt(vec_x[0] * vec_x[0] + vec_x[1] * vec_x[1]);
|
float l = sqrt(vec_x[0] * vec_x[0] + vec_x[1] * vec_x[1]);
|
||||||
|
|
@ -2418,11 +2415,11 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
MYSERIAL.println(fabs(l));
|
MYSERIAL.println(fabs(l));
|
||||||
SERIAL_ECHOLNPGM("Saving bed calibration vectors to EEPROM");
|
SERIAL_ECHOLNPGM("Saving bed calibration vectors to EEPROM");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Correct the current_position to match the transformed coordinate system after world2machine_rotation_and_skew and world2machine_shift were set.
|
// Correct the current_position to match the transformed coordinate system after world2machine_rotation_and_skew and world2machine_shift were set.
|
||||||
world2machine_update_current();
|
world2machine_update_current();
|
||||||
|
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
// Test the positions. Are the positions reproducible? Now the calibration is active in the planner.
|
// Test the positions. Are the positions reproducible? Now the calibration is active in the planner.
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
|
|
@ -2437,7 +2434,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (result == BED_SKEW_OFFSET_DETECTION_FITTING_FAILED && too_far_mask == 2) return result; //if fitting failed and front center point is out of reach, terminate calibration and inform user
|
if (result == BED_SKEW_OFFSET_DETECTION_FITTING_FAILED && too_far_mask == 2) return result; //if fitting failed and front center point is out of reach, terminate calibration and inform user
|
||||||
|
|
@ -2462,9 +2459,9 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
float *vec_y = vec_x + 2;
|
float *vec_y = vec_x + 2;
|
||||||
float *cntr = vec_y + 2;
|
float *cntr = vec_y + 2;
|
||||||
memset(pts, 0, sizeof(float) * 7 * 7);
|
memset(pts, 0, sizeof(float) * 7 * 7);
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) SERIAL_ECHOLNPGM("Improving bed offset and skew");
|
if (verbosity_level >= 10) SERIAL_ECHOLNPGM("Improving bed offset and skew");
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Cache the current correction matrix.
|
// Cache the current correction matrix.
|
||||||
world2machine_initialize();
|
world2machine_initialize();
|
||||||
vec_x[0] = world2machine_rotation_and_skew[0][0];
|
vec_x[0] = world2machine_rotation_and_skew[0][0];
|
||||||
|
|
@ -2503,7 +2500,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
enable_endstops(false);
|
enable_endstops(false);
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
go_to_current(homing_feedrate[Z_AXIS]/60);
|
go_to_current(homing_feedrate[Z_AXIS]/60);
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
// Go to Y0, wait, then go to Y-4.
|
// Go to Y0, wait, then go to Y-4.
|
||||||
current_position[Y_AXIS] = 0.f;
|
current_position[Y_AXIS] = 0.f;
|
||||||
|
|
@ -2515,40 +2512,40 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
SERIAL_ECHOLNPGM("At Y_MIN_POS");
|
SERIAL_ECHOLNPGM("At Y_MIN_POS");
|
||||||
delay_keep_alive(5000);
|
delay_keep_alive(5000);
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Go to the measurement point.
|
// Go to the measurement point.
|
||||||
// Use the coorrected coordinate, which is a result of find_bed_offset_and_skew().
|
// Use the coorrected coordinate, which is a result of find_bed_offset_and_skew().
|
||||||
current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4+mesh_point*2) + vec_y[0] * pgm_read_float(bed_ref_points_4+mesh_point*2+1) + cntr[0];
|
current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4+mesh_point*2) + vec_y[0] * pgm_read_float(bed_ref_points_4+mesh_point*2+1) + cntr[0];
|
||||||
current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4+mesh_point*2) + vec_y[1] * pgm_read_float(bed_ref_points_4+mesh_point*2+1) + cntr[1];
|
current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4+mesh_point*2) + vec_y[1] * pgm_read_float(bed_ref_points_4+mesh_point*2+1) + cntr[1];
|
||||||
// The calibration points are very close to the min Y.
|
// The calibration points are very close to the min Y.
|
||||||
if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION) {
|
if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION){
|
||||||
current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION;
|
current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION;
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM("Calibration point ");
|
SERIAL_ECHOPGM("Calibration point ");
|
||||||
SERIAL_ECHO(mesh_point);
|
SERIAL_ECHO(mesh_point);
|
||||||
SERIAL_ECHOPGM("lower than Ymin. Y coordinate clamping was used.");
|
SERIAL_ECHOPGM("lower than Ymin. Y coordinate clamping was used.");
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
go_to_current(homing_feedrate[X_AXIS]/60);
|
go_to_current(homing_feedrate[X_AXIS]/60);
|
||||||
// Find its Z position by running the normal vertical search.
|
// Find its Z position by running the normal vertical search.
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10)
|
if (verbosity_level >= 10)
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
find_bed_induction_sensor_point_z();
|
find_bed_induction_sensor_point_z();
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10)
|
if (verbosity_level >= 10)
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Try to move the Z axis down a bit to increase a chance of the sensor to trigger.
|
// Try to move the Z axis down a bit to increase a chance of the sensor to trigger.
|
||||||
current_position[Z_AXIS] -= 0.025f;
|
current_position[Z_AXIS] -= 0.025f;
|
||||||
// Improve the point position by searching its center in a current plane.
|
// Improve the point position by searching its center in a current plane.
|
||||||
int8_t n_errors = 3;
|
int8_t n_errors = 3;
|
||||||
for (int8_t iter = 0; iter < 8; ) {
|
for (int8_t iter = 0; iter < 8; ) {
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level > 20) {
|
if (verbosity_level > 20) {
|
||||||
SERIAL_ECHOPGM("Improving bed point ");
|
SERIAL_ECHOPGM("Improving bed point ");
|
||||||
SERIAL_ECHO(mesh_point);
|
SERIAL_ECHO(mesh_point);
|
||||||
|
|
@ -2558,7 +2555,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
MYSERIAL.print(current_position[Z_AXIS], 5);
|
MYSERIAL.print(current_position[Z_AXIS], 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (mesh_point < 2) {
|
if (mesh_point < 2) {
|
||||||
// Because the sensor cannot move in front of the first row
|
// Because the sensor cannot move in front of the first row
|
||||||
|
|
@ -2568,14 +2565,9 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
found = improve_bed_induction_sensor_point3(verbosity_level);
|
found = improve_bed_induction_sensor_point3(verbosity_level);
|
||||||
} else {
|
} else {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case 0:
|
case 0: found = improve_bed_induction_sensor_point(); break;
|
||||||
found = improve_bed_induction_sensor_point();
|
case 1: found = improve_bed_induction_sensor_point2(mesh_point < 2, verbosity_level); break;
|
||||||
break;
|
default: break;
|
||||||
case 1:
|
|
||||||
found = improve_bed_induction_sensor_point2(mesh_point < 2, verbosity_level);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found) {
|
if (found) {
|
||||||
|
|
@ -2597,7 +2589,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
enable_endstops(false);
|
enable_endstops(false);
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
go_to_current(homing_feedrate[Z_AXIS]);
|
go_to_current(homing_feedrate[Z_AXIS]);
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
SERIAL_ECHOPGM("Improving bed point ");
|
SERIAL_ECHOPGM("Improving bed point ");
|
||||||
SERIAL_ECHO(mesh_point);
|
SERIAL_ECHO(mesh_point);
|
||||||
|
|
@ -2607,13 +2599,13 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
MYSERIAL.print(current_position[Z_AXIS], 5);
|
MYSERIAL.print(current_position[Z_AXIS], 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10)
|
if (verbosity_level >= 10)
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
// Don't let the manage_inactivity() function remove power from the motors.
|
// Don't let the manage_inactivity() function remove power from the motors.
|
||||||
refresh_cmd_timeout();
|
refresh_cmd_timeout();
|
||||||
|
|
@ -2625,7 +2617,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
enable_endstops(false);
|
enable_endstops(false);
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
|
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
// Test the positions. Are the positions reproducible?
|
// Test the positions. Are the positions reproducible?
|
||||||
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
|
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
|
||||||
|
|
@ -2649,7 +2641,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
{
|
{
|
||||||
// First fill in the too_far_mask from the measured points.
|
// First fill in the too_far_mask from the measured points.
|
||||||
|
|
@ -2664,7 +2656,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
// In case of success, update the too_far_mask from the calculated points.
|
// In case of success, update the too_far_mask from the calculated points.
|
||||||
for (uint8_t mesh_point = 0; mesh_point < 2; ++ mesh_point) {
|
for (uint8_t mesh_point = 0; mesh_point < 2; ++ mesh_point) {
|
||||||
float y = vec_x[1] * pgm_read_float(bed_ref_points_4+mesh_point*2) + vec_y[1] * pgm_read_float(bed_ref_points_4+mesh_point*2+1) + cntr[1];
|
float y = vec_x[1] * pgm_read_float(bed_ref_points_4+mesh_point*2) + vec_y[1] * pgm_read_float(bed_ref_points_4+mesh_point*2+1) + cntr[1];
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOPGM("Distance from min:");
|
SERIAL_ECHOPGM("Distance from min:");
|
||||||
|
|
@ -2674,7 +2666,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
MYSERIAL.print(y);
|
MYSERIAL.print(y);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
if (y < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH)
|
if (y < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH)
|
||||||
too_far_mask |= 1 << mesh_point;
|
too_far_mask |= 1 << mesh_point;
|
||||||
}
|
}
|
||||||
|
|
@ -2696,7 +2688,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
|
|
||||||
enable_endstops(false);
|
enable_endstops(false);
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
// Test the positions. Are the positions reproducible? Now the calibration is active in the planner.
|
// Test the positions. Are the positions reproducible? Now the calibration is active in the planner.
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
|
|
@ -2725,7 +2717,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_VERBOSITY
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
if(!sample_z())
|
if(!sample_z())
|
||||||
goto canceled;
|
goto canceled;
|
||||||
|
|
@ -2894,7 +2886,7 @@ bool sample_mesh_and_store_reference()
|
||||||
float dif = mbl.z_values[j][i] - mbl.z_values[0][0];
|
float dif = mbl.z_values[j][i] - mbl.z_values[0][0];
|
||||||
int16_t dif_quantized = int16_t(floor(dif * 100.f + 0.5f));
|
int16_t dif_quantized = int16_t(floor(dif * 100.f + 0.5f));
|
||||||
eeprom_update_word((uint16_t*)addr, *reinterpret_cast<uint16_t*>(&dif_quantized));
|
eeprom_update_word((uint16_t*)addr, *reinterpret_cast<uint16_t*>(&dif_quantized));
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
uint16_t z_offset_u = eeprom_read_word((uint16_t*)addr);
|
uint16_t z_offset_u = eeprom_read_word((uint16_t*)addr);
|
||||||
float dif2 = *reinterpret_cast<int16_t*>(&z_offset_u) * 0.01;
|
float dif2 = *reinterpret_cast<int16_t*>(&z_offset_u) * 0.01;
|
||||||
|
|
@ -2909,7 +2901,7 @@ bool sample_mesh_and_store_reference()
|
||||||
MYSERIAL.print(dif2, 5);
|
MYSERIAL.print(dif2, 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
addr += 2;
|
addr += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3013,7 +3005,7 @@ void babystep_load()
|
||||||
// End of G80: Apply the baby stepping value.
|
// End of G80: Apply the baby stepping value.
|
||||||
EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystepLoadZ);
|
EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystepLoadZ);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
SERIAL_ECHO("Z baby step: ");
|
SERIAL_ECHO("Z baby step: ");
|
||||||
SERIAL_ECHO(babystepLoadZ);
|
SERIAL_ECHO(babystepLoadZ);
|
||||||
SERIAL_ECHO(", current Z: ");
|
SERIAL_ECHO(", current Z: ");
|
||||||
|
|
@ -3021,7 +3013,7 @@ void babystep_load()
|
||||||
SERIAL_ECHO("correction: ");
|
SERIAL_ECHO("correction: ");
|
||||||
SERIAL_ECHO(float(babystepLoadZ) / float(axis_steps_per_unit[Z_AXIS]));
|
SERIAL_ECHO(float(babystepLoadZ) / float(axis_steps_per_unit[Z_AXIS]));
|
||||||
SERIAL_ECHOLN("");
|
SERIAL_ECHOLN("");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,7 @@
|
||||||
|
|
||||||
mesh_bed_leveling mbl;
|
mesh_bed_leveling mbl;
|
||||||
|
|
||||||
mesh_bed_leveling::mesh_bed_leveling() {
|
mesh_bed_leveling::mesh_bed_leveling() { reset(); }
|
||||||
reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void mesh_bed_leveling::reset() {
|
void mesh_bed_leveling::reset() {
|
||||||
active = 0;
|
active = 0;
|
||||||
|
|
@ -118,16 +116,16 @@ void mesh_bed_leveling::upsample_3x3()
|
||||||
if (i == idx1)
|
if (i == idx1)
|
||||||
continue;
|
continue;
|
||||||
float x = get_x(i);
|
float x = get_x(i);
|
||||||
#ifdef MBL_BILINEAR
|
#ifdef MBL_BILINEAR
|
||||||
z_values[j][i] = (x < x1) ?
|
z_values[j][i] = (x < x1) ?
|
||||||
((z_values[j][idx0] * (x - x0) + z_values[j][idx1] * (x1 - x)) / (x1 - x0)) :
|
((z_values[j][idx0] * (x - x0) + z_values[j][idx1] * (x1 - x)) / (x1 - x0)) :
|
||||||
((z_values[j][idx1] * (x - x1) + z_values[j][idx2] * (x2 - x)) / (x2 - x1));
|
((z_values[j][idx1] * (x - x1) + z_values[j][idx2] * (x2 - x)) / (x2 - x1));
|
||||||
#else
|
#else
|
||||||
z_values[j][i] =
|
z_values[j][i] =
|
||||||
z_values[j][idx0] * (x - x1) * (x - x2) / ((x0 - x1) * (x0 - x2)) +
|
z_values[j][idx0] * (x - x1) * (x - x2) / ((x0 - x1) * (x0 - x2)) +
|
||||||
z_values[j][idx1] * (x - x0) * (x - x2) / ((x1 - x0) * (x1 - x2)) +
|
z_values[j][idx1] * (x - x0) * (x - x2) / ((x1 - x0) * (x1 - x2)) +
|
||||||
z_values[j][idx2] * (x - x0) * (x - x1) / ((x2 - x0) * (x2 - x1));
|
z_values[j][idx2] * (x - x0) * (x - x1) / ((x2 - x0) * (x2 - x1));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -145,21 +143,21 @@ void mesh_bed_leveling::upsample_3x3()
|
||||||
if (j == idx1)
|
if (j == idx1)
|
||||||
continue;
|
continue;
|
||||||
float y = get_y(j);
|
float y = get_y(j);
|
||||||
#ifdef MBL_BILINEAR
|
#ifdef MBL_BILINEAR
|
||||||
z_values[j][i] = (y < y1) ?
|
z_values[j][i] = (y < y1) ?
|
||||||
((z_values[idx0][i] * (y - y0) + z_values[idx1][i] * (y1 - y)) / (y1 - y0)) :
|
((z_values[idx0][i] * (y - y0) + z_values[idx1][i] * (y1 - y)) / (y1 - y0)) :
|
||||||
((z_values[idx1][i] * (y - y1) + z_values[idx2][i] * (y2 - y)) / (y2 - y1));
|
((z_values[idx1][i] * (y - y1) + z_values[idx2][i] * (y2 - y)) / (y2 - y1));
|
||||||
#else
|
#else
|
||||||
z_values[j][i] =
|
z_values[j][i] =
|
||||||
z_values[idx0][i] * (y - y1) * (y - y2) / ((y0 - y1) * (y0 - y2)) +
|
z_values[idx0][i] * (y - y1) * (y - y2) / ((y0 - y1) * (y0 - y2)) +
|
||||||
z_values[idx1][i] * (y - y0) * (y - y2) / ((y1 - y0) * (y1 - y2)) +
|
z_values[idx1][i] * (y - y0) * (y - y2) / ((y1 - y0) * (y1 - y2)) +
|
||||||
z_values[idx2][i] * (y - y0) * (y - y1) / ((y2 - y0) * (y2 - y1));
|
z_values[idx2][i] * (y - y0) * (y - y1) / ((y2 - y0) * (y2 - y1));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Relax the non-measured points.
|
// Relax the non-measured points.
|
||||||
const float weight = 0.2f;
|
const float weight = 0.2f;
|
||||||
for (uint8_t iter = 0; iter < 20; ++ iter) {
|
for (uint8_t iter = 0; iter < 20; ++ iter) {
|
||||||
|
|
@ -174,7 +172,7 @@ void mesh_bed_leveling::upsample_3x3()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,21 +21,15 @@ public:
|
||||||
void upsample_3x3();
|
void upsample_3x3();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static float get_x(int i) {
|
static float get_x(int i) { return float(MESH_MIN_X) + float(MESH_X_DIST) * float(i); }
|
||||||
return float(MESH_MIN_X) + float(MESH_X_DIST) * float(i);
|
static float get_y(int i) { return float(MESH_MIN_Y) + float(MESH_Y_DIST) * float(i); }
|
||||||
}
|
|
||||||
static float get_y(int i) {
|
|
||||||
return float(MESH_MIN_Y) + float(MESH_Y_DIST) * float(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Measurement point for the Z probe.
|
// Measurement point for the Z probe.
|
||||||
// If use_default=true, then the default positions for a correctly built printer are used.
|
// If use_default=true, then the default positions for a correctly built printer are used.
|
||||||
// Otherwise a correction matrix is pulled from the EEPROM if available.
|
// Otherwise a correction matrix is pulled from the EEPROM if available.
|
||||||
static void get_meas_xy(int ix, int iy, float &x, float &y, bool use_default);
|
static void get_meas_xy(int ix, int iy, float &x, float &y, bool use_default);
|
||||||
|
|
||||||
void set_z(int ix, int iy, float z) {
|
void set_z(int ix, int iy, float z) { z_values[iy][ix] = z; }
|
||||||
z_values[iy][ix] = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
int select_x_index(float x) {
|
int select_x_index(float x) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
|
||||||
|
|
@ -440,7 +440,7 @@ void mmu_loop(void)
|
||||||
if (!mmu_finda && CHECK_FINDA && fsensor_enabled) {
|
if (!mmu_finda && CHECK_FINDA && fsensor_enabled) {
|
||||||
fsensor_stop_and_save_print();
|
fsensor_stop_and_save_print();
|
||||||
enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover
|
enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover
|
||||||
if (lcd_autoDeplete) enquecommand_front_P(PSTR("M600 AUTO")); //save print and run M600 command
|
if (lcd_autoDepleteEnabled()) enquecommand_front_P(PSTR("M600 AUTO")); //save print and run M600 command
|
||||||
else enquecommand_front_P(PSTR("M600")); //save print and run M600 command
|
else enquecommand_front_P(PSTR("M600")); //save print and run M600 command
|
||||||
}
|
}
|
||||||
mmu_state = 1;
|
mmu_state = 1;
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,8 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
|
||||||
|
|
||||||
// CCW angle between position and target from circle center. Only one atan2() trig computation required.
|
// CCW angle between position and target from circle center. Only one atan2() trig computation required.
|
||||||
float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1);
|
float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1);
|
||||||
if (angular_travel < 0) {
|
if (angular_travel < 0) { angular_travel += 2*M_PI; }
|
||||||
angular_travel += 2*M_PI;
|
if (isclockwise) { angular_travel -= 2*M_PI; }
|
||||||
}
|
|
||||||
if (isclockwise) {
|
|
||||||
angular_travel -= 2*M_PI;
|
|
||||||
}
|
|
||||||
|
|
||||||
//20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving
|
//20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving
|
||||||
//to compensate when start pos = target pos && angle is zero -> angle = 2Pi
|
//to compensate when start pos = target pos && angle is zero -> angle = 2Pi
|
||||||
|
|
@ -57,9 +53,7 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
|
||||||
//end fix G03
|
//end fix G03
|
||||||
|
|
||||||
float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel));
|
float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel));
|
||||||
if (millimeters_of_travel < 0.001) {
|
if (millimeters_of_travel < 0.001) { return; }
|
||||||
return;
|
|
||||||
}
|
|
||||||
uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT);
|
uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT);
|
||||||
if(segments == 0) segments = 1;
|
if(segments == 0) segments = 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#define OPTIBOOT_CUSTOMVER 0
|
#define OPTIBOOT_CUSTOMVER 0
|
||||||
#define OPTIBOOT_MINVER 2
|
#define OPTIBOOT_MINVER 2
|
||||||
static unsigned const int __attribute__((section(".version")))
|
static unsigned const int __attribute__((section(".version")))
|
||||||
optiboot_version = 256*(OPTIBOOT_MAJVER + OPTIBOOT_CUSTOMVER) + OPTIBOOT_MINVER;
|
optiboot_version = 256*(OPTIBOOT_MAJVER + OPTIBOOT_CUSTOMVER) + OPTIBOOT_MINVER;
|
||||||
|
|
||||||
/* Watchdog settings */
|
/* Watchdog settings */
|
||||||
#define WATCHDOG_OFF (0)
|
#define WATCHDOG_OFF (0)
|
||||||
|
|
@ -84,8 +84,7 @@ static void verifySpace() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getNch(uint8_t count) {
|
static void getNch(uint8_t count) {
|
||||||
do getch();
|
do getch(); while (--count);
|
||||||
while (--count);
|
|
||||||
verifySpace();
|
verifySpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,6 @@
|
||||||
#define PAT9125_BANK_SELECTION 0x7f
|
#define PAT9125_BANK_SELECTION 0x7f
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define PAT9125_NEW_INIT
|
|
||||||
#ifdef PAT9125_SWSPI
|
#ifdef PAT9125_SWSPI
|
||||||
#include "swspi.h"
|
#include "swspi.h"
|
||||||
#endif //PAT9125_SWSPI
|
#endif //PAT9125_SWSPI
|
||||||
|
|
|
||||||
|
|
@ -42,44 +42,44 @@
|
||||||
//List of pins which to ignore when asked to change by gcode, 0 and 1 are RX and TX, do not mess with those!
|
//List of pins which to ignore when asked to change by gcode, 0 and 1 are RX and TX, do not mess with those!
|
||||||
#define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN, HEATER_0_PIN,
|
#define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN, HEATER_0_PIN,
|
||||||
#if EXTRUDERS > 1
|
#if EXTRUDERS > 1
|
||||||
#define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, HEATER_1_PIN,
|
#define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, HEATER_1_PIN,
|
||||||
#else
|
#else
|
||||||
#define _E1_PINS
|
#define _E1_PINS
|
||||||
#endif
|
#endif
|
||||||
#if EXTRUDERS > 2
|
#if EXTRUDERS > 2
|
||||||
#define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN, HEATER_2_PIN,
|
#define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN, HEATER_2_PIN,
|
||||||
#else
|
#else
|
||||||
#define _E2_PINS
|
#define _E2_PINS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef X_STOP_PIN
|
#ifdef X_STOP_PIN
|
||||||
#if X_HOME_DIR < 0
|
#if X_HOME_DIR < 0
|
||||||
#define X_MIN_PIN X_STOP_PIN
|
#define X_MIN_PIN X_STOP_PIN
|
||||||
#define X_MAX_PIN -1
|
#define X_MAX_PIN -1
|
||||||
#else
|
#else
|
||||||
#define X_MIN_PIN -1
|
#define X_MIN_PIN -1
|
||||||
#define X_MAX_PIN X_STOP_PIN
|
#define X_MAX_PIN X_STOP_PIN
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Y_STOP_PIN
|
#ifdef Y_STOP_PIN
|
||||||
#if Y_HOME_DIR < 0
|
#if Y_HOME_DIR < 0
|
||||||
#define Y_MIN_PIN Y_STOP_PIN
|
#define Y_MIN_PIN Y_STOP_PIN
|
||||||
#define Y_MAX_PIN -1
|
#define Y_MAX_PIN -1
|
||||||
#else
|
#else
|
||||||
#define Y_MIN_PIN -1
|
#define Y_MIN_PIN -1
|
||||||
#define Y_MAX_PIN Y_STOP_PIN
|
#define Y_MAX_PIN Y_STOP_PIN
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Z_STOP_PIN
|
#ifdef Z_STOP_PIN
|
||||||
#if Z_HOME_DIR < 0
|
#if Z_HOME_DIR < 0
|
||||||
#define Z_MIN_PIN Z_STOP_PIN
|
#define Z_MIN_PIN Z_STOP_PIN
|
||||||
#define Z_MAX_PIN -1
|
#define Z_MAX_PIN -1
|
||||||
#else
|
#else
|
||||||
#define Z_MIN_PIN -1
|
#define Z_MIN_PIN -1
|
||||||
#define Z_MAX_PIN Z_STOP_PIN
|
#define Z_MAX_PIN Z_STOP_PIN
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DISABLE_MAX_ENDSTOPS
|
#ifdef DISABLE_MAX_ENDSTOPS
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#define KNOWN_BOARD
|
#define KNOWN_BOARD
|
||||||
#ifndef __AVR_ATmega2560__
|
#ifndef __AVR_ATmega2560__
|
||||||
#error Oops! Make sure you have 'Arduino Mega 2560 or Rambo' selected from the 'Tools -> Boards' menu.
|
#error Oops! Make sure you have 'Arduino Mega 2560 or Rambo' selected from the 'Tools -> Boards' menu.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TMC2130
|
#define TMC2130
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#define KNOWN_BOARD
|
#define KNOWN_BOARD
|
||||||
#ifndef __AVR_ATmega2560__
|
#ifndef __AVR_ATmega2560__
|
||||||
#error Oops! Make sure you have 'Arduino Mega 2560 or Rambo' selected from the 'Tools -> Boards' menu.
|
#error Oops! Make sure you have 'Arduino Mega 2560 or Rambo' selected from the 'Tools -> Boards' menu.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PINDA_THERMISTOR
|
#define PINDA_THERMISTOR
|
||||||
|
|
@ -65,8 +65,8 @@
|
||||||
#define E0_MS2_PIN 66
|
#define E0_MS2_PIN 66
|
||||||
|
|
||||||
#ifdef SNMM
|
#ifdef SNMM
|
||||||
#define E_MUX0_PIN 17
|
#define E_MUX0_PIN 17
|
||||||
#define E_MUX1_PIN 16
|
#define E_MUX1_PIN 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#define KNOWN_BOARD
|
#define KNOWN_BOARD
|
||||||
#ifndef __AVR_ATmega2560__
|
#ifndef __AVR_ATmega2560__
|
||||||
#error Oops! Make sure you have 'Arduino Mega 2560 or Rambo' selected from the 'Tools -> Boards' menu.
|
#error Oops! Make sure you have 'Arduino Mega 2560 or Rambo' selected from the 'Tools -> Boards' menu.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PINDA_THERMISTOR
|
#define PINDA_THERMISTOR
|
||||||
|
|
@ -65,8 +65,8 @@
|
||||||
#define E0_MS2_PIN 66
|
#define E0_MS2_PIN 66
|
||||||
|
|
||||||
#ifdef SNMM
|
#ifdef SNMM
|
||||||
#define E_MUX0_PIN 17
|
#define E_MUX0_PIN 17
|
||||||
#define E_MUX1_PIN 16
|
#define E_MUX1_PIN 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ float extrude_min_temp=EXTRUDE_MINTEMP;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
float extruder_advance_k = LIN_ADVANCE_K,
|
float extruder_advance_k = LIN_ADVANCE_K,
|
||||||
advance_ed_ratio = LIN_ADVANCE_E_D_RATIO,
|
advance_ed_ratio = LIN_ADVANCE_E_D_RATIO,
|
||||||
position_float[NUM_AXIS] = { 0 };
|
position_float[NUM_AXIS] = { 0 };
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -441,7 +441,7 @@ void plan_init() {
|
||||||
void getHighESpeed()
|
void getHighESpeed()
|
||||||
{
|
{
|
||||||
static float oldt=0;
|
static float oldt=0;
|
||||||
if(!autotemp_enabled) {
|
if(!autotemp_enabled){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(degTargetHotend0()+2<autotemp_min) { //probably temperature set to zero.
|
if(degTargetHotend0()+2<autotemp_min) { //probably temperature set to zero.
|
||||||
|
|
@ -530,7 +530,7 @@ void check_axes_activity()
|
||||||
disable_e2();
|
disable_e2();
|
||||||
}
|
}
|
||||||
#if defined(FAN_PIN) && FAN_PIN > -1
|
#if defined(FAN_PIN) && FAN_PIN > -1
|
||||||
#ifdef FAN_KICKSTART_TIME
|
#ifdef FAN_KICKSTART_TIME
|
||||||
static unsigned long fan_kick_end;
|
static unsigned long fan_kick_end;
|
||||||
if (tail_fan_speed) {
|
if (tail_fan_speed) {
|
||||||
if (fan_kick_end == 0) {
|
if (fan_kick_end == 0) {
|
||||||
|
|
@ -543,12 +543,12 @@ void check_axes_activity()
|
||||||
} else {
|
} else {
|
||||||
fan_kick_end = 0;
|
fan_kick_end = 0;
|
||||||
}
|
}
|
||||||
#endif//FAN_KICKSTART_TIME
|
#endif//FAN_KICKSTART_TIME
|
||||||
#ifdef FAN_SOFT_PWM
|
#ifdef FAN_SOFT_PWM
|
||||||
fanSpeedSoftPwm = tail_fan_speed;
|
fanSpeedSoftPwm = tail_fan_speed;
|
||||||
#else
|
#else
|
||||||
analogWrite(FAN_PIN,tail_fan_speed);
|
analogWrite(FAN_PIN,tail_fan_speed);
|
||||||
#endif//!FAN_SOFT_PWM
|
#endif//!FAN_SOFT_PWM
|
||||||
#endif//FAN_PIN > -1
|
#endif//FAN_PIN > -1
|
||||||
#ifdef AUTOTEMP
|
#ifdef AUTOTEMP
|
||||||
getHighESpeed();
|
getHighESpeed();
|
||||||
|
|
@ -683,7 +683,7 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
|
|
||||||
// Apply the machine correction matrix.
|
// Apply the machine correction matrix.
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
SERIAL_ECHOPGM("Planner, current position - servos: ");
|
SERIAL_ECHOPGM("Planner, current position - servos: ");
|
||||||
MYSERIAL.print(st_get_position_mm(X_AXIS), 5);
|
MYSERIAL.print(st_get_position_mm(X_AXIS), 5);
|
||||||
SERIAL_ECHOPGM(", ");
|
SERIAL_ECHOPGM(", ");
|
||||||
|
|
@ -712,17 +712,17 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
SERIAL_ECHOPGM(", ");
|
SERIAL_ECHOPGM(", ");
|
||||||
MYSERIAL.print(world2machine_shift[1], 5);
|
MYSERIAL.print(world2machine_shift[1], 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
world2machine(x, y);
|
world2machine(x, y);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
SERIAL_ECHOPGM("Planner, target position, corrected: ");
|
SERIAL_ECHOPGM("Planner, target position, corrected: ");
|
||||||
MYSERIAL.print(x, 5);
|
MYSERIAL.print(x, 5);
|
||||||
SERIAL_ECHOPGM(", ");
|
SERIAL_ECHOPGM(", ");
|
||||||
MYSERIAL.print(y, 5);
|
MYSERIAL.print(y, 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// The target position of the tool in absolute steps
|
// The target position of the tool in absolute steps
|
||||||
|
|
@ -732,9 +732,9 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
target[X_AXIS] = lround(x*cs.axis_steps_per_unit[X_AXIS]);
|
target[X_AXIS] = lround(x*cs.axis_steps_per_unit[X_AXIS]);
|
||||||
target[Y_AXIS] = lround(y*cs.axis_steps_per_unit[Y_AXIS]);
|
target[Y_AXIS] = lround(y*cs.axis_steps_per_unit[Y_AXIS]);
|
||||||
#ifdef MESH_BED_LEVELING
|
#ifdef MESH_BED_LEVELING
|
||||||
if (mbl.active) {
|
if (mbl.active){
|
||||||
target[Z_AXIS] = lround((z+mbl.get_z(x, y))*cs.axis_steps_per_unit[Z_AXIS]);
|
target[Z_AXIS] = lround((z+mbl.get_z(x, y))*cs.axis_steps_per_unit[Z_AXIS]);
|
||||||
} else {
|
}else{
|
||||||
target[Z_AXIS] = lround(z*cs.axis_steps_per_unit[Z_AXIS]);
|
target[Z_AXIS] = lround(z*cs.axis_steps_per_unit[Z_AXIS]);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
@ -747,7 +747,7 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
float de_float = e - position_float[E_AXIS];
|
float de_float = e - position_float[E_AXIS];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||||
if(target[E_AXIS]!=position[E_AXIS])
|
if(target[E_AXIS]!=position[E_AXIS])
|
||||||
{
|
{
|
||||||
if(degHotend(active_extruder)<extrude_min_temp)
|
if(degHotend(active_extruder)<extrude_min_temp)
|
||||||
|
|
@ -761,7 +761,7 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
SERIAL_ECHOLNRPGM(_i(" cold extrusion prevented"));////MSG_ERR_COLD_EXTRUDE_STOP c=0 r=0
|
SERIAL_ECHOLNRPGM(_i(" cold extrusion prevented"));////MSG_ERR_COLD_EXTRUDE_STOP c=0 r=0
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PREVENT_LENGTHY_EXTRUDE
|
#ifdef PREVENT_LENGTHY_EXTRUDE
|
||||||
if(labs(target[E_AXIS]-position[E_AXIS])>cs.axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH)
|
if(labs(target[E_AXIS]-position[E_AXIS])>cs.axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH)
|
||||||
{
|
{
|
||||||
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
|
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
|
||||||
|
|
@ -772,9 +772,9 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
SERIAL_ECHOLNRPGM(_n(" too long extrusion prevented"));////MSG_ERR_LONG_EXTRUDE_STOP c=0 r=0
|
SERIAL_ECHOLNRPGM(_n(" too long extrusion prevented"));////MSG_ERR_LONG_EXTRUDE_STOP c=0 r=0
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Prepare to set up new block
|
// Prepare to set up new block
|
||||||
block_t *block = &block_buffer[block_buffer_head];
|
block_t *block = &block_buffer[block_buffer_head];
|
||||||
|
|
@ -788,13 +788,13 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
// Number of steps for each axis
|
// Number of steps for each axis
|
||||||
#ifndef COREXY
|
#ifndef COREXY
|
||||||
// default non-h-bot planning
|
// default non-h-bot planning
|
||||||
block->steps_x.wide = labs(target[X_AXIS]-position[X_AXIS]);
|
block->steps_x.wide = labs(target[X_AXIS]-position[X_AXIS]);
|
||||||
block->steps_y.wide = labs(target[Y_AXIS]-position[Y_AXIS]);
|
block->steps_y.wide = labs(target[Y_AXIS]-position[Y_AXIS]);
|
||||||
#else
|
#else
|
||||||
// corexy planning
|
// corexy planning
|
||||||
// these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
|
// these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
|
||||||
block->steps_x.wide = labs((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS]));
|
block->steps_x.wide = labs((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS]));
|
||||||
block->steps_y.wide = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]));
|
block->steps_y.wide = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]));
|
||||||
#endif
|
#endif
|
||||||
block->steps_z.wide = labs(target[Z_AXIS]-position[Z_AXIS]);
|
block->steps_z.wide = labs(target[Z_AXIS]-position[Z_AXIS]);
|
||||||
block->steps_e.wide = labs(target[E_AXIS]-position[E_AXIS]);
|
block->steps_e.wide = labs(target[E_AXIS]-position[E_AXIS]);
|
||||||
|
|
@ -844,16 +844,16 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
block->active_extruder = extruder;
|
block->active_extruder = extruder;
|
||||||
|
|
||||||
//enable active axes
|
//enable active axes
|
||||||
#ifdef COREXY
|
#ifdef COREXY
|
||||||
if((block->steps_x.wide != 0) || (block->steps_y.wide != 0))
|
if((block->steps_x.wide != 0) || (block->steps_y.wide != 0))
|
||||||
{
|
{
|
||||||
enable_x();
|
enable_x();
|
||||||
enable_y();
|
enable_y();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(block->steps_x.wide != 0) enable_x();
|
if(block->steps_x.wide != 0) enable_x();
|
||||||
if(block->steps_y.wide != 0) enable_y();
|
if(block->steps_y.wide != 0) enable_y();
|
||||||
#endif
|
#endif
|
||||||
if(block->steps_z.wide != 0) enable_z();
|
if(block->steps_z.wide != 0) enable_z();
|
||||||
|
|
||||||
// Enable extruder(s)
|
// Enable extruder(s)
|
||||||
|
|
@ -872,34 +872,22 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
enable_e0();
|
enable_e0();
|
||||||
g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2;
|
g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2;
|
||||||
|
|
||||||
if(g_uc_extruder_last_move[1] == 0) {
|
if(g_uc_extruder_last_move[1] == 0) {disable_e1();}
|
||||||
disable_e1();
|
if(g_uc_extruder_last_move[2] == 0) {disable_e2();}
|
||||||
}
|
|
||||||
if(g_uc_extruder_last_move[2] == 0) {
|
|
||||||
disable_e2();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
enable_e1();
|
enable_e1();
|
||||||
g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2;
|
g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2;
|
||||||
|
|
||||||
if(g_uc_extruder_last_move[0] == 0) {
|
if(g_uc_extruder_last_move[0] == 0) {disable_e0();}
|
||||||
disable_e0();
|
if(g_uc_extruder_last_move[2] == 0) {disable_e2();}
|
||||||
}
|
|
||||||
if(g_uc_extruder_last_move[2] == 0) {
|
|
||||||
disable_e2();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
enable_e2();
|
enable_e2();
|
||||||
g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2;
|
g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2;
|
||||||
|
|
||||||
if(g_uc_extruder_last_move[0] == 0) {
|
if(g_uc_extruder_last_move[0] == 0) {disable_e0();}
|
||||||
disable_e0();
|
if(g_uc_extruder_last_move[1] == 0) {disable_e1();}
|
||||||
}
|
|
||||||
if(g_uc_extruder_last_move[1] == 0) {
|
|
||||||
disable_e1();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -920,24 +908,24 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
if(feed_rate<cs.minimumfeedrate) feed_rate=cs.minimumfeedrate;
|
if(feed_rate<cs.minimumfeedrate) feed_rate=cs.minimumfeedrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This part of the code calculates the total length of the movement.
|
/* This part of the code calculates the total length of the movement.
|
||||||
For cartesian bots, the X_AXIS is the real X movement and same for Y_AXIS.
|
For cartesian bots, the X_AXIS is the real X movement and same for Y_AXIS.
|
||||||
But for corexy bots, that is not true. The "X_AXIS" and "Y_AXIS" motors (that should be named to A_AXIS
|
But for corexy bots, that is not true. The "X_AXIS" and "Y_AXIS" motors (that should be named to A_AXIS
|
||||||
and B_AXIS) cannot be used for X and Y length, because A=X+Y and B=X-Y.
|
and B_AXIS) cannot be used for X and Y length, because A=X+Y and B=X-Y.
|
||||||
So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head.
|
So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head.
|
||||||
Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
|
Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
|
||||||
*/
|
*/
|
||||||
#ifndef COREXY
|
#ifndef COREXY
|
||||||
float delta_mm[4];
|
float delta_mm[4];
|
||||||
delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/cs.axis_steps_per_unit[X_AXIS];
|
delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/cs.axis_steps_per_unit[X_AXIS];
|
||||||
delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/cs.axis_steps_per_unit[Y_AXIS];
|
delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/cs.axis_steps_per_unit[Y_AXIS];
|
||||||
#else
|
#else
|
||||||
float delta_mm[6];
|
float delta_mm[6];
|
||||||
delta_mm[X_HEAD] = (target[X_AXIS]-position[X_AXIS])/cs.axis_steps_per_unit[X_AXIS];
|
delta_mm[X_HEAD] = (target[X_AXIS]-position[X_AXIS])/cs.axis_steps_per_unit[X_AXIS];
|
||||||
delta_mm[Y_HEAD] = (target[Y_AXIS]-position[Y_AXIS])/cs.axis_steps_per_unit[Y_AXIS];
|
delta_mm[Y_HEAD] = (target[Y_AXIS]-position[Y_AXIS])/cs.axis_steps_per_unit[Y_AXIS];
|
||||||
delta_mm[X_AXIS] = ((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS]))/cs.axis_steps_per_unit[X_AXIS];
|
delta_mm[X_AXIS] = ((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS]))/cs.axis_steps_per_unit[X_AXIS];
|
||||||
delta_mm[Y_AXIS] = ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]))/cs.axis_steps_per_unit[Y_AXIS];
|
delta_mm[Y_AXIS] = ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]))/cs.axis_steps_per_unit[Y_AXIS];
|
||||||
#endif
|
#endif
|
||||||
delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/cs.axis_steps_per_unit[Z_AXIS];
|
delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/cs.axis_steps_per_unit[Z_AXIS];
|
||||||
delta_mm[E_AXIS] = (target[E_AXIS]-position[E_AXIS])/cs.axis_steps_per_unit[E_AXIS];
|
delta_mm[E_AXIS] = (target[E_AXIS]-position[E_AXIS])/cs.axis_steps_per_unit[E_AXIS];
|
||||||
if ( block->steps_x.wide <=dropsegments && block->steps_y.wide <=dropsegments && block->steps_z.wide <=dropsegments )
|
if ( block->steps_x.wide <=dropsegments && block->steps_y.wide <=dropsegments && block->steps_z.wide <=dropsegments )
|
||||||
|
|
@ -946,11 +934,11 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifndef COREXY
|
#ifndef COREXY
|
||||||
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
|
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
|
||||||
#else
|
#else
|
||||||
block->millimeters = sqrt(square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS]));
|
block->millimeters = sqrt(square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS]));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides
|
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides
|
||||||
|
|
||||||
|
|
@ -1014,25 +1002,13 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
// Limit acceleration per axis
|
// Limit acceleration per axis
|
||||||
//FIXME Vojtech: One shall rather limit a projection of the acceleration vector instead of using the limit.
|
//FIXME Vojtech: One shall rather limit a projection of the acceleration vector instead of using the limit.
|
||||||
if(((float)block->acceleration_st * (float)block->steps_x.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[X_AXIS])
|
if(((float)block->acceleration_st * (float)block->steps_x.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[X_AXIS])
|
||||||
{
|
{ block->acceleration_st = axis_steps_per_sqr_second[X_AXIS]; maxlimit_status |= (X_AXIS_MASK << 4); }
|
||||||
block->acceleration_st = axis_steps_per_sqr_second[X_AXIS];
|
|
||||||
maxlimit_status |= (X_AXIS_MASK << 4);
|
|
||||||
}
|
|
||||||
if(((float)block->acceleration_st * (float)block->steps_y.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[Y_AXIS])
|
if(((float)block->acceleration_st * (float)block->steps_y.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[Y_AXIS])
|
||||||
{
|
{ block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS]; maxlimit_status |= (Y_AXIS_MASK << 4); }
|
||||||
block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS];
|
|
||||||
maxlimit_status |= (Y_AXIS_MASK << 4);
|
|
||||||
}
|
|
||||||
if(((float)block->acceleration_st * (float)block->steps_e.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[E_AXIS])
|
if(((float)block->acceleration_st * (float)block->steps_e.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[E_AXIS])
|
||||||
{
|
{ block->acceleration_st = axis_steps_per_sqr_second[E_AXIS]; maxlimit_status |= (Z_AXIS_MASK << 4); }
|
||||||
block->acceleration_st = axis_steps_per_sqr_second[E_AXIS];
|
|
||||||
maxlimit_status |= (Z_AXIS_MASK << 4);
|
|
||||||
}
|
|
||||||
if(((float)block->acceleration_st * (float)block->steps_z.wide / (float)block->step_event_count.wide ) > axis_steps_per_sqr_second[Z_AXIS])
|
if(((float)block->acceleration_st * (float)block->steps_z.wide / (float)block->step_event_count.wide ) > axis_steps_per_sqr_second[Z_AXIS])
|
||||||
{
|
{ block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS]; maxlimit_status |= (E_AXIS_MASK << 4); }
|
||||||
block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
|
|
||||||
maxlimit_status |= (E_AXIS_MASK << 4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Acceleration of the segment, in mm/sec^2
|
// Acceleration of the segment, in mm/sec^2
|
||||||
block->acceleration = block->acceleration_st / steps_per_mm;
|
block->acceleration = block->acceleration_st / steps_per_mm;
|
||||||
|
|
@ -1300,18 +1276,18 @@ void plan_set_position(float x, float y, float z, const float &e)
|
||||||
// Only useful in the bed leveling routine, when the mesh bed leveling is off.
|
// Only useful in the bed leveling routine, when the mesh bed leveling is off.
|
||||||
void plan_set_z_position(const float &z)
|
void plan_set_z_position(const float &z)
|
||||||
{
|
{
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
position_float[Z_AXIS] = z;
|
position_float[Z_AXIS] = z;
|
||||||
#endif
|
#endif
|
||||||
position[Z_AXIS] = lround(z*cs.axis_steps_per_unit[Z_AXIS]);
|
position[Z_AXIS] = lround(z*cs.axis_steps_per_unit[Z_AXIS]);
|
||||||
st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]);
|
st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void plan_set_e_position(const float &e)
|
void plan_set_e_position(const float &e)
|
||||||
{
|
{
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
position_float[E_AXIS] = e;
|
position_float[E_AXIS] = e;
|
||||||
#endif
|
#endif
|
||||||
position[E_AXIS] = lround(e*cs.axis_steps_per_unit[E_AXIS]);
|
position[E_AXIS] = lround(e*cs.axis_steps_per_unit[E_AXIS]);
|
||||||
st_set_e_position(position[E_AXIS]);
|
st_set_e_position(position[E_AXIS]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ typedef struct {
|
||||||
} block_t;
|
} block_t;
|
||||||
|
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
extern float extruder_advance_k, advance_ed_ratio;
|
extern float extruder_advance_k, advance_ed_ratio;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_AUTO_BED_LEVELING
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
||||||
|
|
@ -171,10 +171,10 @@ extern uint8_t maxlimit_status;
|
||||||
|
|
||||||
|
|
||||||
#ifdef AUTOTEMP
|
#ifdef AUTOTEMP
|
||||||
extern bool autotemp_enabled;
|
extern bool autotemp_enabled;
|
||||||
extern float autotemp_max;
|
extern float autotemp_max;
|
||||||
extern float autotemp_min;
|
extern float autotemp_min;
|
||||||
extern float autotemp_factor;
|
extern float autotemp_factor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -379,10 +379,10 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Code for unequal increments or equal increments
|
Code for unequal increments or equal increments
|
||||||
not equal to 1.
|
not equal to 1.
|
||||||
*/
|
*/
|
||||||
if ( incx != 1 || incy != 1 )
|
if ( incx != 1 || incy != 1 )
|
||||||
{
|
{
|
||||||
if ( 0 <= incx )
|
if ( 0 <= incx )
|
||||||
|
|
@ -410,9 +410,9 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy )
|
||||||
iy = iy + incy;
|
iy = iy + incy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Code for both increments equal to 1.
|
Code for both increments equal to 1.
|
||||||
*/
|
*/
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m = n % 4;
|
m = n % 4;
|
||||||
|
|
@ -498,10 +498,10 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy )
|
||||||
{
|
{
|
||||||
return dtemp;
|
return dtemp;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Code for unequal increments or equal increments
|
Code for unequal increments or equal increments
|
||||||
not equal to 1.
|
not equal to 1.
|
||||||
*/
|
*/
|
||||||
if ( incx != 1 || incy != 1 )
|
if ( incx != 1 || incy != 1 )
|
||||||
{
|
{
|
||||||
if ( 0 <= incx )
|
if ( 0 <= incx )
|
||||||
|
|
@ -529,9 +529,9 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy )
|
||||||
iy = iy + incy;
|
iy = iy + incy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Code for both increments equal to 1.
|
Code for both increments equal to 1.
|
||||||
*/
|
*/
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m = n % 5;
|
m = n % 5;
|
||||||
|
|
@ -853,9 +853,9 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[],
|
||||||
|
|
||||||
pl = 1;
|
pl = 1;
|
||||||
pu = 0;
|
pu = 0;
|
||||||
/*
|
/*
|
||||||
If pivoting is requested, rearrange the columns.
|
If pivoting is requested, rearrange the columns.
|
||||||
*/
|
*/
|
||||||
if ( job != 0 )
|
if ( job != 0 )
|
||||||
{
|
{
|
||||||
for ( j = 1; j <= p; j++ )
|
for ( j = 1; j <= p; j++ )
|
||||||
|
|
@ -901,9 +901,9 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Compute the norms of the free columns.
|
Compute the norms of the free columns.
|
||||||
*/
|
*/
|
||||||
for ( j = pl; j <= pu; j++ )
|
for ( j = pl; j <= pu; j++ )
|
||||||
{
|
{
|
||||||
qraux[j-1] = dnrm2 ( n, a+0+(j-1)*lda, 1 );
|
qraux[j-1] = dnrm2 ( n, a+0+(j-1)*lda, 1 );
|
||||||
|
|
@ -913,16 +913,16 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[],
|
||||||
{
|
{
|
||||||
work[j-1] = qraux[j-1];
|
work[j-1] = qraux[j-1];
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Perform the Householder reduction of A.
|
Perform the Householder reduction of A.
|
||||||
*/
|
*/
|
||||||
lup = i4_min ( n, p );
|
lup = i4_min ( n, p );
|
||||||
|
|
||||||
for ( l = 1; l <= lup; l++ )
|
for ( l = 1; l <= lup; l++ )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Bring the column of largest norm into the pivot position.
|
Bring the column of largest norm into the pivot position.
|
||||||
*/
|
*/
|
||||||
if ( pl <= l && l < pu )
|
if ( pl <= l && l < pu )
|
||||||
{
|
{
|
||||||
maxnrm = 0.0;
|
maxnrm = 0.0;
|
||||||
|
|
@ -946,9 +946,9 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[],
|
||||||
jpvt[l-1] = jp;
|
jpvt[l-1] = jp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Compute the Householder transformation for column L.
|
Compute the Householder transformation for column L.
|
||||||
*/
|
*/
|
||||||
qraux[l-1] = 0.0;
|
qraux[l-1] = 0.0;
|
||||||
|
|
||||||
if ( l != n )
|
if ( l != n )
|
||||||
|
|
@ -964,9 +964,9 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[],
|
||||||
|
|
||||||
dscal ( n-l+1, 1.0 / nrmxl, a+l-1+(l-1)*lda, 1 );
|
dscal ( n-l+1, 1.0 / nrmxl, a+l-1+(l-1)*lda, 1 );
|
||||||
a[l-1+(l-1)*lda] = 1.0 + a[l-1+(l-1)*lda];
|
a[l-1+(l-1)*lda] = 1.0 + a[l-1+(l-1)*lda];
|
||||||
/*
|
/*
|
||||||
Apply the transformation to the remaining columns, updating the norms.
|
Apply the transformation to the remaining columns, updating the norms.
|
||||||
*/
|
*/
|
||||||
for ( j = l + 1; j <= p; j++ )
|
for ( j = l + 1; j <= p; j++ )
|
||||||
{
|
{
|
||||||
t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 )
|
t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 )
|
||||||
|
|
@ -994,9 +994,9 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Save the transformation.
|
Save the transformation.
|
||||||
*/
|
*/
|
||||||
qraux[l-1] = a[l-1+(l-1)*lda];
|
qraux[l-1] = a[l-1+(l-1)*lda];
|
||||||
a[l-1+(l-1)*lda] = -nrmxl;
|
a[l-1+(l-1)*lda] = -nrmxl;
|
||||||
}
|
}
|
||||||
|
|
@ -1144,16 +1144,16 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[],
|
||||||
}
|
}
|
||||||
|
|
||||||
ind = 0;
|
ind = 0;
|
||||||
/*
|
/*
|
||||||
Factor the matrix.
|
Factor the matrix.
|
||||||
*/
|
*/
|
||||||
if ( itask == 1 )
|
if ( itask == 1 )
|
||||||
{
|
{
|
||||||
dqrank ( a, lda, m, n, tol, kr, jpvt, qraux );
|
dqrank ( a, lda, m, n, tol, kr, jpvt, qraux );
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Solve the least-squares problem.
|
Solve the least-squares problem.
|
||||||
*/
|
*/
|
||||||
dqrlss ( a, lda, m, n, *kr, b, x, rsd, jpvt, qraux );
|
dqrlss ( a, lda, m, n, *kr, b, x, rsd, jpvt, qraux );
|
||||||
|
|
||||||
return ind;
|
return ind;
|
||||||
|
|
@ -1429,13 +1429,13 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
|
||||||
int ju;
|
int ju;
|
||||||
double t;
|
double t;
|
||||||
double temp;
|
double temp;
|
||||||
/*
|
/*
|
||||||
Set INFO flag.
|
Set INFO flag.
|
||||||
*/
|
*/
|
||||||
info = 0;
|
info = 0;
|
||||||
/*
|
/*
|
||||||
Determine what is to be computed.
|
Determine what is to be computed.
|
||||||
*/
|
*/
|
||||||
cqy = ( job / 10000 != 0 );
|
cqy = ( job / 10000 != 0 );
|
||||||
cqty = ( ( job % 10000 ) != 0 );
|
cqty = ( ( job % 10000 ) != 0 );
|
||||||
cb = ( ( job % 1000 ) / 100 != 0 );
|
cb = ( ( job % 1000 ) / 100 != 0 );
|
||||||
|
|
@ -1443,9 +1443,9 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
|
||||||
cab = ( ( job % 10 ) != 0 );
|
cab = ( ( job % 10 ) != 0 );
|
||||||
|
|
||||||
ju = i4_min ( k, n-1 );
|
ju = i4_min ( k, n-1 );
|
||||||
/*
|
/*
|
||||||
Special action when N = 1.
|
Special action when N = 1.
|
||||||
*/
|
*/
|
||||||
if ( ju == 0 )
|
if ( ju == 0 )
|
||||||
{
|
{
|
||||||
if ( cqy )
|
if ( cqy )
|
||||||
|
|
@ -1481,9 +1481,9 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Set up to compute QY or QTY.
|
Set up to compute QY or QTY.
|
||||||
*/
|
*/
|
||||||
if ( cqy )
|
if ( cqy )
|
||||||
{
|
{
|
||||||
for ( i = 1; i <= n; i++ )
|
for ( i = 1; i <= n; i++ )
|
||||||
|
|
@ -1499,9 +1499,9 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
|
||||||
qty[i-1] = y[i-1];
|
qty[i-1] = y[i-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Compute QY.
|
Compute QY.
|
||||||
*/
|
*/
|
||||||
if ( cqy )
|
if ( cqy )
|
||||||
{
|
{
|
||||||
for ( jj = 1; jj <= ju; jj++ )
|
for ( jj = 1; jj <= ju; jj++ )
|
||||||
|
|
@ -1518,9 +1518,9 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Compute Q'*Y.
|
Compute Q'*Y.
|
||||||
*/
|
*/
|
||||||
if ( cqty )
|
if ( cqty )
|
||||||
{
|
{
|
||||||
for ( j = 1; j <= ju; j++ )
|
for ( j = 1; j <= ju; j++ )
|
||||||
|
|
@ -1535,9 +1535,9 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Set up to compute B, RSD, or AB.
|
Set up to compute B, RSD, or AB.
|
||||||
*/
|
*/
|
||||||
if ( cb )
|
if ( cb )
|
||||||
{
|
{
|
||||||
for ( i = 1; i <= k; i++ )
|
for ( i = 1; i <= k; i++ )
|
||||||
|
|
@ -1577,9 +1577,9 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
|
||||||
rsd[i-1] = 0.0;
|
rsd[i-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Compute B.
|
Compute B.
|
||||||
*/
|
*/
|
||||||
if ( cb )
|
if ( cb )
|
||||||
{
|
{
|
||||||
for ( jj = 1; jj <= k; jj++ )
|
for ( jj = 1; jj <= k; jj++ )
|
||||||
|
|
@ -1601,9 +1601,9 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Compute RSD or AB as required.
|
Compute RSD or AB as required.
|
||||||
*/
|
*/
|
||||||
if ( cr || cab )
|
if ( cr || cab )
|
||||||
{
|
{
|
||||||
for ( jj = 1; jj <= ju; jj++ )
|
for ( jj = 1; jj <= ju; jj++ )
|
||||||
|
|
|
||||||
|
|
@ -50,23 +50,15 @@ uint8_t sm4_get_dir(uint8_t axis)
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
|
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
|
||||||
case 0:
|
case 0: return (PORTL & 2)?0:1;
|
||||||
return (PORTL & 2)?0:1;
|
case 1: return (PORTL & 1)?0:1;
|
||||||
case 1:
|
case 2: return (PORTL & 4)?0:1;
|
||||||
return (PORTL & 1)?0:1;
|
case 3: return (PORTL & 64)?1:0;
|
||||||
case 2:
|
|
||||||
return (PORTL & 4)?0:1;
|
|
||||||
case 3:
|
|
||||||
return (PORTL & 64)?1:0;
|
|
||||||
#elif ((MOTHERBOARD == BOARD_EINSY_1_0a))
|
#elif ((MOTHERBOARD == BOARD_EINSY_1_0a))
|
||||||
case 0:
|
case 0: return (PORTL & 1)?1:0;
|
||||||
return (PORTL & 1)?1:0;
|
case 1: return (PORTL & 2)?0:1;
|
||||||
case 1:
|
case 2: return (PORTL & 4)?1:0;
|
||||||
return (PORTL & 2)?0:1;
|
case 3: return (PORTL & 64)?0:1;
|
||||||
case 2:
|
|
||||||
return (PORTL & 4)?1:0;
|
|
||||||
case 3:
|
|
||||||
return (PORTL & 64)?0:1;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -77,39 +69,15 @@ void sm4_set_dir(uint8_t axis, uint8_t dir)
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
|
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
|
||||||
case 0:
|
case 0: if (!dir) PORTL |= 2; else PORTL &= ~2; break;
|
||||||
if (!dir) PORTL |= 2;
|
case 1: if (!dir) PORTL |= 1; else PORTL &= ~1; break;
|
||||||
else PORTL &= ~2;
|
case 2: if (!dir) PORTL |= 4; else PORTL &= ~4; break;
|
||||||
break;
|
case 3: if (dir) PORTL |= 64; else PORTL &= ~64; break;
|
||||||
case 1:
|
|
||||||
if (!dir) PORTL |= 1;
|
|
||||||
else PORTL &= ~1;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (!dir) PORTL |= 4;
|
|
||||||
else PORTL &= ~4;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (dir) PORTL |= 64;
|
|
||||||
else PORTL &= ~64;
|
|
||||||
break;
|
|
||||||
#elif ((MOTHERBOARD == BOARD_EINSY_1_0a))
|
#elif ((MOTHERBOARD == BOARD_EINSY_1_0a))
|
||||||
case 0:
|
case 0: if (dir) PORTL |= 1; else PORTL &= ~1; break;
|
||||||
if (dir) PORTL |= 1;
|
case 1: if (!dir) PORTL |= 2; else PORTL &= ~2; break;
|
||||||
else PORTL &= ~1;
|
case 2: if (dir) PORTL |= 4; else PORTL &= ~4; break;
|
||||||
break;
|
case 3: if (!dir) PORTL |= 64; else PORTL &= ~64; break;
|
||||||
case 1:
|
|
||||||
if (!dir) PORTL |= 2;
|
|
||||||
else PORTL &= ~2;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (dir) PORTL |= 4;
|
|
||||||
else PORTL &= ~4;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (!dir) PORTL |= 64;
|
|
||||||
else PORTL &= ~64;
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
asm("nop");
|
asm("nop");
|
||||||
|
|
|
||||||
|
|
@ -21,26 +21,26 @@ static void Sound_DoSound_Alert(bool bOnce);
|
||||||
|
|
||||||
void Sound_Init(void)
|
void Sound_Init(void)
|
||||||
{
|
{
|
||||||
SET_OUTPUT(BEEPER);
|
SET_OUTPUT(BEEPER);
|
||||||
eSoundMode=(eSOUND_MODE)eeprom_read_byte((uint8_t*)EEPROM_SOUND_MODE);
|
eSoundMode=(eSOUND_MODE)eeprom_read_byte((uint8_t*)EEPROM_SOUND_MODE);
|
||||||
if(eSoundMode==e_SOUND_MODE_NULL)
|
if(eSoundMode==e_SOUND_MODE_NULL)
|
||||||
Sound_Default(); // je potreba provest i ulozeni do EEPROM
|
Sound_Default(); // je potreba provest i ulozeni do EEPROM
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound_Default(void)
|
void Sound_Default(void)
|
||||||
{
|
{
|
||||||
eSoundMode=e_SOUND_MODE_DEFAULT;
|
eSoundMode=e_SOUND_MODE_DEFAULT;
|
||||||
Sound_SaveMode();
|
Sound_SaveMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound_SaveMode(void)
|
void Sound_SaveMode(void)
|
||||||
{
|
{
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_SOUND_MODE,(uint8_t)eSoundMode);
|
eeprom_update_byte((uint8_t*)EEPROM_SOUND_MODE,(uint8_t)eSoundMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound_CycleState(void)
|
void Sound_CycleState(void)
|
||||||
{
|
{
|
||||||
switch(eSoundMode)
|
switch(eSoundMode)
|
||||||
{
|
{
|
||||||
case e_SOUND_MODE_LOUD:
|
case e_SOUND_MODE_LOUD:
|
||||||
eSoundMode=e_SOUND_MODE_ONCE;
|
eSoundMode=e_SOUND_MODE_ONCE;
|
||||||
|
|
@ -57,7 +57,7 @@ void Sound_CycleState(void)
|
||||||
default:
|
default:
|
||||||
eSoundMode=e_SOUND_MODE_LOUD;
|
eSoundMode=e_SOUND_MODE_LOUD;
|
||||||
}
|
}
|
||||||
Sound_SaveMode();
|
Sound_SaveMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound_MakeSound(eSOUND_TYPE eSoundType)
|
void Sound_MakeSound(eSOUND_TYPE eSoundType)
|
||||||
|
|
@ -94,9 +94,9 @@ switch(eSoundMode)
|
||||||
|
|
||||||
static void Sound_DoSound_Echo(void)
|
static void Sound_DoSound_Echo(void)
|
||||||
{
|
{
|
||||||
uint8_t nI;
|
uint8_t nI;
|
||||||
|
|
||||||
for(nI=0; nI<10; nI++)
|
for(nI=0;nI<10;nI++)
|
||||||
{
|
{
|
||||||
WRITE(BEEPER,HIGH);
|
WRITE(BEEPER,HIGH);
|
||||||
delayMicroseconds(100);
|
delayMicroseconds(100);
|
||||||
|
|
@ -107,9 +107,9 @@ static void Sound_DoSound_Echo(void)
|
||||||
|
|
||||||
static void Sound_DoSound_Prompt(void)
|
static void Sound_DoSound_Prompt(void)
|
||||||
{
|
{
|
||||||
WRITE(BEEPER,HIGH);
|
WRITE(BEEPER,HIGH);
|
||||||
delay_keep_alive(500);
|
delay_keep_alive(500);
|
||||||
WRITE(BEEPER,LOW);
|
WRITE(BEEPER,LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Sound_DoSound_Alert(bool bOnce)
|
static void Sound_DoSound_Alert(bool bOnce)
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@
|
||||||
|
|
||||||
#define e_SOUND_MODE_NULL 0xFF
|
#define e_SOUND_MODE_NULL 0xFF
|
||||||
typedef enum
|
typedef enum
|
||||||
{e_SOUND_MODE_LOUD,e_SOUND_MODE_ONCE,e_SOUND_MODE_SILENT,e_SOUND_MODE_MUTE} eSOUND_MODE;
|
{e_SOUND_MODE_LOUD,e_SOUND_MODE_ONCE,e_SOUND_MODE_SILENT,e_SOUND_MODE_MUTE} eSOUND_MODE;
|
||||||
#define e_SOUND_MODE_DEFAULT e_SOUND_MODE_LOUD
|
#define e_SOUND_MODE_DEFAULT e_SOUND_MODE_LOUD
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{e_SOUND_TYPE_ButtonEcho,e_SOUND_TYPE_EncoderEcho,e_SOUND_TYPE_StandardPrompt,e_SOUND_TYPE_StandardConfirm,e_SOUND_TYPE_StandardWarning,e_SOUND_TYPE_StandardAlert} eSOUND_TYPE;
|
{e_SOUND_TYPE_ButtonEcho,e_SOUND_TYPE_EncoderEcho,e_SOUND_TYPE_StandardPrompt,e_SOUND_TYPE_StandardConfirm,e_SOUND_TYPE_StandardWarning,e_SOUND_TYPE_StandardAlert} eSOUND_TYPE;
|
||||||
typedef enum
|
typedef enum
|
||||||
{e_SOUND_CLASS_Echo,e_SOUND_CLASS_Prompt,e_SOUND_CLASS_Confirm,e_SOUND_CLASS_Warning,e_SOUND_CLASS_Alert} eSOUND_CLASS;
|
{e_SOUND_CLASS_Echo,e_SOUND_CLASS_Prompt,e_SOUND_CLASS_Confirm,e_SOUND_CLASS_Warning,e_SOUND_CLASS_Alert} eSOUND_CLASS;
|
||||||
|
|
||||||
|
|
||||||
extern eSOUND_MODE eSoundMode;
|
extern eSOUND_MODE eSoundMode;
|
||||||
|
|
|
||||||
|
|
@ -6,73 +6,73 @@
|
||||||
#if F_CPU == 16000000
|
#if F_CPU == 16000000
|
||||||
|
|
||||||
const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\
|
const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\
|
||||||
{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135},
|
{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135},
|
||||||
{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32},
|
{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32},
|
||||||
{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14},
|
{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14},
|
||||||
{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8},
|
{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8},
|
||||||
{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5},
|
{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5},
|
||||||
{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3},
|
{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3},
|
||||||
{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2},
|
{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2},
|
||||||
{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2},
|
{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2},
|
||||||
{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1},
|
{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1},
|
||||||
{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1},
|
{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1},
|
||||||
{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1},
|
{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1},
|
||||||
{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1},
|
{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1},
|
||||||
{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0},
|
{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0},
|
||||||
{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1},
|
{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1},
|
||||||
{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0},
|
{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0},
|
||||||
{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1},
|
{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1},
|
||||||
{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0},
|
{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0},
|
||||||
{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0},
|
{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0},
|
||||||
{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0},
|
{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0},
|
||||||
{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1},
|
{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1},
|
||||||
{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0},
|
{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0},
|
||||||
{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0},
|
{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0},
|
||||||
{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0},
|
{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0},
|
||||||
{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0},
|
{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0},
|
||||||
{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0},
|
{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0},
|
||||||
{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0},
|
{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0},
|
||||||
{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0},
|
{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0},
|
||||||
{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1},
|
{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1},
|
||||||
{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0},
|
{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0},
|
||||||
{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0},
|
{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0},
|
||||||
{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0},
|
{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0},
|
||||||
{ 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0}
|
{ 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\
|
const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\
|
||||||
{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894},
|
{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894},
|
||||||
{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657},
|
{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657},
|
||||||
{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331},
|
{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331},
|
||||||
{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198},
|
{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198},
|
||||||
{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132},
|
{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132},
|
||||||
{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94},
|
{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94},
|
||||||
{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71},
|
{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71},
|
||||||
{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55},
|
{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55},
|
||||||
{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44},
|
{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44},
|
||||||
{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36},
|
{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36},
|
||||||
{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30},
|
{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30},
|
||||||
{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25},
|
{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25},
|
||||||
{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22},
|
{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22},
|
||||||
{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18},
|
{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18},
|
||||||
{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16},
|
{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16},
|
||||||
{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15},
|
{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15},
|
||||||
{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13},
|
{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13},
|
||||||
{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11},
|
{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11},
|
||||||
{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10},
|
{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10},
|
||||||
{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9},
|
{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9},
|
||||||
{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8},
|
{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8},
|
||||||
{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8},
|
{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8},
|
||||||
{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7},
|
{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7},
|
||||||
{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7},
|
{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7},
|
||||||
{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6},
|
{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6},
|
||||||
{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5},
|
{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5},
|
||||||
{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5},
|
{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5},
|
||||||
{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5},
|
{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5},
|
||||||
{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4},
|
{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4},
|
||||||
{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4},
|
{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4},
|
||||||
{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4},
|
{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4},
|
||||||
{ 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3}
|
{ 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3}
|
||||||
};
|
};
|
||||||
|
|
||||||
#elif F_CPU == 20000000
|
#elif F_CPU == 20000000
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,14 @@
|
||||||
|
|
||||||
// These can't be used after statements in c89.
|
// These can't be used after statements in c89.
|
||||||
#ifdef __COUNTER__
|
#ifdef __COUNTER__
|
||||||
#define static_assert(e,m) \
|
#define static_assert(e,m) \
|
||||||
;enum { ASSERT_CONCAT(STATIC_ASSERT_, __COUNTER__) = 1/(int)(!!(e)) }
|
;enum { ASSERT_CONCAT(STATIC_ASSERT_, __COUNTER__) = 1/(int)(!!(e)) }
|
||||||
#else
|
#else
|
||||||
//This can't be used twice on the same line so ensure if using in headers
|
//This can't be used twice on the same line so ensure if using in headers
|
||||||
//that the headers are not included twice (by wrapping in #ifndef...#endif)
|
//that the headers are not included twice (by wrapping in #ifndef...#endif)
|
||||||
//Note it doesn't cause an issue when used on same line of separate modules
|
//Note it doesn't cause an issue when used on same line of separate modules
|
||||||
//compiled with gcc -combine -fwhole-program.
|
//compiled with gcc -combine -fwhole-program.
|
||||||
#define static_assert(e,m) \
|
#define static_assert(e,m) \
|
||||||
;enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(int)(!!(e)) }
|
;enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(int)(!!(e)) }
|
||||||
#endif //__COUNTER__
|
#endif //__COUNTER__
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,10 @@ bool z_max_endstop = false;
|
||||||
// Variables used by The Stepper Driver Interrupt
|
// Variables used by The Stepper Driver Interrupt
|
||||||
static unsigned char out_bits; // The next stepping-bits to be output
|
static unsigned char out_bits; // The next stepping-bits to be output
|
||||||
static dda_isteps_t
|
static dda_isteps_t
|
||||||
counter_x, // Counter variables for the bresenham line tracer
|
counter_x, // Counter variables for the bresenham line tracer
|
||||||
counter_y,
|
counter_y,
|
||||||
counter_z,
|
counter_z,
|
||||||
counter_e;
|
counter_e;
|
||||||
volatile dda_usteps_t step_events_completed; // The number of step events executed in the current block
|
volatile dda_usteps_t step_events_completed; // The number of step events executed in the current block
|
||||||
static int32_t acceleration_time, deceleration_time;
|
static int32_t acceleration_time, deceleration_time;
|
||||||
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
|
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
|
||||||
|
|
@ -78,7 +78,7 @@ static uint8_t step_loops;
|
||||||
static uint16_t OCR1A_nominal;
|
static uint16_t OCR1A_nominal;
|
||||||
static uint8_t step_loops_nominal;
|
static uint8_t step_loops_nominal;
|
||||||
|
|
||||||
volatile long endstops_trigsteps[3]= {0,0,0};
|
volatile long endstops_trigsteps[3]={0,0,0};
|
||||||
volatile long endstops_stepsTotal,endstops_stepsDone;
|
volatile long endstops_stepsTotal,endstops_stepsDone;
|
||||||
static volatile bool endstop_x_hit=false;
|
static volatile bool endstop_x_hit=false;
|
||||||
static volatile bool endstop_y_hit=false;
|
static volatile bool endstop_y_hit=false;
|
||||||
|
|
@ -87,9 +87,9 @@ static volatile bool endstop_z_hit=false;
|
||||||
bool abort_on_endstop_hit = false;
|
bool abort_on_endstop_hit = false;
|
||||||
#endif
|
#endif
|
||||||
#ifdef MOTOR_CURRENT_PWM_XY_PIN
|
#ifdef MOTOR_CURRENT_PWM_XY_PIN
|
||||||
int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT;
|
int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT;
|
||||||
int motor_current_setting_silent[3] = DEFAULT_PWM_MOTOR_CURRENT;
|
int motor_current_setting_silent[3] = DEFAULT_PWM_MOTOR_CURRENT;
|
||||||
int motor_current_setting_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD;
|
int motor_current_setting_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool old_x_min_endstop=false;
|
static bool old_x_min_endstop=false;
|
||||||
|
|
@ -109,24 +109,24 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
|
||||||
|
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
|
|
||||||
static uint16_t nextMainISR = 0;
|
static uint16_t nextMainISR = 0;
|
||||||
static uint16_t eISR_Rate;
|
static uint16_t eISR_Rate;
|
||||||
|
|
||||||
// Extrusion steps to be executed by the stepper.
|
// Extrusion steps to be executed by the stepper.
|
||||||
// If set to non zero, the timer ISR routine will tick the Linear Advance extruder ticks first.
|
// If set to non zero, the timer ISR routine will tick the Linear Advance extruder ticks first.
|
||||||
// If e_steps is zero, then the timer ISR routine will perform the usual DDA step.
|
// If e_steps is zero, then the timer ISR routine will perform the usual DDA step.
|
||||||
static volatile int16_t e_steps = 0;
|
static volatile int16_t e_steps = 0;
|
||||||
// How many extruder steps shall be ticked at a single ISR invocation?
|
// How many extruder steps shall be ticked at a single ISR invocation?
|
||||||
static uint8_t estep_loops;
|
static uint8_t estep_loops;
|
||||||
// The current speed of the extruder, scaled by the linear advance constant, so it has the same measure
|
// The current speed of the extruder, scaled by the linear advance constant, so it has the same measure
|
||||||
// as current_adv_steps.
|
// as current_adv_steps.
|
||||||
static int current_estep_rate;
|
static int current_estep_rate;
|
||||||
// The current pretension of filament expressed in extruder micro steps.
|
// The current pretension of filament expressed in extruder micro steps.
|
||||||
static int current_adv_steps;
|
static int current_adv_steps;
|
||||||
|
|
||||||
#define _NEXT_ISR(T) nextMainISR = T
|
#define _NEXT_ISR(T) nextMainISR = T
|
||||||
#else
|
#else
|
||||||
#define _NEXT_ISR(T) OCR1A = T
|
#define _NEXT_ISR(T) OCR1A = T
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_STEPPER_TIMER_MISSED
|
#ifdef DEBUG_STEPPER_TIMER_MISSED
|
||||||
|
|
@ -522,14 +522,14 @@ FORCE_INLINE void stepper_next_block()
|
||||||
// Set directions.
|
// Set directions.
|
||||||
out_bits = current_block->direction_bits;
|
out_bits = current_block->direction_bits;
|
||||||
// Set the direction bits (X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY)
|
// Set the direction bits (X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY)
|
||||||
if((out_bits & (1<<X_AXIS))!=0) {
|
if((out_bits & (1<<X_AXIS))!=0){
|
||||||
WRITE_NC(X_DIR_PIN, INVERT_X_DIR);
|
WRITE_NC(X_DIR_PIN, INVERT_X_DIR);
|
||||||
count_direction[X_AXIS]=-1;
|
count_direction[X_AXIS]=-1;
|
||||||
} else {
|
} else {
|
||||||
WRITE_NC(X_DIR_PIN, !INVERT_X_DIR);
|
WRITE_NC(X_DIR_PIN, !INVERT_X_DIR);
|
||||||
count_direction[X_AXIS]=1;
|
count_direction[X_AXIS]=1;
|
||||||
}
|
}
|
||||||
if((out_bits & (1<<Y_AXIS))!=0) {
|
if((out_bits & (1<<Y_AXIS))!=0){
|
||||||
WRITE_NC(Y_DIR_PIN, INVERT_Y_DIR);
|
WRITE_NC(Y_DIR_PIN, INVERT_Y_DIR);
|
||||||
count_direction[Y_AXIS]=-1;
|
count_direction[Y_AXIS]=-1;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -546,18 +546,18 @@ FORCE_INLINE void stepper_next_block()
|
||||||
if ((out_bits & (1 << E_AXIS)) != 0) { // -direction
|
if ((out_bits & (1 << E_AXIS)) != 0) { // -direction
|
||||||
#ifndef LIN_ADVANCE
|
#ifndef LIN_ADVANCE
|
||||||
WRITE(E0_DIR_PIN,
|
WRITE(E0_DIR_PIN,
|
||||||
#ifdef SNMM
|
#ifdef SNMM
|
||||||
(mmu_extruder == 0 || mmu_extruder == 2) ? !INVERT_E0_DIR :
|
(mmu_extruder == 0 || mmu_extruder == 2) ? !INVERT_E0_DIR :
|
||||||
#endif // SNMM
|
#endif // SNMM
|
||||||
INVERT_E0_DIR);
|
INVERT_E0_DIR);
|
||||||
#endif /* LIN_ADVANCE */
|
#endif /* LIN_ADVANCE */
|
||||||
count_direction[E_AXIS] = -1;
|
count_direction[E_AXIS] = -1;
|
||||||
} else { // +direction
|
} else { // +direction
|
||||||
#ifndef LIN_ADVANCE
|
#ifndef LIN_ADVANCE
|
||||||
WRITE(E0_DIR_PIN,
|
WRITE(E0_DIR_PIN,
|
||||||
#ifdef SNMM
|
#ifdef SNMM
|
||||||
(mmu_extruder == 0 || mmu_extruder == 2) ? INVERT_E0_DIR :
|
(mmu_extruder == 0 || mmu_extruder == 2) ? INVERT_E0_DIR :
|
||||||
#endif // SNMM
|
#endif // SNMM
|
||||||
!INVERT_E0_DIR);
|
!INVERT_E0_DIR);
|
||||||
#endif /* LIN_ADVANCE */
|
#endif /* LIN_ADVANCE */
|
||||||
count_direction[E_AXIS] = 1;
|
count_direction[E_AXIS] = 1;
|
||||||
|
|
@ -574,89 +574,89 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
{
|
{
|
||||||
if(check_endstops)
|
if(check_endstops)
|
||||||
{
|
{
|
||||||
#ifndef COREXY
|
#ifndef COREXY
|
||||||
if ((out_bits & (1<<X_AXIS)) != 0) // stepping along -X axis
|
if ((out_bits & (1<<X_AXIS)) != 0) // stepping along -X axis
|
||||||
#else
|
#else
|
||||||
if ((((out_bits & (1<<X_AXIS)) != 0)&&(out_bits & (1<<Y_AXIS)) != 0)) //-X occurs for -A and -B
|
if ((((out_bits & (1<<X_AXIS)) != 0)&&(out_bits & (1<<Y_AXIS)) != 0)) //-X occurs for -A and -B
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if ( (defined(X_MIN_PIN) && (X_MIN_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_XMINLIMIT)
|
#if ( (defined(X_MIN_PIN) && (X_MIN_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_XMINLIMIT)
|
||||||
#ifdef TMC2130_SG_HOMING
|
#ifdef TMC2130_SG_HOMING
|
||||||
// Stall guard homing turned on
|
// Stall guard homing turned on
|
||||||
x_min_endstop = (READ(X_TMC2130_DIAG) != 0);
|
x_min_endstop = (READ(X_TMC2130_DIAG) != 0);
|
||||||
#else
|
#else
|
||||||
// Normal homing
|
// Normal homing
|
||||||
x_min_endstop = (READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING);
|
x_min_endstop = (READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING);
|
||||||
#endif
|
#endif
|
||||||
if(x_min_endstop && old_x_min_endstop && (current_block->steps_x.wide > 0)) {
|
if(x_min_endstop && old_x_min_endstop && (current_block->steps_x.wide > 0)) {
|
||||||
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
||||||
endstop_x_hit=true;
|
endstop_x_hit=true;
|
||||||
step_events_completed.wide = current_block->step_event_count.wide;
|
step_events_completed.wide = current_block->step_event_count.wide;
|
||||||
}
|
}
|
||||||
old_x_min_endstop = x_min_endstop;
|
old_x_min_endstop = x_min_endstop;
|
||||||
#endif
|
#endif
|
||||||
} else { // +direction
|
} else { // +direction
|
||||||
#if ( (defined(X_MAX_PIN) && (X_MAX_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_XMAXLIMIT)
|
#if ( (defined(X_MAX_PIN) && (X_MAX_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_XMAXLIMIT)
|
||||||
#ifdef TMC2130_SG_HOMING
|
#ifdef TMC2130_SG_HOMING
|
||||||
// Stall guard homing turned on
|
// Stall guard homing turned on
|
||||||
x_max_endstop = (READ(X_TMC2130_DIAG) != 0);
|
x_max_endstop = (READ(X_TMC2130_DIAG) != 0);
|
||||||
#else
|
#else
|
||||||
// Normal homing
|
// Normal homing
|
||||||
x_max_endstop = (READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING);
|
x_max_endstop = (READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING);
|
||||||
#endif
|
#endif
|
||||||
if(x_max_endstop && old_x_max_endstop && (current_block->steps_x.wide > 0)) {
|
if(x_max_endstop && old_x_max_endstop && (current_block->steps_x.wide > 0)){
|
||||||
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
||||||
endstop_x_hit=true;
|
endstop_x_hit=true;
|
||||||
step_events_completed.wide = current_block->step_event_count.wide;
|
step_events_completed.wide = current_block->step_event_count.wide;
|
||||||
}
|
}
|
||||||
old_x_max_endstop = x_max_endstop;
|
old_x_max_endstop = x_max_endstop;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef COREXY
|
#ifndef COREXY
|
||||||
if ((out_bits & (1<<Y_AXIS)) != 0) // -direction
|
if ((out_bits & (1<<Y_AXIS)) != 0) // -direction
|
||||||
#else
|
#else
|
||||||
if ((((out_bits & (1<<X_AXIS)) != 0)&&(out_bits & (1<<Y_AXIS)) == 0)) // -Y occurs for -A and +B
|
if ((((out_bits & (1<<X_AXIS)) != 0)&&(out_bits & (1<<Y_AXIS)) == 0)) // -Y occurs for -A and +B
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if ( (defined(Y_MIN_PIN) && (Y_MIN_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_YMINLIMIT)
|
#if ( (defined(Y_MIN_PIN) && (Y_MIN_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_YMINLIMIT)
|
||||||
#ifdef TMC2130_SG_HOMING
|
#ifdef TMC2130_SG_HOMING
|
||||||
// Stall guard homing turned on
|
// Stall guard homing turned on
|
||||||
y_min_endstop = (READ(Y_TMC2130_DIAG) != 0);
|
y_min_endstop = (READ(Y_TMC2130_DIAG) != 0);
|
||||||
#else
|
#else
|
||||||
// Normal homing
|
// Normal homing
|
||||||
y_min_endstop = (READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING);
|
y_min_endstop = (READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING);
|
||||||
#endif
|
#endif
|
||||||
if(y_min_endstop && old_y_min_endstop && (current_block->steps_y.wide > 0)) {
|
if(y_min_endstop && old_y_min_endstop && (current_block->steps_y.wide > 0)) {
|
||||||
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
||||||
endstop_y_hit=true;
|
endstop_y_hit=true;
|
||||||
step_events_completed.wide = current_block->step_event_count.wide;
|
step_events_completed.wide = current_block->step_event_count.wide;
|
||||||
}
|
}
|
||||||
old_y_min_endstop = y_min_endstop;
|
old_y_min_endstop = y_min_endstop;
|
||||||
#endif
|
#endif
|
||||||
} else { // +direction
|
} else { // +direction
|
||||||
#if ( (defined(Y_MAX_PIN) && (Y_MAX_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_YMAXLIMIT)
|
#if ( (defined(Y_MAX_PIN) && (Y_MAX_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_YMAXLIMIT)
|
||||||
#ifdef TMC2130_SG_HOMING
|
#ifdef TMC2130_SG_HOMING
|
||||||
// Stall guard homing turned on
|
// Stall guard homing turned on
|
||||||
y_max_endstop = (READ(Y_TMC2130_DIAG) != 0);
|
y_max_endstop = (READ(Y_TMC2130_DIAG) != 0);
|
||||||
#else
|
#else
|
||||||
// Normal homing
|
// Normal homing
|
||||||
y_max_endstop = (READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING);
|
y_max_endstop = (READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING);
|
||||||
#endif
|
#endif
|
||||||
if(y_max_endstop && old_y_max_endstop && (current_block->steps_y.wide > 0)) {
|
if(y_max_endstop && old_y_max_endstop && (current_block->steps_y.wide > 0)){
|
||||||
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
||||||
endstop_y_hit=true;
|
endstop_y_hit=true;
|
||||||
step_events_completed.wide = current_block->step_event_count.wide;
|
step_events_completed.wide = current_block->step_event_count.wide;
|
||||||
}
|
}
|
||||||
old_y_max_endstop = y_max_endstop;
|
old_y_max_endstop = y_max_endstop;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((out_bits & (1<<Z_AXIS)) != 0) // -direction
|
if ((out_bits & (1<<Z_AXIS)) != 0) // -direction
|
||||||
{
|
{
|
||||||
#if defined(Z_MIN_PIN) && (Z_MIN_PIN > -1) && !defined(DEBUG_DISABLE_ZMINLIMIT)
|
#if defined(Z_MIN_PIN) && (Z_MIN_PIN > -1) && !defined(DEBUG_DISABLE_ZMINLIMIT)
|
||||||
if (! check_z_endstop) {
|
if (! check_z_endstop) {
|
||||||
#ifdef TMC2130_SG_HOMING
|
#ifdef TMC2130_SG_HOMING
|
||||||
// Stall guard homing turned on
|
// Stall guard homing turned on
|
||||||
#ifdef TMC2130_STEALTH_Z
|
#ifdef TMC2130_STEALTH_Z
|
||||||
if ((tmc2130_mode == TMC2130_MODE_SILENT) && !(tmc2130_sg_homing_axes_mask & 0x04))
|
if ((tmc2130_mode == TMC2130_MODE_SILENT) && !(tmc2130_sg_homing_axes_mask & 0x04))
|
||||||
|
|
@ -664,9 +664,9 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
else
|
else
|
||||||
#endif //TMC2130_STEALTH_Z
|
#endif //TMC2130_STEALTH_Z
|
||||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) || (READ(Z_TMC2130_DIAG) != 0);
|
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) || (READ(Z_TMC2130_DIAG) != 0);
|
||||||
#else
|
#else
|
||||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
|
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
|
||||||
#endif //TMC2130_SG_HOMING
|
#endif //TMC2130_SG_HOMING
|
||||||
if(z_min_endstop && old_z_min_endstop && (current_block->steps_z.wide > 0)) {
|
if(z_min_endstop && old_z_min_endstop && (current_block->steps_z.wide > 0)) {
|
||||||
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
||||||
endstop_z_hit=true;
|
endstop_z_hit=true;
|
||||||
|
|
@ -674,10 +674,10 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
}
|
}
|
||||||
old_z_min_endstop = z_min_endstop;
|
old_z_min_endstop = z_min_endstop;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else { // +direction
|
} else { // +direction
|
||||||
#if defined(Z_MAX_PIN) && (Z_MAX_PIN > -1) && !defined(DEBUG_DISABLE_ZMAXLIMIT)
|
#if defined(Z_MAX_PIN) && (Z_MAX_PIN > -1) && !defined(DEBUG_DISABLE_ZMAXLIMIT)
|
||||||
#ifdef TMC2130_SG_HOMING
|
#ifdef TMC2130_SG_HOMING
|
||||||
// Stall guard homing turned on
|
// Stall guard homing turned on
|
||||||
#ifdef TMC2130_STEALTH_Z
|
#ifdef TMC2130_STEALTH_Z
|
||||||
if ((tmc2130_mode == TMC2130_MODE_SILENT) && !(tmc2130_sg_homing_axes_mask & 0x04))
|
if ((tmc2130_mode == TMC2130_MODE_SILENT) && !(tmc2130_sg_homing_axes_mask & 0x04))
|
||||||
|
|
@ -685,25 +685,25 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
else
|
else
|
||||||
#endif //TMC2130_STEALTH_Z
|
#endif //TMC2130_STEALTH_Z
|
||||||
z_max_endstop = (READ(Z_TMC2130_DIAG) != 0);
|
z_max_endstop = (READ(Z_TMC2130_DIAG) != 0);
|
||||||
#else
|
#else
|
||||||
z_max_endstop = (READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING);
|
z_max_endstop = (READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING);
|
||||||
#endif //TMC2130_SG_HOMING
|
#endif //TMC2130_SG_HOMING
|
||||||
if(z_max_endstop && old_z_max_endstop && (current_block->steps_z.wide > 0)) {
|
if(z_max_endstop && old_z_max_endstop && (current_block->steps_z.wide > 0)) {
|
||||||
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
||||||
endstop_z_hit=true;
|
endstop_z_hit=true;
|
||||||
step_events_completed.wide = current_block->step_event_count.wide;
|
step_events_completed.wide = current_block->step_event_count.wide;
|
||||||
}
|
}
|
||||||
old_z_max_endstop = z_max_endstop;
|
old_z_max_endstop = z_max_endstop;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Supporting stopping on a trigger of the Z-stop induction sensor, not only for the Z-minus movements.
|
// Supporting stopping on a trigger of the Z-stop induction sensor, not only for the Z-minus movements.
|
||||||
#if defined(Z_MIN_PIN) && (Z_MIN_PIN > -1) && !defined(DEBUG_DISABLE_ZMINLIMIT)
|
#if defined(Z_MIN_PIN) && (Z_MIN_PIN > -1) && !defined(DEBUG_DISABLE_ZMINLIMIT)
|
||||||
if (check_z_endstop) {
|
if (check_z_endstop) {
|
||||||
// Check the Z min end-stop no matter what.
|
// Check the Z min end-stop no matter what.
|
||||||
// Good for searching for the center of an induction target.
|
// Good for searching for the center of an induction target.
|
||||||
#ifdef TMC2130_SG_HOMING
|
#ifdef TMC2130_SG_HOMING
|
||||||
// Stall guard homing turned on
|
// Stall guard homing turned on
|
||||||
#ifdef TMC2130_STEALTH_Z
|
#ifdef TMC2130_STEALTH_Z
|
||||||
if ((tmc2130_mode == TMC2130_MODE_SILENT) && !(tmc2130_sg_homing_axes_mask & 0x04))
|
if ((tmc2130_mode == TMC2130_MODE_SILENT) && !(tmc2130_sg_homing_axes_mask & 0x04))
|
||||||
|
|
@ -711,9 +711,9 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
else
|
else
|
||||||
#endif //TMC2130_STEALTH_Z
|
#endif //TMC2130_STEALTH_Z
|
||||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) || (READ(Z_TMC2130_DIAG) != 0);
|
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) || (READ(Z_TMC2130_DIAG) != 0);
|
||||||
#else
|
#else
|
||||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
|
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
|
||||||
#endif //TMC2130_SG_HOMING
|
#endif //TMC2130_SG_HOMING
|
||||||
if(z_min_endstop && old_z_min_endstop) {
|
if(z_min_endstop && old_z_min_endstop) {
|
||||||
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
||||||
endstop_z_hit=true;
|
endstop_z_hit=true;
|
||||||
|
|
@ -721,7 +721,7 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
}
|
}
|
||||||
old_z_min_endstop = z_min_endstop;
|
old_z_min_endstop = z_min_endstop;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -776,9 +776,9 @@ FORCE_INLINE void stepper_tick_lowres()
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
++ e_steps;
|
++ e_steps;
|
||||||
#else
|
#else
|
||||||
#ifdef FILAMENT_SENSOR
|
#ifdef FILAMENT_SENSOR
|
||||||
++ fsensor_counter;
|
++ fsensor_counter;
|
||||||
#endif //FILAMENT_SENSOR
|
#endif //FILAMENT_SENSOR
|
||||||
WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN);
|
WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -838,9 +838,9 @@ FORCE_INLINE void stepper_tick_highres()
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
++ e_steps;
|
++ e_steps;
|
||||||
#else
|
#else
|
||||||
#ifdef FILAMENT_SENSOR
|
#ifdef FILAMENT_SENSOR
|
||||||
++ fsensor_counter;
|
++ fsensor_counter;
|
||||||
#endif //FILAMENT_SENSOR
|
#endif //FILAMENT_SENSOR
|
||||||
WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN);
|
WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -896,11 +896,11 @@ FORCE_INLINE void isr() {
|
||||||
bool neg = e_steps < 0;
|
bool neg = e_steps < 0;
|
||||||
{
|
{
|
||||||
bool dir =
|
bool dir =
|
||||||
#ifdef SNMM
|
#ifdef SNMM
|
||||||
(neg == (mmu_extruder & 1))
|
(neg == (mmu_extruder & 1))
|
||||||
#else
|
#else
|
||||||
neg
|
neg
|
||||||
#endif
|
#endif
|
||||||
? INVERT_E0_DIR : !INVERT_E0_DIR; //If we have SNMM, reverse every second extruder.
|
? INVERT_E0_DIR : !INVERT_E0_DIR; //If we have SNMM, reverse every second extruder.
|
||||||
WRITE_NC(E0_DIR_PIN, dir);
|
WRITE_NC(E0_DIR_PIN, dir);
|
||||||
if (neg)
|
if (neg)
|
||||||
|
|
@ -953,11 +953,11 @@ FORCE_INLINE void isr() {
|
||||||
uint16_t timer = calc_timer(acc_step_rate);
|
uint16_t timer = calc_timer(acc_step_rate);
|
||||||
_NEXT_ISR(timer);
|
_NEXT_ISR(timer);
|
||||||
acceleration_time += timer;
|
acceleration_time += timer;
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
if (current_block->use_advance_lead)
|
if (current_block->use_advance_lead)
|
||||||
// int32_t = (uint16_t * uint32_t) >> 17
|
// int32_t = (uint16_t * uint32_t) >> 17
|
||||||
current_estep_rate = ((uint32_t)acc_step_rate * current_block->abs_adv_steps_multiplier8) >> 17;
|
current_estep_rate = ((uint32_t)acc_step_rate * current_block->abs_adv_steps_multiplier8) >> 17;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (step_events_completed.wide > (unsigned long int)current_block->decelerate_after) {
|
else if (step_events_completed.wide > (unsigned long int)current_block->decelerate_after) {
|
||||||
uint16_t step_rate;
|
uint16_t step_rate;
|
||||||
|
|
@ -971,10 +971,10 @@ FORCE_INLINE void isr() {
|
||||||
uint16_t timer = calc_timer(step_rate);
|
uint16_t timer = calc_timer(step_rate);
|
||||||
_NEXT_ISR(timer);
|
_NEXT_ISR(timer);
|
||||||
deceleration_time += timer;
|
deceleration_time += timer;
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
if (current_block->use_advance_lead)
|
if (current_block->use_advance_lead)
|
||||||
current_estep_rate = ((uint32_t)step_rate * current_block->abs_adv_steps_multiplier8) >> 17;
|
current_estep_rate = ((uint32_t)step_rate * current_block->abs_adv_steps_multiplier8) >> 17;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (! step_loops_nominal) {
|
if (! step_loops_nominal) {
|
||||||
|
|
@ -982,10 +982,10 @@ FORCE_INLINE void isr() {
|
||||||
// the initial interrupt blocking.
|
// the initial interrupt blocking.
|
||||||
OCR1A_nominal = calc_timer(uint16_t(current_block->nominal_rate));
|
OCR1A_nominal = calc_timer(uint16_t(current_block->nominal_rate));
|
||||||
step_loops_nominal = step_loops;
|
step_loops_nominal = step_loops;
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
if (current_block->use_advance_lead)
|
if (current_block->use_advance_lead)
|
||||||
current_estep_rate = (current_block->nominal_rate * current_block->abs_adv_steps_multiplier8) >> 17;
|
current_estep_rate = (current_block->nominal_rate * current_block->abs_adv_steps_multiplier8) >> 17;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
_NEXT_ISR(OCR1A_nominal);
|
_NEXT_ISR(OCR1A_nominal);
|
||||||
}
|
}
|
||||||
|
|
@ -1128,80 +1128,80 @@ void st_init()
|
||||||
microstep_init(); //Initialize Microstepping Pins
|
microstep_init(); //Initialize Microstepping Pins
|
||||||
|
|
||||||
//Initialize Dir Pins
|
//Initialize Dir Pins
|
||||||
#if defined(X_DIR_PIN) && X_DIR_PIN > -1
|
#if defined(X_DIR_PIN) && X_DIR_PIN > -1
|
||||||
SET_OUTPUT(X_DIR_PIN);
|
SET_OUTPUT(X_DIR_PIN);
|
||||||
#endif
|
#endif
|
||||||
#if defined(X2_DIR_PIN) && X2_DIR_PIN > -1
|
#if defined(X2_DIR_PIN) && X2_DIR_PIN > -1
|
||||||
SET_OUTPUT(X2_DIR_PIN);
|
SET_OUTPUT(X2_DIR_PIN);
|
||||||
#endif
|
#endif
|
||||||
#if defined(Y_DIR_PIN) && Y_DIR_PIN > -1
|
#if defined(Y_DIR_PIN) && Y_DIR_PIN > -1
|
||||||
SET_OUTPUT(Y_DIR_PIN);
|
SET_OUTPUT(Y_DIR_PIN);
|
||||||
|
|
||||||
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1)
|
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1)
|
||||||
SET_OUTPUT(Y2_DIR_PIN);
|
SET_OUTPUT(Y2_DIR_PIN);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(Z_DIR_PIN) && Z_DIR_PIN > -1
|
#if defined(Z_DIR_PIN) && Z_DIR_PIN > -1
|
||||||
SET_OUTPUT(Z_DIR_PIN);
|
SET_OUTPUT(Z_DIR_PIN);
|
||||||
|
|
||||||
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_DIR_PIN) && (Z2_DIR_PIN > -1)
|
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_DIR_PIN) && (Z2_DIR_PIN > -1)
|
||||||
SET_OUTPUT(Z2_DIR_PIN);
|
SET_OUTPUT(Z2_DIR_PIN);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(E0_DIR_PIN) && E0_DIR_PIN > -1
|
#if defined(E0_DIR_PIN) && E0_DIR_PIN > -1
|
||||||
SET_OUTPUT(E0_DIR_PIN);
|
SET_OUTPUT(E0_DIR_PIN);
|
||||||
#endif
|
#endif
|
||||||
#if defined(E1_DIR_PIN) && (E1_DIR_PIN > -1)
|
#if defined(E1_DIR_PIN) && (E1_DIR_PIN > -1)
|
||||||
SET_OUTPUT(E1_DIR_PIN);
|
SET_OUTPUT(E1_DIR_PIN);
|
||||||
#endif
|
#endif
|
||||||
#if defined(E2_DIR_PIN) && (E2_DIR_PIN > -1)
|
#if defined(E2_DIR_PIN) && (E2_DIR_PIN > -1)
|
||||||
SET_OUTPUT(E2_DIR_PIN);
|
SET_OUTPUT(E2_DIR_PIN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Initialize Enable Pins - steppers default to disabled.
|
//Initialize Enable Pins - steppers default to disabled.
|
||||||
|
|
||||||
#if defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1
|
#if defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1
|
||||||
SET_OUTPUT(X_ENABLE_PIN);
|
SET_OUTPUT(X_ENABLE_PIN);
|
||||||
if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
|
if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
#if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
|
#if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
|
||||||
SET_OUTPUT(X2_ENABLE_PIN);
|
SET_OUTPUT(X2_ENABLE_PIN);
|
||||||
if(!X_ENABLE_ON) WRITE(X2_ENABLE_PIN,HIGH);
|
if(!X_ENABLE_ON) WRITE(X2_ENABLE_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
|
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
|
||||||
SET_OUTPUT(Y_ENABLE_PIN);
|
SET_OUTPUT(Y_ENABLE_PIN);
|
||||||
if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
|
if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
|
||||||
|
|
||||||
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1)
|
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1)
|
||||||
SET_OUTPUT(Y2_ENABLE_PIN);
|
SET_OUTPUT(Y2_ENABLE_PIN);
|
||||||
if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH);
|
if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
|
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
|
||||||
SET_OUTPUT(Z_ENABLE_PIN);
|
SET_OUTPUT(Z_ENABLE_PIN);
|
||||||
if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
|
if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
|
||||||
|
|
||||||
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_ENABLE_PIN) && (Z2_ENABLE_PIN > -1)
|
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_ENABLE_PIN) && (Z2_ENABLE_PIN > -1)
|
||||||
SET_OUTPUT(Z2_ENABLE_PIN);
|
SET_OUTPUT(Z2_ENABLE_PIN);
|
||||||
if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH);
|
if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
|
#if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
|
||||||
SET_OUTPUT(E0_ENABLE_PIN);
|
SET_OUTPUT(E0_ENABLE_PIN);
|
||||||
if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
|
if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
#if defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
|
#if defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
|
||||||
SET_OUTPUT(E1_ENABLE_PIN);
|
SET_OUTPUT(E1_ENABLE_PIN);
|
||||||
if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
|
if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
#if defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
|
#if defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
|
||||||
SET_OUTPUT(E2_ENABLE_PIN);
|
SET_OUTPUT(E2_ENABLE_PIN);
|
||||||
if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
|
if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//endstops and pullups
|
//endstops and pullups
|
||||||
|
|
||||||
#ifdef TMC2130_SG_HOMING
|
#ifdef TMC2130_SG_HOMING
|
||||||
SET_INPUT(X_TMC2130_DIAG);
|
SET_INPUT(X_TMC2130_DIAG);
|
||||||
WRITE(X_TMC2130_DIAG,HIGH);
|
WRITE(X_TMC2130_DIAG,HIGH);
|
||||||
|
|
||||||
|
|
@ -1214,56 +1214,56 @@ void st_init()
|
||||||
SET_INPUT(E0_TMC2130_DIAG);
|
SET_INPUT(E0_TMC2130_DIAG);
|
||||||
WRITE(E0_TMC2130_DIAG,HIGH);
|
WRITE(E0_TMC2130_DIAG,HIGH);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(X_MIN_PIN) && X_MIN_PIN > -1
|
#if defined(X_MIN_PIN) && X_MIN_PIN > -1
|
||||||
SET_INPUT(X_MIN_PIN);
|
SET_INPUT(X_MIN_PIN);
|
||||||
#ifdef ENDSTOPPULLUP_XMIN
|
#ifdef ENDSTOPPULLUP_XMIN
|
||||||
WRITE(X_MIN_PIN,HIGH);
|
WRITE(X_MIN_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
|
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
|
||||||
SET_INPUT(Y_MIN_PIN);
|
SET_INPUT(Y_MIN_PIN);
|
||||||
#ifdef ENDSTOPPULLUP_YMIN
|
#ifdef ENDSTOPPULLUP_YMIN
|
||||||
WRITE(Y_MIN_PIN,HIGH);
|
WRITE(Y_MIN_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
|
#if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
|
||||||
SET_INPUT(Z_MIN_PIN);
|
SET_INPUT(Z_MIN_PIN);
|
||||||
#ifdef ENDSTOPPULLUP_ZMIN
|
#ifdef ENDSTOPPULLUP_ZMIN
|
||||||
WRITE(Z_MIN_PIN,HIGH);
|
WRITE(Z_MIN_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(X_MAX_PIN) && X_MAX_PIN > -1
|
#if defined(X_MAX_PIN) && X_MAX_PIN > -1
|
||||||
SET_INPUT(X_MAX_PIN);
|
SET_INPUT(X_MAX_PIN);
|
||||||
#ifdef ENDSTOPPULLUP_XMAX
|
#ifdef ENDSTOPPULLUP_XMAX
|
||||||
WRITE(X_MAX_PIN,HIGH);
|
WRITE(X_MAX_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
|
#if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
|
||||||
SET_INPUT(Y_MAX_PIN);
|
SET_INPUT(Y_MAX_PIN);
|
||||||
#ifdef ENDSTOPPULLUP_YMAX
|
#ifdef ENDSTOPPULLUP_YMAX
|
||||||
WRITE(Y_MAX_PIN,HIGH);
|
WRITE(Y_MAX_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
|
#if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
|
||||||
SET_INPUT(Z_MAX_PIN);
|
SET_INPUT(Z_MAX_PIN);
|
||||||
#ifdef ENDSTOPPULLUP_ZMAX
|
#ifdef ENDSTOPPULLUP_ZMAX
|
||||||
WRITE(Z_MAX_PIN,HIGH);
|
WRITE(Z_MAX_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(FANCHECK) && defined(TACH_0) && (TACH_0 > -1))
|
#if (defined(FANCHECK) && defined(TACH_0) && (TACH_0 > -1))
|
||||||
SET_INPUT(TACH_0);
|
SET_INPUT(TACH_0);
|
||||||
#ifdef TACH0PULLUP
|
#ifdef TACH0PULLUP
|
||||||
WRITE(TACH_0, HIGH);
|
WRITE(TACH_0, HIGH);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//Initialize Step Pins
|
//Initialize Step Pins
|
||||||
|
|
@ -1275,49 +1275,49 @@ void st_init()
|
||||||
WRITE(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN);
|
WRITE(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN);
|
||||||
#endif //DEBUG_XSTEP_DUP_PIN
|
#endif //DEBUG_XSTEP_DUP_PIN
|
||||||
disable_x();
|
disable_x();
|
||||||
#endif
|
#endif
|
||||||
#if defined(X2_STEP_PIN) && (X2_STEP_PIN > -1)
|
#if defined(X2_STEP_PIN) && (X2_STEP_PIN > -1)
|
||||||
SET_OUTPUT(X2_STEP_PIN);
|
SET_OUTPUT(X2_STEP_PIN);
|
||||||
WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
|
WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
|
||||||
disable_x();
|
disable_x();
|
||||||
#endif
|
#endif
|
||||||
#if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1)
|
#if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1)
|
||||||
SET_OUTPUT(Y_STEP_PIN);
|
SET_OUTPUT(Y_STEP_PIN);
|
||||||
WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
|
WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
|
||||||
#ifdef DEBUG_YSTEP_DUP_PIN
|
#ifdef DEBUG_YSTEP_DUP_PIN
|
||||||
SET_OUTPUT(DEBUG_YSTEP_DUP_PIN);
|
SET_OUTPUT(DEBUG_YSTEP_DUP_PIN);
|
||||||
WRITE(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN);
|
WRITE(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN);
|
||||||
#endif //DEBUG_YSTEP_DUP_PIN
|
#endif //DEBUG_YSTEP_DUP_PIN
|
||||||
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1)
|
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1)
|
||||||
SET_OUTPUT(Y2_STEP_PIN);
|
SET_OUTPUT(Y2_STEP_PIN);
|
||||||
WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN);
|
WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN);
|
||||||
#endif
|
#endif
|
||||||
disable_y();
|
disable_y();
|
||||||
#endif
|
#endif
|
||||||
#if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1)
|
#if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1)
|
||||||
SET_OUTPUT(Z_STEP_PIN);
|
SET_OUTPUT(Z_STEP_PIN);
|
||||||
WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
|
WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
|
||||||
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_STEP_PIN) && (Z2_STEP_PIN > -1)
|
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_STEP_PIN) && (Z2_STEP_PIN > -1)
|
||||||
SET_OUTPUT(Z2_STEP_PIN);
|
SET_OUTPUT(Z2_STEP_PIN);
|
||||||
WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
|
WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
|
||||||
#endif
|
#endif
|
||||||
disable_z();
|
disable_z();
|
||||||
#endif
|
#endif
|
||||||
#if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1)
|
#if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1)
|
||||||
SET_OUTPUT(E0_STEP_PIN);
|
SET_OUTPUT(E0_STEP_PIN);
|
||||||
WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
|
WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
|
||||||
disable_e0();
|
disable_e0();
|
||||||
#endif
|
#endif
|
||||||
#if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1)
|
#if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1)
|
||||||
SET_OUTPUT(E1_STEP_PIN);
|
SET_OUTPUT(E1_STEP_PIN);
|
||||||
WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN);
|
WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN);
|
||||||
disable_e1();
|
disable_e1();
|
||||||
#endif
|
#endif
|
||||||
#if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1)
|
#if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1)
|
||||||
SET_OUTPUT(E2_STEP_PIN);
|
SET_OUTPUT(E2_STEP_PIN);
|
||||||
WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
|
WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
|
||||||
disable_e2();
|
disable_e2();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// waveform generation = 0100 = CTC
|
// waveform generation = 0100 = CTC
|
||||||
TCCR1B &= ~(1<<WGM13);
|
TCCR1B &= ~(1<<WGM13);
|
||||||
|
|
@ -1502,31 +1502,30 @@ void babystep(const uint8_t axis,const bool direction)
|
||||||
uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //if dualzstepper, both point to same direction.
|
uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //if dualzstepper, both point to same direction.
|
||||||
//setup new step
|
//setup new step
|
||||||
WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
|
WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
|
||||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||||
WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
|
WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
|
||||||
#endif
|
#endif
|
||||||
//perform step
|
//perform step
|
||||||
WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
|
WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
|
||||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||||
WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
|
WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
|
||||||
#endif
|
#endif
|
||||||
delayMicroseconds(1);
|
delayMicroseconds(1);
|
||||||
WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
|
WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
|
||||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||||
WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
|
WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//get old pin state back.
|
//get old pin state back.
|
||||||
WRITE(Z_DIR_PIN,old_z_dir_pin);
|
WRITE(Z_DIR_PIN,old_z_dir_pin);
|
||||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||||
WRITE(Z2_DIR_PIN,old_z_dir_pin);
|
WRITE(Z2_DIR_PIN,old_z_dir_pin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif //BABYSTEPPING
|
#endif //BABYSTEPPING
|
||||||
|
|
@ -1549,25 +1548,25 @@ void EEPROM_read_st(int pos, uint8_t* value, uint8_t size)
|
||||||
*value = eeprom_read_byte((unsigned char*)pos);
|
*value = eeprom_read_byte((unsigned char*)pos);
|
||||||
pos++;
|
pos++;
|
||||||
value++;
|
value++;
|
||||||
} while(--size);
|
}while(--size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void st_current_init() //Initialize Digipot Motor Current
|
void st_current_init() //Initialize Digipot Motor Current
|
||||||
{
|
{
|
||||||
uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
|
uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
|
||||||
SilentModeMenu = SilentMode;
|
SilentModeMenu = SilentMode;
|
||||||
#ifdef MOTOR_CURRENT_PWM_XY_PIN
|
#ifdef MOTOR_CURRENT_PWM_XY_PIN
|
||||||
pinMode(MOTOR_CURRENT_PWM_XY_PIN, OUTPUT);
|
pinMode(MOTOR_CURRENT_PWM_XY_PIN, OUTPUT);
|
||||||
pinMode(MOTOR_CURRENT_PWM_Z_PIN, OUTPUT);
|
pinMode(MOTOR_CURRENT_PWM_Z_PIN, OUTPUT);
|
||||||
pinMode(MOTOR_CURRENT_PWM_E_PIN, OUTPUT);
|
pinMode(MOTOR_CURRENT_PWM_E_PIN, OUTPUT);
|
||||||
if((SilentMode == SILENT_MODE_OFF) || (farm_mode) ) {
|
if((SilentMode == SILENT_MODE_OFF) || (farm_mode) ){
|
||||||
|
|
||||||
motor_current_setting[0] = motor_current_setting_loud[0];
|
motor_current_setting[0] = motor_current_setting_loud[0];
|
||||||
motor_current_setting[1] = motor_current_setting_loud[1];
|
motor_current_setting[1] = motor_current_setting_loud[1];
|
||||||
motor_current_setting[2] = motor_current_setting_loud[2];
|
motor_current_setting[2] = motor_current_setting_loud[2];
|
||||||
|
|
||||||
} else {
|
}else{
|
||||||
|
|
||||||
motor_current_setting[0] = motor_current_setting_silent[0];
|
motor_current_setting[0] = motor_current_setting_silent[0];
|
||||||
motor_current_setting[1] = motor_current_setting_silent[1];
|
motor_current_setting[1] = motor_current_setting_silent[1];
|
||||||
|
|
@ -1579,7 +1578,7 @@ void st_current_init() //Initialize Digipot Motor Current
|
||||||
st_current_set(2, motor_current_setting[2]);
|
st_current_set(2, motor_current_setting[2]);
|
||||||
//Set timer5 to 31khz so the PWM of the motor power is as constant as possible. (removes a buzzing noise)
|
//Set timer5 to 31khz so the PWM of the motor power is as constant as possible. (removes a buzzing noise)
|
||||||
TCCR5B = (TCCR5B & ~(_BV(CS50) | _BV(CS51) | _BV(CS52))) | _BV(CS50);
|
TCCR5B = (TCCR5B & ~(_BV(CS50) | _BV(CS51) | _BV(CS52))) | _BV(CS50);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1592,18 +1591,18 @@ void st_current_set(uint8_t driver, int current)
|
||||||
if (driver == 2) analogWrite(MOTOR_CURRENT_PWM_E_PIN, (long)current * 255L / (long)MOTOR_CURRENT_PWM_RANGE);
|
if (driver == 2) analogWrite(MOTOR_CURRENT_PWM_E_PIN, (long)current * 255L / (long)MOTOR_CURRENT_PWM_RANGE);
|
||||||
}
|
}
|
||||||
#else //MOTOR_CURRENT_PWM_XY_PIN
|
#else //MOTOR_CURRENT_PWM_XY_PIN
|
||||||
void st_current_set(uint8_t, int ) {}
|
void st_current_set(uint8_t, int ){}
|
||||||
#endif //MOTOR_CURRENT_PWM_XY_PIN
|
#endif //MOTOR_CURRENT_PWM_XY_PIN
|
||||||
|
|
||||||
void microstep_init()
|
void microstep_init()
|
||||||
{
|
{
|
||||||
|
|
||||||
#if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
|
#if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
|
||||||
pinMode(E1_MS1_PIN,OUTPUT);
|
pinMode(E1_MS1_PIN,OUTPUT);
|
||||||
pinMode(E1_MS2_PIN,OUTPUT);
|
pinMode(E1_MS2_PIN,OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(X_MS1_PIN) && X_MS1_PIN > -1
|
#if defined(X_MS1_PIN) && X_MS1_PIN > -1
|
||||||
const uint8_t microstep_modes[] = MICROSTEP_MODES;
|
const uint8_t microstep_modes[] = MICROSTEP_MODES;
|
||||||
pinMode(X_MS1_PIN,OUTPUT);
|
pinMode(X_MS1_PIN,OUTPUT);
|
||||||
pinMode(X_MS2_PIN,OUTPUT);
|
pinMode(X_MS2_PIN,OUTPUT);
|
||||||
|
|
@ -1613,8 +1612,8 @@ void microstep_init()
|
||||||
pinMode(Z_MS2_PIN,OUTPUT);
|
pinMode(Z_MS2_PIN,OUTPUT);
|
||||||
pinMode(E0_MS1_PIN,OUTPUT);
|
pinMode(E0_MS1_PIN,OUTPUT);
|
||||||
pinMode(E0_MS2_PIN,OUTPUT);
|
pinMode(E0_MS2_PIN,OUTPUT);
|
||||||
for(int i=0; i<=4; i++) microstep_mode(i,microstep_modes[i]);
|
for(int i=0;i<=4;i++) microstep_mode(i,microstep_modes[i]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1624,43 +1623,23 @@ void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2)
|
||||||
{
|
{
|
||||||
if(ms1 > -1) switch(driver)
|
if(ms1 > -1) switch(driver)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0: digitalWrite( X_MS1_PIN,ms1); break;
|
||||||
digitalWrite( X_MS1_PIN,ms1);
|
case 1: digitalWrite( Y_MS1_PIN,ms1); break;
|
||||||
break;
|
case 2: digitalWrite( Z_MS1_PIN,ms1); break;
|
||||||
case 1:
|
case 3: digitalWrite(E0_MS1_PIN,ms1); break;
|
||||||
digitalWrite( Y_MS1_PIN,ms1);
|
#if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
|
||||||
break;
|
case 4: digitalWrite(E1_MS1_PIN,ms1); break;
|
||||||
case 2:
|
#endif
|
||||||
digitalWrite( Z_MS1_PIN,ms1);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
digitalWrite(E0_MS1_PIN,ms1);
|
|
||||||
break;
|
|
||||||
#if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
|
|
||||||
case 4:
|
|
||||||
digitalWrite(E1_MS1_PIN,ms1);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if(ms2 > -1) switch(driver)
|
if(ms2 > -1) switch(driver)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0: digitalWrite( X_MS2_PIN,ms2); break;
|
||||||
digitalWrite( X_MS2_PIN,ms2);
|
case 1: digitalWrite( Y_MS2_PIN,ms2); break;
|
||||||
break;
|
case 2: digitalWrite( Z_MS2_PIN,ms2); break;
|
||||||
case 1:
|
case 3: digitalWrite(E0_MS2_PIN,ms2); break;
|
||||||
digitalWrite( Y_MS2_PIN,ms2);
|
#if defined(E1_MS2_PIN) && E1_MS2_PIN > -1
|
||||||
break;
|
case 4: digitalWrite(E1_MS2_PIN,ms2); break;
|
||||||
case 2:
|
#endif
|
||||||
digitalWrite( Z_MS2_PIN,ms2);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
digitalWrite(E0_MS2_PIN,ms2);
|
|
||||||
break;
|
|
||||||
#if defined(E1_MS2_PIN) && E1_MS2_PIN > -1
|
|
||||||
case 4:
|
|
||||||
digitalWrite(E1_MS2_PIN,ms2);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1668,21 +1647,11 @@ void microstep_mode(uint8_t driver, uint8_t stepping_mode)
|
||||||
{
|
{
|
||||||
switch(stepping_mode)
|
switch(stepping_mode)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1: microstep_ms(driver,MICROSTEP1); break;
|
||||||
microstep_ms(driver,MICROSTEP1);
|
case 2: microstep_ms(driver,MICROSTEP2); break;
|
||||||
break;
|
case 4: microstep_ms(driver,MICROSTEP4); break;
|
||||||
case 2:
|
case 8: microstep_ms(driver,MICROSTEP8); break;
|
||||||
microstep_ms(driver,MICROSTEP2);
|
case 16: microstep_ms(driver,MICROSTEP16); break;
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
microstep_ms(driver,MICROSTEP4);
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
microstep_ms(driver,MICROSTEP8);
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
microstep_ms(driver,MICROSTEP16);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1701,10 +1670,10 @@ void microstep_readings()
|
||||||
SERIAL_PROTOCOLPGM("E0: ");
|
SERIAL_PROTOCOLPGM("E0: ");
|
||||||
SERIAL_PROTOCOL( digitalRead(E0_MS1_PIN));
|
SERIAL_PROTOCOL( digitalRead(E0_MS1_PIN));
|
||||||
SERIAL_PROTOCOLLN( digitalRead(E0_MS2_PIN));
|
SERIAL_PROTOCOLLN( digitalRead(E0_MS2_PIN));
|
||||||
#if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
|
#if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
|
||||||
SERIAL_PROTOCOLPGM("E1: ");
|
SERIAL_PROTOCOLPGM("E1: ");
|
||||||
SERIAL_PROTOCOL( digitalRead(E1_MS1_PIN));
|
SERIAL_PROTOCOL( digitalRead(E1_MS1_PIN));
|
||||||
SERIAL_PROTOCOLLN( digitalRead(E1_MS2_PIN));
|
SERIAL_PROTOCOLLN( digitalRead(E1_MS2_PIN));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif //TMC2130
|
#endif //TMC2130
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,9 @@ void st_init();
|
||||||
void isr();
|
void isr();
|
||||||
|
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
void advance_isr();
|
void advance_isr();
|
||||||
void advance_isr_scheduler();
|
void advance_isr_scheduler();
|
||||||
void clear_current_adv_vars(); //Used to reset the built up pretension and remaining esteps on filament change.
|
void clear_current_adv_vars(); //Used to reset the built up pretension and remaining esteps on filament change.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Block until all buffered steps are executed
|
// Block until all buffered steps are executed
|
||||||
|
|
@ -104,7 +104,7 @@ void microstep_init();
|
||||||
void microstep_readings();
|
void microstep_readings();
|
||||||
|
|
||||||
#ifdef BABYSTEPPING
|
#ifdef BABYSTEPPING
|
||||||
void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention
|
void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,7 @@ void swi2c_init(void)
|
||||||
PIN_OUT(SWI2C_SCL);
|
PIN_OUT(SWI2C_SCL);
|
||||||
PIN_SET(SWI2C_SDA);
|
PIN_SET(SWI2C_SDA);
|
||||||
PIN_SET(SWI2C_SCL);
|
PIN_SET(SWI2C_SCL);
|
||||||
uint8_t i;
|
uint8_t i; for (i = 0; i < 100; i++)
|
||||||
for (i = 0; i < 100; i++)
|
|
||||||
__delay();
|
__delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,8 +81,7 @@ uint8_t swi2c_read(void)
|
||||||
__delay();
|
__delay();
|
||||||
PIN_INP(SWI2C_SDA);
|
PIN_INP(SWI2C_SDA);
|
||||||
uint8_t data = 0;
|
uint8_t data = 0;
|
||||||
int8_t bit;
|
int8_t bit; for (bit = 7; bit >= 0; bit--)
|
||||||
for (bit = 7; bit >= 0; bit--)
|
|
||||||
{
|
{
|
||||||
PIN_SET(SWI2C_SCL);
|
PIN_SET(SWI2C_SCL);
|
||||||
__delay();
|
__delay();
|
||||||
|
|
@ -97,8 +95,7 @@ uint8_t swi2c_read(void)
|
||||||
|
|
||||||
void swi2c_write(uint8_t data)
|
void swi2c_write(uint8_t data)
|
||||||
{
|
{
|
||||||
int8_t bit;
|
int8_t bit; for (bit = 7; bit >= 0; bit--)
|
||||||
for (bit = 7; bit >= 0; bit--)
|
|
||||||
{
|
{
|
||||||
if (data & (1 << bit)) PIN_SET(SWI2C_SDA);
|
if (data & (1 << bit)) PIN_SET(SWI2C_SDA);
|
||||||
else PIN_CLR(SWI2C_SDA);
|
else PIN_CLR(SWI2C_SDA);
|
||||||
|
|
@ -114,10 +111,7 @@ uint8_t swi2c_check(uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
swi2c_start();
|
swi2c_start();
|
||||||
swi2c_write((dev_addr & SWI2C_DMSK) << SWI2C_ASHF);
|
swi2c_write((dev_addr & SWI2C_DMSK) << SWI2C_ASHF);
|
||||||
if (!swi2c_wait_ack()) {
|
if (!swi2c_wait_ack()) { swi2c_stop(); return 0; }
|
||||||
swi2c_stop();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
swi2c_stop();
|
swi2c_stop();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -128,10 +122,7 @@ uint8_t swi2c_readByte_A8(uint8_t dev_addr, uint8_t addr, uint8_t* pbyte)
|
||||||
{
|
{
|
||||||
swi2c_start();
|
swi2c_start();
|
||||||
swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
|
swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
|
||||||
if (!swi2c_wait_ack()) {
|
if (!swi2c_wait_ack()) { swi2c_stop(); return 0; }
|
||||||
swi2c_stop();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
swi2c_write(addr & 0xff);
|
swi2c_write(addr & 0xff);
|
||||||
if (!swi2c_wait_ack()) return 0;
|
if (!swi2c_wait_ack()) return 0;
|
||||||
swi2c_stop();
|
swi2c_stop();
|
||||||
|
|
@ -148,10 +139,7 @@ uint8_t swi2c_writeByte_A8(uint8_t dev_addr, uint8_t addr, uint8_t* pbyte)
|
||||||
{
|
{
|
||||||
swi2c_start();
|
swi2c_start();
|
||||||
swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
|
swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
|
||||||
if (!swi2c_wait_ack()) {
|
if (!swi2c_wait_ack()) { swi2c_stop(); return 0; }
|
||||||
swi2c_stop();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
swi2c_write(addr & 0xff);
|
swi2c_write(addr & 0xff);
|
||||||
if (!swi2c_wait_ack()) return 0;
|
if (!swi2c_wait_ack()) return 0;
|
||||||
swi2c_write(*pbyte);
|
swi2c_write(*pbyte);
|
||||||
|
|
@ -168,10 +156,7 @@ uint8_t swi2c_readByte_A16(uint8_t dev_addr, unsigned short addr, uint8_t* pbyte
|
||||||
{
|
{
|
||||||
swi2c_start();
|
swi2c_start();
|
||||||
swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
|
swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
|
||||||
if (!swi2c_wait_ack()) {
|
if (!swi2c_wait_ack()) { swi2c_stop(); return 0; }
|
||||||
swi2c_stop();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
swi2c_write(addr >> 8);
|
swi2c_write(addr >> 8);
|
||||||
if (!swi2c_wait_ack()) return 0;
|
if (!swi2c_wait_ack()) return 0;
|
||||||
swi2c_write(addr & 0xff);
|
swi2c_write(addr & 0xff);
|
||||||
|
|
@ -190,10 +175,7 @@ uint8_t swi2c_writeByte_A16(uint8_t dev_addr, unsigned short addr, uint8_t* pbyt
|
||||||
{
|
{
|
||||||
swi2c_start();
|
swi2c_start();
|
||||||
swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
|
swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
|
||||||
if (!swi2c_wait_ack()) {
|
if (!swi2c_wait_ack()) { swi2c_stop(); return 0; }
|
||||||
swi2c_stop();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
swi2c_write(addr >> 8);
|
swi2c_write(addr >> 8);
|
||||||
if (!swi2c_wait_ack()) return 0;
|
if (!swi2c_wait_ack()) return 0;
|
||||||
swi2c_write(addr & 0xff);
|
swi2c_write(addr & 0xff);
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,8 @@ void swspi_tx(unsigned char tx)
|
||||||
{
|
{
|
||||||
int delay = 1 << (swspi_cfg & SWSPI_DEL));
|
int delay = 1 << (swspi_cfg & SWSPI_DEL));
|
||||||
if (swspi_miso == swspi_mosi) GPIO_OUT(swspi_mosi);
|
if (swspi_miso == swspi_mosi) GPIO_OUT(swspi_mosi);
|
||||||
unsigned char i = 0;
|
unsigned char i = 0; for (; i < 8; i++)
|
||||||
for (; i < 8; i++)
|
{
|
||||||
{
|
|
||||||
if (tx & 0x80) GPIO_SET(swspi_mosi);
|
if (tx & 0x80) GPIO_SET(swspi_mosi);
|
||||||
else GPIO_CLR(swspi_mosi);
|
else GPIO_CLR(swspi_mosi);
|
||||||
DELAY(delay);
|
DELAY(delay);
|
||||||
|
|
@ -60,9 +59,8 @@ unsigned char swspi_rx()
|
||||||
int delay = 1 << (swspi_cfg & SWSPI_DEL));
|
int delay = 1 << (swspi_cfg & SWSPI_DEL));
|
||||||
if (swspi_miso == swspi_mosi) GPIO_OUT(swspi_mosi);
|
if (swspi_miso == swspi_mosi) GPIO_OUT(swspi_mosi);
|
||||||
unsigned char rx = 0;
|
unsigned char rx = 0;
|
||||||
unsigned char i = 0;
|
unsigned char i = 0; for (; i < 8; i++)
|
||||||
for (; i < 8; i++)
|
{
|
||||||
{
|
|
||||||
rx <<= 1;
|
rx <<= 1;
|
||||||
DELAY(delay);
|
DELAY(delay);
|
||||||
SWSPI_SCK_UP;
|
SWSPI_SCK_UP;
|
||||||
|
|
@ -77,9 +75,8 @@ unsigned char swspi_txrx(unsigned char tx)
|
||||||
{
|
{
|
||||||
int delay = 1 << (swspi_cfg & SWSPI_DEL));
|
int delay = 1 << (swspi_cfg & SWSPI_DEL));
|
||||||
unsigned char rx = 0;
|
unsigned char rx = 0;
|
||||||
unsigned char i = 0;
|
unsigned char i = 0; for (; i < 8; i++)
|
||||||
for (; i < 8; i++)
|
{
|
||||||
{
|
|
||||||
rx <<= 1;
|
rx <<= 1;
|
||||||
if (tx & 0x80) GPIO_SET(swspi_mosi);
|
if (tx & 0x80) GPIO_SET(swspi_mosi);
|
||||||
else GPIO_CLR(swspi_mosi);
|
else GPIO_CLR(swspi_mosi);
|
||||||
|
|
|
||||||
|
|
@ -71,29 +71,29 @@ int current_voltage_raw_bed = 0;
|
||||||
int current_temperature_bed_raw = 0;
|
int current_temperature_bed_raw = 0;
|
||||||
float current_temperature_bed = 0.0;
|
float current_temperature_bed = 0.0;
|
||||||
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
||||||
int redundant_temperature_raw = 0;
|
int redundant_temperature_raw = 0;
|
||||||
float redundant_temperature = 0.0;
|
float redundant_temperature = 0.0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef PIDTEMP
|
#ifdef PIDTEMP
|
||||||
float _Kp, _Ki, _Kd;
|
float _Kp, _Ki, _Kd;
|
||||||
int pid_cycle, pid_number_of_cycles;
|
int pid_cycle, pid_number_of_cycles;
|
||||||
bool pid_tuning_finished = false;
|
bool pid_tuning_finished = false;
|
||||||
#ifdef PID_ADD_EXTRUSION_RATE
|
#ifdef PID_ADD_EXTRUSION_RATE
|
||||||
float Kc=DEFAULT_Kc;
|
float Kc=DEFAULT_Kc;
|
||||||
#endif
|
#endif
|
||||||
#endif //PIDTEMP
|
#endif //PIDTEMP
|
||||||
|
|
||||||
#ifdef FAN_SOFT_PWM
|
#ifdef FAN_SOFT_PWM
|
||||||
unsigned char fanSpeedSoftPwm;
|
unsigned char fanSpeedSoftPwm;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
unsigned char soft_pwm_bed;
|
unsigned char soft_pwm_bed;
|
||||||
|
|
||||||
#ifdef BABYSTEPPING
|
#ifdef BABYSTEPPING
|
||||||
volatile int babystepsTodo[3]= {0,0,0};
|
volatile int babystepsTodo[3]={0,0,0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
@ -102,59 +102,59 @@ volatile int babystepsTodo[3]= {0,0,0};
|
||||||
static volatile bool temp_meas_ready = false;
|
static volatile bool temp_meas_ready = false;
|
||||||
|
|
||||||
#ifdef PIDTEMP
|
#ifdef PIDTEMP
|
||||||
//static cannot be external:
|
//static cannot be external:
|
||||||
static float temp_iState[EXTRUDERS] = { 0 };
|
static float temp_iState[EXTRUDERS] = { 0 };
|
||||||
static float temp_dState[EXTRUDERS] = { 0 };
|
static float temp_dState[EXTRUDERS] = { 0 };
|
||||||
static float pTerm[EXTRUDERS];
|
static float pTerm[EXTRUDERS];
|
||||||
static float iTerm[EXTRUDERS];
|
static float iTerm[EXTRUDERS];
|
||||||
static float dTerm[EXTRUDERS];
|
static float dTerm[EXTRUDERS];
|
||||||
//int output;
|
//int output;
|
||||||
static float pid_error[EXTRUDERS];
|
static float pid_error[EXTRUDERS];
|
||||||
static float temp_iState_min[EXTRUDERS];
|
static float temp_iState_min[EXTRUDERS];
|
||||||
static float temp_iState_max[EXTRUDERS];
|
static float temp_iState_max[EXTRUDERS];
|
||||||
// static float pid_input[EXTRUDERS];
|
// static float pid_input[EXTRUDERS];
|
||||||
// static float pid_output[EXTRUDERS];
|
// static float pid_output[EXTRUDERS];
|
||||||
static bool pid_reset[EXTRUDERS];
|
static bool pid_reset[EXTRUDERS];
|
||||||
#endif //PIDTEMP
|
#endif //PIDTEMP
|
||||||
#ifdef PIDTEMPBED
|
#ifdef PIDTEMPBED
|
||||||
//static cannot be external:
|
//static cannot be external:
|
||||||
static float temp_iState_bed = { 0 };
|
static float temp_iState_bed = { 0 };
|
||||||
static float temp_dState_bed = { 0 };
|
static float temp_dState_bed = { 0 };
|
||||||
static float pTerm_bed;
|
static float pTerm_bed;
|
||||||
static float iTerm_bed;
|
static float iTerm_bed;
|
||||||
static float dTerm_bed;
|
static float dTerm_bed;
|
||||||
//int output;
|
//int output;
|
||||||
static float pid_error_bed;
|
static float pid_error_bed;
|
||||||
static float temp_iState_min_bed;
|
static float temp_iState_min_bed;
|
||||||
static float temp_iState_max_bed;
|
static float temp_iState_max_bed;
|
||||||
#else //PIDTEMPBED
|
#else //PIDTEMPBED
|
||||||
static unsigned long previous_millis_bed_heater;
|
static unsigned long previous_millis_bed_heater;
|
||||||
#endif //PIDTEMPBED
|
#endif //PIDTEMPBED
|
||||||
static unsigned char soft_pwm[EXTRUDERS];
|
static unsigned char soft_pwm[EXTRUDERS];
|
||||||
|
|
||||||
#ifdef FAN_SOFT_PWM
|
#ifdef FAN_SOFT_PWM
|
||||||
static unsigned char soft_pwm_fan;
|
static unsigned char soft_pwm_fan;
|
||||||
#endif
|
#endif
|
||||||
#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
|
#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
|
||||||
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
|
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
|
||||||
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
|
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
|
||||||
static unsigned long extruder_autofan_last_check;
|
static unsigned long extruder_autofan_last_check;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if EXTRUDERS > 3
|
#if EXTRUDERS > 3
|
||||||
# error Unsupported number of extruders
|
# error Unsupported number of extruders
|
||||||
#elif EXTRUDERS > 2
|
#elif EXTRUDERS > 2
|
||||||
# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2, v3 }
|
# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2, v3 }
|
||||||
#elif EXTRUDERS > 1
|
#elif EXTRUDERS > 1
|
||||||
# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2 }
|
# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2 }
|
||||||
#else
|
#else
|
||||||
# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1 }
|
# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1 }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Init min and max temp with extreme values to prevent false errors during startup
|
// Init min and max temp with extreme values to prevent false errors during startup
|
||||||
static int minttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_LO_TEMP, HEATER_1_RAW_LO_TEMP, HEATER_2_RAW_LO_TEMP );
|
static int minttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP );
|
||||||
static int maxttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_HI_TEMP, HEATER_1_RAW_HI_TEMP, HEATER_2_RAW_HI_TEMP );
|
static int maxttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP );
|
||||||
static int minttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 0, 0, 0 );
|
static int minttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 0, 0, 0 );
|
||||||
static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 16383, 16383, 16383 );
|
static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 16383, 16383, 16383 );
|
||||||
#ifdef BED_MINTEMP
|
#ifdef BED_MINTEMP
|
||||||
|
|
@ -165,11 +165,11 @@ static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
||||||
static void *heater_ttbl_map[2] = {(void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE };
|
static void *heater_ttbl_map[2] = {(void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE };
|
||||||
static uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
|
static uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
|
||||||
#else
|
#else
|
||||||
static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( (void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE, (void *)HEATER_2_TEMPTABLE );
|
static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( (void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE, (void *)HEATER_2_TEMPTABLE );
|
||||||
static uint8_t heater_ttbllen_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN );
|
static uint8_t heater_ttbllen_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static float analog2temp(int raw, uint8_t e);
|
static float analog2temp(int raw, uint8_t e);
|
||||||
|
|
@ -207,8 +207,8 @@ static void temp_runaway_check(int _heater_id, float _target_temperature, float
|
||||||
static void temp_runaway_stop(bool isPreheat, bool isBed);
|
static void temp_runaway_stop(bool isPreheat, bool isBed);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void PID_autotune(float temp, int extruder, int ncycles)
|
void PID_autotune(float temp, int extruder, int ncycles)
|
||||||
{
|
{
|
||||||
pid_number_of_cycles = ncycles;
|
pid_number_of_cycles = ncycles;
|
||||||
pid_tuning_finished = false;
|
pid_tuning_finished = false;
|
||||||
float input = 0.0;
|
float input = 0.0;
|
||||||
|
|
@ -235,10 +235,10 @@ void PID_autotune(float temp, int extruder, int ncycles)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((extruder >= EXTRUDERS)
|
if ((extruder >= EXTRUDERS)
|
||||||
#if (TEMP_BED_PIN <= -1)
|
#if (TEMP_BED_PIN <= -1)
|
||||||
||(extruder < 0)
|
||(extruder < 0)
|
||||||
#endif
|
#endif
|
||||||
) {
|
){
|
||||||
SERIAL_ECHOLN("PID Autotune failed. Bad extruder number.");
|
SERIAL_ECHOLN("PID Autotune failed. Bad extruder number.");
|
||||||
pid_tuning_finished = true;
|
pid_tuning_finished = true;
|
||||||
pid_cycle = 0;
|
pid_cycle = 0;
|
||||||
|
|
@ -275,14 +275,14 @@ void PID_autotune(float temp, int extruder, int ncycles)
|
||||||
max=max(max,input);
|
max=max(max,input);
|
||||||
min=min(min,input);
|
min=min(min,input);
|
||||||
|
|
||||||
#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
|
#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
|
||||||
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
|
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
|
||||||
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
|
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
|
||||||
if(millis() - extruder_autofan_last_check > 2500) {
|
if(millis() - extruder_autofan_last_check > 2500) {
|
||||||
checkExtruderAutoFans();
|
checkExtruderAutoFans();
|
||||||
extruder_autofan_last_check = millis();
|
extruder_autofan_last_check = millis();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(heating == true && input > temp) {
|
if(heating == true && input > temp) {
|
||||||
if(millis() - t2 > 5000) {
|
if(millis() - t2 > 5000) {
|
||||||
|
|
@ -303,35 +303,26 @@ void PID_autotune(float temp, int extruder, int ncycles)
|
||||||
t_low=t2 - t1;
|
t_low=t2 - t1;
|
||||||
if(pid_cycle > 0) {
|
if(pid_cycle > 0) {
|
||||||
bias += (d*(t_high - t_low))/(t_low + t_high);
|
bias += (d*(t_high - t_low))/(t_low + t_high);
|
||||||
bias = constrain(bias, 20,(extruder<0?(MAX_BED_POWER):(PID_MAX))-20);
|
bias = constrain(bias, 20 ,(extruder<0?(MAX_BED_POWER):(PID_MAX))-20);
|
||||||
if(bias > (extruder<0?(MAX_BED_POWER):(PID_MAX))/2) d = (extruder<0?(MAX_BED_POWER):(PID_MAX)) - 1 - bias;
|
if(bias > (extruder<0?(MAX_BED_POWER):(PID_MAX))/2) d = (extruder<0?(MAX_BED_POWER):(PID_MAX)) - 1 - bias;
|
||||||
else d = bias;
|
else d = bias;
|
||||||
|
|
||||||
SERIAL_PROTOCOLPGM(" bias: ");
|
SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);
|
||||||
SERIAL_PROTOCOL(bias);
|
SERIAL_PROTOCOLPGM(" d: "); SERIAL_PROTOCOL(d);
|
||||||
SERIAL_PROTOCOLPGM(" d: ");
|
SERIAL_PROTOCOLPGM(" min: "); SERIAL_PROTOCOL(min);
|
||||||
SERIAL_PROTOCOL(d);
|
SERIAL_PROTOCOLPGM(" max: "); SERIAL_PROTOCOLLN(max);
|
||||||
SERIAL_PROTOCOLPGM(" min: ");
|
|
||||||
SERIAL_PROTOCOL(min);
|
|
||||||
SERIAL_PROTOCOLPGM(" max: ");
|
|
||||||
SERIAL_PROTOCOLLN(max);
|
|
||||||
if(pid_cycle > 2) {
|
if(pid_cycle > 2) {
|
||||||
Ku = (4.0*d)/(3.14159*(max-min)/2.0);
|
Ku = (4.0*d)/(3.14159*(max-min)/2.0);
|
||||||
Tu = ((float)(t_low + t_high)/1000.0);
|
Tu = ((float)(t_low + t_high)/1000.0);
|
||||||
SERIAL_PROTOCOLPGM(" Ku: ");
|
SERIAL_PROTOCOLPGM(" Ku: "); SERIAL_PROTOCOL(Ku);
|
||||||
SERIAL_PROTOCOL(Ku);
|
SERIAL_PROTOCOLPGM(" Tu: "); SERIAL_PROTOCOLLN(Tu);
|
||||||
SERIAL_PROTOCOLPGM(" Tu: ");
|
|
||||||
SERIAL_PROTOCOLLN(Tu);
|
|
||||||
_Kp = 0.6*Ku;
|
_Kp = 0.6*Ku;
|
||||||
_Ki = 2*_Kp/Tu;
|
_Ki = 2*_Kp/Tu;
|
||||||
_Kd = _Kp*Tu/8;
|
_Kd = _Kp*Tu/8;
|
||||||
SERIAL_PROTOCOLLNPGM(" Classic PID ");
|
SERIAL_PROTOCOLLNPGM(" Classic PID ");
|
||||||
SERIAL_PROTOCOLPGM(" Kp: ");
|
SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(_Kp);
|
||||||
SERIAL_PROTOCOLLN(_Kp);
|
SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(_Ki);
|
||||||
SERIAL_PROTOCOLPGM(" Ki: ");
|
SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(_Kd);
|
||||||
SERIAL_PROTOCOLLN(_Ki);
|
|
||||||
SERIAL_PROTOCOLPGM(" Kd: ");
|
|
||||||
SERIAL_PROTOCOLLN(_Kd);
|
|
||||||
/*
|
/*
|
||||||
_Kp = 0.33*Ku;
|
_Kp = 0.33*Ku;
|
||||||
_Ki = _Kp/Tu;
|
_Ki = _Kp/Tu;
|
||||||
|
|
@ -367,10 +358,10 @@ void PID_autotune(float temp, int extruder, int ncycles)
|
||||||
}
|
}
|
||||||
if(millis() - temp_millis > 2000) {
|
if(millis() - temp_millis > 2000) {
|
||||||
int p;
|
int p;
|
||||||
if (extruder<0) {
|
if (extruder<0){
|
||||||
p=soft_pwm_bed;
|
p=soft_pwm_bed;
|
||||||
SERIAL_PROTOCOLPGM("B:");
|
SERIAL_PROTOCOLPGM("B:");
|
||||||
} else {
|
}else{
|
||||||
p=soft_pwm[extruder];
|
p=soft_pwm[extruder];
|
||||||
SERIAL_PROTOCOLPGM("T:");
|
SERIAL_PROTOCOLPGM("T:");
|
||||||
}
|
}
|
||||||
|
|
@ -387,7 +378,7 @@ void PID_autotune(float temp, int extruder, int ncycles)
|
||||||
else if (safety_check_cycles < safety_check_cycles_count) { //delay
|
else if (safety_check_cycles < safety_check_cycles_count) { //delay
|
||||||
safety_check_cycles++;
|
safety_check_cycles++;
|
||||||
}
|
}
|
||||||
else if (safety_check_cycles == safety_check_cycles_count) { //check that temperature is rising
|
else if (safety_check_cycles == safety_check_cycles_count){ //check that temperature is rising
|
||||||
safety_check_cycles++;
|
safety_check_cycles++;
|
||||||
//SERIAL_ECHOPGM("Time from beginning: ");
|
//SERIAL_ECHOPGM("Time from beginning: ");
|
||||||
//MYSERIAL.print(safety_check_cycles_count * 2);
|
//MYSERIAL.print(safety_check_cycles_count * 2);
|
||||||
|
|
@ -440,17 +431,17 @@ int getHeaterPower(int heater) {
|
||||||
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
|
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
|
||||||
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
|
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
|
||||||
|
|
||||||
#if defined(FAN_PIN) && FAN_PIN > -1
|
#if defined(FAN_PIN) && FAN_PIN > -1
|
||||||
#if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN
|
#if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN
|
||||||
#error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN"
|
#error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN"
|
||||||
#endif
|
#endif
|
||||||
#if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN
|
#if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN
|
||||||
#error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN"
|
#error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN"
|
||||||
#endif
|
#endif
|
||||||
#if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN
|
#if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN
|
||||||
#error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN"
|
#error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setExtruderAutoFanState(int pin, bool state)
|
void setExtruderAutoFanState(int pin, bool state)
|
||||||
{
|
{
|
||||||
|
|
@ -520,7 +511,7 @@ void fanSpeedError(unsigned char _fan) {
|
||||||
case 0:
|
case 0:
|
||||||
SERIAL_ECHOLNPGM("Extruder fan speed is lower then expected");
|
SERIAL_ECHOLNPGM("Extruder fan speed is lower then expected");
|
||||||
if (get_message_level() == 0) {
|
if (get_message_level() == 0) {
|
||||||
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT))
|
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT))
|
||||||
WRITE(BEEPER, HIGH);
|
WRITE(BEEPER, HIGH);
|
||||||
delayMicroseconds(200);
|
delayMicroseconds(200);
|
||||||
WRITE(BEEPER, LOW);
|
WRITE(BEEPER, LOW);
|
||||||
|
|
@ -531,7 +522,7 @@ void fanSpeedError(unsigned char _fan) {
|
||||||
case 1:
|
case 1:
|
||||||
SERIAL_ECHOLNPGM("Print fan speed is lower then expected");
|
SERIAL_ECHOLNPGM("Print fan speed is lower then expected");
|
||||||
if (get_message_level() == 0) {
|
if (get_message_level() == 0) {
|
||||||
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT))
|
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT))
|
||||||
WRITE(BEEPER, HIGH);
|
WRITE(BEEPER, HIGH);
|
||||||
delayMicroseconds(200);
|
delayMicroseconds(200);
|
||||||
WRITE(BEEPER, LOW);
|
WRITE(BEEPER, LOW);
|
||||||
|
|
@ -549,11 +540,11 @@ void checkExtruderAutoFans()
|
||||||
uint8_t fanState = 0;
|
uint8_t fanState = 0;
|
||||||
|
|
||||||
// which fan pins need to be turned on?
|
// which fan pins need to be turned on?
|
||||||
#if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1
|
#if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1
|
||||||
if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)
|
if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)
|
||||||
fanState |= 1;
|
fanState |= 1;
|
||||||
#endif
|
#endif
|
||||||
#if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1
|
#if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1
|
||||||
if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE)
|
if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE)
|
||||||
{
|
{
|
||||||
if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
|
if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
|
||||||
|
|
@ -561,8 +552,8 @@ void checkExtruderAutoFans()
|
||||||
else
|
else
|
||||||
fanState |= 2;
|
fanState |= 2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1
|
#if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1
|
||||||
if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE)
|
if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE)
|
||||||
{
|
{
|
||||||
if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
|
if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
|
||||||
|
|
@ -572,21 +563,21 @@ void checkExtruderAutoFans()
|
||||||
else
|
else
|
||||||
fanState |= 4;
|
fanState |= 4;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// update extruder auto fan states
|
// update extruder auto fan states
|
||||||
#if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1
|
#if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1
|
||||||
setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0);
|
setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1
|
#if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1
|
||||||
if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN)
|
if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN)
|
||||||
setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0);
|
setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1
|
#if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1
|
||||||
if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN
|
if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN
|
||||||
&& EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN)
|
&& EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN)
|
||||||
setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0);
|
setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // any extruder auto fan pins set
|
#endif // any extruder auto fan pins set
|
||||||
|
|
@ -616,10 +607,10 @@ void manage_heater()
|
||||||
temp_runaway_check(e+1, target_temperature[e], current_temperature[e], (int)soft_pwm[e], false);
|
temp_runaway_check(e+1, target_temperature[e], current_temperature[e], (int)soft_pwm[e], false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PIDTEMP
|
#ifdef PIDTEMP
|
||||||
pid_input = current_temperature[e];
|
pid_input = current_temperature[e];
|
||||||
|
|
||||||
#ifndef PID_OPENLOOP
|
#ifndef PID_OPENLOOP
|
||||||
pid_error[e] = target_temperature[e] - pid_input;
|
pid_error[e] = target_temperature[e] - pid_input;
|
||||||
if(pid_error[e] > PID_FUNCTIONAL_RANGE) {
|
if(pid_error[e] > PID_FUNCTIONAL_RANGE) {
|
||||||
pid_output = BANG_MAX;
|
pid_output = BANG_MAX;
|
||||||
|
|
@ -640,22 +631,22 @@ void manage_heater()
|
||||||
iTerm[e] = cs.Ki * temp_iState[e];
|
iTerm[e] = cs.Ki * temp_iState[e];
|
||||||
|
|
||||||
//K1 defined in Configuration.h in the PID settings
|
//K1 defined in Configuration.h in the PID settings
|
||||||
#define K2 (1.0-K1)
|
#define K2 (1.0-K1)
|
||||||
dTerm[e] = (cs.Kd * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]);
|
dTerm[e] = (cs.Kd * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]);
|
||||||
pid_output = pTerm[e] + iTerm[e] - dTerm[e];
|
pid_output = pTerm[e] + iTerm[e] - dTerm[e];
|
||||||
if (pid_output > PID_MAX) {
|
if (pid_output > PID_MAX) {
|
||||||
if (pid_error[e] > 0 ) temp_iState[e] -= pid_error[e]; // conditional un-integration
|
if (pid_error[e] > 0 ) temp_iState[e] -= pid_error[e]; // conditional un-integration
|
||||||
pid_output=PID_MAX;
|
pid_output=PID_MAX;
|
||||||
} else if (pid_output < 0) {
|
} else if (pid_output < 0){
|
||||||
if (pid_error[e] < 0 ) temp_iState[e] -= pid_error[e]; // conditional un-integration
|
if (pid_error[e] < 0 ) temp_iState[e] -= pid_error[e]; // conditional un-integration
|
||||||
pid_output=0;
|
pid_output=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
temp_dState[e] = pid_input;
|
temp_dState[e] = pid_input;
|
||||||
#else
|
#else
|
||||||
pid_output = constrain(target_temperature[e], 0, PID_MAX);
|
pid_output = constrain(target_temperature[e], 0, PID_MAX);
|
||||||
#endif //PID_OPENLOOP
|
#endif //PID_OPENLOOP
|
||||||
#ifdef PID_DEBUG
|
#ifdef PID_DEBUG
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
SERIAL_ECHO(" PID_DEBUG ");
|
SERIAL_ECHO(" PID_DEBUG ");
|
||||||
SERIAL_ECHO(e);
|
SERIAL_ECHO(e);
|
||||||
|
|
@ -669,13 +660,13 @@ void manage_heater()
|
||||||
SERIAL_ECHO(iTerm[e]);
|
SERIAL_ECHO(iTerm[e]);
|
||||||
SERIAL_ECHO(" dTerm ");
|
SERIAL_ECHO(" dTerm ");
|
||||||
SERIAL_ECHOLN(dTerm[e]);
|
SERIAL_ECHOLN(dTerm[e]);
|
||||||
#endif //PID_DEBUG
|
#endif //PID_DEBUG
|
||||||
#else /* PID off */
|
#else /* PID off */
|
||||||
pid_output = 0;
|
pid_output = 0;
|
||||||
if(current_temperature[e] < target_temperature[e]) {
|
if(current_temperature[e] < target_temperature[e]) {
|
||||||
pid_output = PID_MAX;
|
pid_output = PID_MAX;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check if temperature is within the correct range
|
// Check if temperature is within the correct range
|
||||||
#ifdef AMBIENT_THERMISTOR
|
#ifdef AMBIENT_THERMISTOR
|
||||||
|
|
@ -691,7 +682,7 @@ void manage_heater()
|
||||||
soft_pwm[e] = 0;
|
soft_pwm[e] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WATCH_TEMP_PERIOD
|
#ifdef WATCH_TEMP_PERIOD
|
||||||
if(watchmillis[e] && millis() - watchmillis[e] > WATCH_TEMP_PERIOD)
|
if(watchmillis[e] && millis() - watchmillis[e] > WATCH_TEMP_PERIOD)
|
||||||
{
|
{
|
||||||
if(degHotend(e) < watch_start_temp[e] + WATCH_TEMP_INCREASE)
|
if(degHotend(e) < watch_start_temp[e] + WATCH_TEMP_INCREASE)
|
||||||
|
|
@ -700,12 +691,12 @@ void manage_heater()
|
||||||
LCD_MESSAGEPGM("Heating failed");
|
LCD_MESSAGEPGM("Heating failed");
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
SERIAL_ECHOLN("Heating failed");
|
SERIAL_ECHOLN("Heating failed");
|
||||||
} else {
|
}else{
|
||||||
watchmillis[e] = 0;
|
watchmillis[e] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
||||||
if(fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
|
if(fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
|
||||||
disable_heater();
|
disable_heater();
|
||||||
if(IsStopped() == false) {
|
if(IsStopped() == false) {
|
||||||
|
|
@ -713,15 +704,15 @@ void manage_heater()
|
||||||
SERIAL_ERRORLNPGM("Extruder switched off. Temperature difference between temp sensors is too high !");
|
SERIAL_ERRORLNPGM("Extruder switched off. Temperature difference between temp sensors is too high !");
|
||||||
LCD_ALERTMESSAGEPGM("Err: REDUNDANT TEMP ERROR");
|
LCD_ALERTMESSAGEPGM("Err: REDUNDANT TEMP ERROR");
|
||||||
}
|
}
|
||||||
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
||||||
Stop();
|
Stop();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} // End extruder for loop
|
} // End extruder for loop
|
||||||
|
|
||||||
#ifndef DEBUG_DISABLE_FANCHECK
|
#ifndef DEBUG_DISABLE_FANCHECK
|
||||||
#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
|
#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
|
||||||
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
|
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
|
||||||
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
|
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
|
||||||
if(millis() - extruder_autofan_last_check > 1000) // only need to check fan state very infrequently
|
if(millis() - extruder_autofan_last_check > 1000) // only need to check fan state very infrequently
|
||||||
|
|
@ -733,21 +724,21 @@ void manage_heater()
|
||||||
checkExtruderAutoFans();
|
checkExtruderAutoFans();
|
||||||
extruder_autofan_last_check = millis();
|
extruder_autofan_last_check = millis();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif //DEBUG_DISABLE_FANCHECK
|
#endif //DEBUG_DISABLE_FANCHECK
|
||||||
|
|
||||||
#ifndef PIDTEMPBED
|
#ifndef PIDTEMPBED
|
||||||
if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
|
if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
|
||||||
return;
|
return;
|
||||||
previous_millis_bed_heater = millis();
|
previous_millis_bed_heater = millis();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TEMP_SENSOR_BED != 0
|
#if TEMP_SENSOR_BED != 0
|
||||||
|
|
||||||
#ifdef PIDTEMPBED
|
#ifdef PIDTEMPBED
|
||||||
pid_input = current_temperature_bed;
|
pid_input = current_temperature_bed;
|
||||||
|
|
||||||
#ifndef PID_OPENLOOP
|
#ifndef PID_OPENLOOP
|
||||||
pid_error_bed = target_temperature_bed - pid_input;
|
pid_error_bed = target_temperature_bed - pid_input;
|
||||||
pTerm_bed = cs.bedKp * pid_error_bed;
|
pTerm_bed = cs.bedKp * pid_error_bed;
|
||||||
temp_iState_bed += pid_error_bed;
|
temp_iState_bed += pid_error_bed;
|
||||||
|
|
@ -755,7 +746,7 @@ void manage_heater()
|
||||||
iTerm_bed = cs.bedKi * temp_iState_bed;
|
iTerm_bed = cs.bedKi * temp_iState_bed;
|
||||||
|
|
||||||
//K1 defined in Configuration.h in the PID settings
|
//K1 defined in Configuration.h in the PID settings
|
||||||
#define K2 (1.0-K1)
|
#define K2 (1.0-K1)
|
||||||
dTerm_bed= (cs.bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed);
|
dTerm_bed= (cs.bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed);
|
||||||
temp_dState_bed = pid_input;
|
temp_dState_bed = pid_input;
|
||||||
|
|
||||||
|
|
@ -763,14 +754,14 @@ void manage_heater()
|
||||||
if (pid_output > MAX_BED_POWER) {
|
if (pid_output > MAX_BED_POWER) {
|
||||||
if (pid_error_bed > 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration
|
if (pid_error_bed > 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration
|
||||||
pid_output=MAX_BED_POWER;
|
pid_output=MAX_BED_POWER;
|
||||||
} else if (pid_output < 0) {
|
} else if (pid_output < 0){
|
||||||
if (pid_error_bed < 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration
|
if (pid_error_bed < 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration
|
||||||
pid_output=0;
|
pid_output=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);
|
pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);
|
||||||
#endif //PID_OPENLOOP
|
#endif //PID_OPENLOOP
|
||||||
|
|
||||||
#ifdef AMBIENT_THERMISTOR
|
#ifdef AMBIENT_THERMISTOR
|
||||||
if(((current_temperature_bed > BED_MINTEMP) || (current_temperature_ambient < MINTEMP_MINAMBIENT)) && (current_temperature_bed < BED_MAXTEMP))
|
if(((current_temperature_bed > BED_MINTEMP) || (current_temperature_ambient < MINTEMP_MINAMBIENT)) && (current_temperature_bed < BED_MAXTEMP))
|
||||||
|
|
@ -784,7 +775,7 @@ void manage_heater()
|
||||||
soft_pwm_bed = 0;
|
soft_pwm_bed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif !defined(BED_LIMIT_SWITCHING)
|
#elif !defined(BED_LIMIT_SWITCHING)
|
||||||
// Check if temperature is within the correct range
|
// Check if temperature is within the correct range
|
||||||
if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP))
|
if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP))
|
||||||
{
|
{
|
||||||
|
|
@ -802,7 +793,7 @@ void manage_heater()
|
||||||
soft_pwm_bed = 0;
|
soft_pwm_bed = 0;
|
||||||
WRITE(HEATER_BED_PIN,LOW);
|
WRITE(HEATER_BED_PIN,LOW);
|
||||||
}
|
}
|
||||||
#else //#ifdef BED_LIMIT_SWITCHING
|
#else //#ifdef BED_LIMIT_SWITCHING
|
||||||
// Check if temperature is within the correct band
|
// Check if temperature is within the correct band
|
||||||
if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP))
|
if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP))
|
||||||
{
|
{
|
||||||
|
|
@ -820,8 +811,8 @@ void manage_heater()
|
||||||
soft_pwm_bed = 0;
|
soft_pwm_bed = 0;
|
||||||
WRITE(HEATER_BED_PIN,LOW);
|
WRITE(HEATER_BED_PIN,LOW);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HOST_KEEPALIVE_FEATURE
|
#ifdef HOST_KEEPALIVE_FEATURE
|
||||||
host_keepalive();
|
host_keepalive();
|
||||||
|
|
@ -844,12 +835,12 @@ static float analog2temp(int raw, uint8_t e) {
|
||||||
kill(PSTR(""), 6);
|
kill(PSTR(""), 6);
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
#ifdef HEATER_0_USES_MAX6675
|
#ifdef HEATER_0_USES_MAX6675
|
||||||
if (e == 0)
|
if (e == 0)
|
||||||
{
|
{
|
||||||
return 0.25 * raw;
|
return 0.25 * raw;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(heater_ttbl_map[e] != NULL)
|
if(heater_ttbl_map[e] != NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -880,7 +871,7 @@ static float analog2temp(int raw, uint8_t e) {
|
||||||
// Derived from RepRap FiveD extruder::getTemperature()
|
// Derived from RepRap FiveD extruder::getTemperature()
|
||||||
// For bed temperature measurement.
|
// For bed temperature measurement.
|
||||||
static float analog2tempBed(int raw) {
|
static float analog2tempBed(int raw) {
|
||||||
#ifdef BED_USES_THERMISTOR
|
#ifdef BED_USES_THERMISTOR
|
||||||
float celsius = 0;
|
float celsius = 0;
|
||||||
byte i;
|
byte i;
|
||||||
|
|
||||||
|
|
@ -925,11 +916,11 @@ static float analog2tempBed(int raw) {
|
||||||
|
|
||||||
|
|
||||||
return celsius;
|
return celsius;
|
||||||
#elif defined BED_USES_AD595
|
#elif defined BED_USES_AD595
|
||||||
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
|
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef AMBIENT_THERMISTOR
|
#ifdef AMBIENT_THERMISTOR
|
||||||
|
|
@ -959,7 +950,7 @@ static float analog2tempAmbient(int raw)
|
||||||
and this function is called from normal context as it is too slow to run in interrupts and will block the stepper routine otherwise */
|
and this function is called from normal context as it is too slow to run in interrupts and will block the stepper routine otherwise */
|
||||||
static void updateTemperaturesFromRawValues()
|
static void updateTemperaturesFromRawValues()
|
||||||
{
|
{
|
||||||
for(uint8_t e=0; e<EXTRUDERS; e++)
|
for(uint8_t e=0;e<EXTRUDERS;e++)
|
||||||
{
|
{
|
||||||
current_temperature[e] = analog2temp(current_temperature_raw[e], e);
|
current_temperature[e] = analog2temp(current_temperature_raw[e], e);
|
||||||
}
|
}
|
||||||
|
|
@ -978,9 +969,9 @@ static void updateTemperaturesFromRawValues()
|
||||||
current_temperature_bed = analog2tempBed(current_temperature_bed_raw);
|
current_temperature_bed = analog2tempBed(current_temperature_bed_raw);
|
||||||
#endif //DEBUG_HEATER_BED_SIM
|
#endif //DEBUG_HEATER_BED_SIM
|
||||||
|
|
||||||
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
||||||
redundant_temperature = analog2temp(redundant_temperature_raw, 1);
|
redundant_temperature = analog2temp(redundant_temperature_raw, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Reset the watchdog after we know we have a temperature measurement.
|
//Reset the watchdog after we know we have a temperature measurement.
|
||||||
#ifdef WATCHDOG
|
#ifdef WATCHDOG
|
||||||
|
|
@ -1015,30 +1006,30 @@ void tp_init()
|
||||||
#endif //PIDTEMPBED
|
#endif //PIDTEMPBED
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HEATER_0_PIN) && (HEATER_0_PIN > -1)
|
#if defined(HEATER_0_PIN) && (HEATER_0_PIN > -1)
|
||||||
SET_OUTPUT(HEATER_0_PIN);
|
SET_OUTPUT(HEATER_0_PIN);
|
||||||
#endif
|
#endif
|
||||||
#if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1)
|
#if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1)
|
||||||
SET_OUTPUT(HEATER_1_PIN);
|
SET_OUTPUT(HEATER_1_PIN);
|
||||||
#endif
|
#endif
|
||||||
#if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1)
|
#if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1)
|
||||||
SET_OUTPUT(HEATER_2_PIN);
|
SET_OUTPUT(HEATER_2_PIN);
|
||||||
#endif
|
#endif
|
||||||
#if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1)
|
#if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1)
|
||||||
SET_OUTPUT(HEATER_BED_PIN);
|
SET_OUTPUT(HEATER_BED_PIN);
|
||||||
#endif
|
#endif
|
||||||
#if defined(FAN_PIN) && (FAN_PIN > -1)
|
#if defined(FAN_PIN) && (FAN_PIN > -1)
|
||||||
SET_OUTPUT(FAN_PIN);
|
SET_OUTPUT(FAN_PIN);
|
||||||
#ifdef FAST_PWM_FAN
|
#ifdef FAST_PWM_FAN
|
||||||
setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
||||||
#endif
|
#endif
|
||||||
#ifdef FAN_SOFT_PWM
|
#ifdef FAN_SOFT_PWM
|
||||||
soft_pwm_fan = fanSpeedSoftPwm / 2;
|
soft_pwm_fan = fanSpeedSoftPwm / 2;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HEATER_0_USES_MAX6675
|
#ifdef HEATER_0_USES_MAX6675
|
||||||
#ifndef SDSUPPORT
|
#ifndef SDSUPPORT
|
||||||
SET_OUTPUT(SCK_PIN);
|
SET_OUTPUT(SCK_PIN);
|
||||||
WRITE(SCK_PIN,0);
|
WRITE(SCK_PIN,0);
|
||||||
|
|
||||||
|
|
@ -1047,7 +1038,7 @@ void tp_init()
|
||||||
|
|
||||||
SET_INPUT(MISO_PIN);
|
SET_INPUT(MISO_PIN);
|
||||||
WRITE(MISO_PIN,1);
|
WRITE(MISO_PIN,1);
|
||||||
#endif
|
#endif
|
||||||
/* Using pinMode and digitalWrite, as that was the only way I could get it to compile */
|
/* Using pinMode and digitalWrite, as that was the only way I could get it to compile */
|
||||||
|
|
||||||
//Have to toggle SD card CS pin to low first, to enable firmware to talk with SD card
|
//Have to toggle SD card CS pin to low first, to enable firmware to talk with SD card
|
||||||
|
|
@ -1055,7 +1046,7 @@ void tp_init()
|
||||||
digitalWrite(SS_PIN,0);
|
digitalWrite(SS_PIN,0);
|
||||||
pinMode(MAX6675_SS, OUTPUT);
|
pinMode(MAX6675_SS, OUTPUT);
|
||||||
digitalWrite(MAX6675_SS,1);
|
digitalWrite(MAX6675_SS,1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
adc_init();
|
adc_init();
|
||||||
|
|
||||||
|
|
@ -1242,13 +1233,9 @@ void temp_runaway_check(int _heater_id, float _target_temperature, float _curren
|
||||||
|
|
||||||
if (__preheat_errors[_heater_id] > ((_isbed) ? 2 : 5))
|
if (__preheat_errors[_heater_id] > ((_isbed) ? 2 : 5))
|
||||||
{
|
{
|
||||||
if (farm_mode) {
|
if (farm_mode) { prusa_statistics(0); }
|
||||||
prusa_statistics(0);
|
|
||||||
}
|
|
||||||
temp_runaway_stop(true, _isbed);
|
temp_runaway_stop(true, _isbed);
|
||||||
if (farm_mode) {
|
if (farm_mode) { prusa_statistics(91); }
|
||||||
prusa_statistics(91);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
__preheat_start[_heater_id] = _current_temperature;
|
__preheat_start[_heater_id] = _current_temperature;
|
||||||
__preheat_counter[_heater_id] = 0;
|
__preheat_counter[_heater_id] = 0;
|
||||||
|
|
@ -1282,13 +1269,9 @@ void temp_runaway_check(int _heater_id, float _target_temperature, float _curren
|
||||||
temp_runaway_error_counter[_heater_id]++;
|
temp_runaway_error_counter[_heater_id]++;
|
||||||
if (temp_runaway_error_counter[_heater_id] * 2 > __timeout)
|
if (temp_runaway_error_counter[_heater_id] * 2 > __timeout)
|
||||||
{
|
{
|
||||||
if (farm_mode) {
|
if (farm_mode) { prusa_statistics(0); }
|
||||||
prusa_statistics(0);
|
|
||||||
}
|
|
||||||
temp_runaway_stop(false, _isbed);
|
temp_runaway_stop(false, _isbed);
|
||||||
if (farm_mode) {
|
if (farm_mode) { prusa_statistics(90); }
|
||||||
prusa_statistics(90);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1318,7 +1301,7 @@ void temp_runaway_stop(bool isPreheat, bool isBed)
|
||||||
disable_e2();
|
disable_e2();
|
||||||
manage_heater();
|
manage_heater();
|
||||||
lcd_update(0);
|
lcd_update(0);
|
||||||
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT))
|
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT))
|
||||||
WRITE(BEEPER, HIGH);
|
WRITE(BEEPER, HIGH);
|
||||||
delayMicroseconds(500);
|
delayMicroseconds(500);
|
||||||
WRITE(BEEPER, LOW);
|
WRITE(BEEPER, LOW);
|
||||||
|
|
@ -1351,37 +1334,37 @@ void disable_heater()
|
||||||
{
|
{
|
||||||
setAllTargetHotends(0);
|
setAllTargetHotends(0);
|
||||||
setTargetBed(0);
|
setTargetBed(0);
|
||||||
#if defined(TEMP_0_PIN) && TEMP_0_PIN > -1
|
#if defined(TEMP_0_PIN) && TEMP_0_PIN > -1
|
||||||
target_temperature[0]=0;
|
target_temperature[0]=0;
|
||||||
soft_pwm[0]=0;
|
soft_pwm[0]=0;
|
||||||
#if defined(HEATER_0_PIN) && HEATER_0_PIN > -1
|
#if defined(HEATER_0_PIN) && HEATER_0_PIN > -1
|
||||||
WRITE(HEATER_0_PIN,LOW);
|
WRITE(HEATER_0_PIN,LOW);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TEMP_1_PIN) && TEMP_1_PIN > -1 && EXTRUDERS > 1
|
#if defined(TEMP_1_PIN) && TEMP_1_PIN > -1 && EXTRUDERS > 1
|
||||||
target_temperature[1]=0;
|
target_temperature[1]=0;
|
||||||
soft_pwm[1]=0;
|
soft_pwm[1]=0;
|
||||||
#if defined(HEATER_1_PIN) && HEATER_1_PIN > -1
|
#if defined(HEATER_1_PIN) && HEATER_1_PIN > -1
|
||||||
WRITE(HEATER_1_PIN,LOW);
|
WRITE(HEATER_1_PIN,LOW);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 && EXTRUDERS > 2
|
#if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 && EXTRUDERS > 2
|
||||||
target_temperature[2]=0;
|
target_temperature[2]=0;
|
||||||
soft_pwm[2]=0;
|
soft_pwm[2]=0;
|
||||||
#if defined(HEATER_2_PIN) && HEATER_2_PIN > -1
|
#if defined(HEATER_2_PIN) && HEATER_2_PIN > -1
|
||||||
WRITE(HEATER_2_PIN,LOW);
|
WRITE(HEATER_2_PIN,LOW);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
|
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
|
||||||
target_temperature_bed=0;
|
target_temperature_bed=0;
|
||||||
soft_pwm_bed=0;
|
soft_pwm_bed=0;
|
||||||
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
|
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
|
||||||
WRITE(HEATER_BED_PIN,LOW);
|
WRITE(HEATER_BED_PIN,LOW);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void max_temp_error(uint8_t e) {
|
void max_temp_error(uint8_t e) {
|
||||||
|
|
@ -1392,24 +1375,22 @@ void max_temp_error(uint8_t e) {
|
||||||
SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
|
SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
|
||||||
LCD_ALERTMESSAGEPGM("Err: MAXTEMP");
|
LCD_ALERTMESSAGEPGM("Err: MAXTEMP");
|
||||||
}
|
}
|
||||||
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
SET_OUTPUT(EXTRUDER_0_AUTO_FAN_PIN);
|
SET_OUTPUT(EXTRUDER_0_AUTO_FAN_PIN);
|
||||||
SET_OUTPUT(FAN_PIN);
|
SET_OUTPUT(FAN_PIN);
|
||||||
SET_OUTPUT(BEEPER);
|
SET_OUTPUT(BEEPER);
|
||||||
WRITE(FAN_PIN, 1);
|
WRITE(FAN_PIN, 1);
|
||||||
WRITE(EXTRUDER_0_AUTO_FAN_PIN, 1);
|
WRITE(EXTRUDER_0_AUTO_FAN_PIN, 1);
|
||||||
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT))
|
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT))
|
||||||
WRITE(BEEPER, 1);
|
WRITE(BEEPER, 1);
|
||||||
// fanSpeed will consumed by the check_axes_activity() routine.
|
// fanSpeed will consumed by the check_axes_activity() routine.
|
||||||
fanSpeed=255;
|
fanSpeed=255;
|
||||||
if (farm_mode) {
|
if (farm_mode) { prusa_statistics(93); }
|
||||||
prusa_statistics(93);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void min_temp_error(uint8_t e) {
|
void min_temp_error(uint8_t e) {
|
||||||
|
|
@ -1424,12 +1405,10 @@ void min_temp_error(uint8_t e) {
|
||||||
SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
|
SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
|
||||||
LCD_ALERTMESSAGEPGM("Err: MINTEMP");
|
LCD_ALERTMESSAGEPGM("Err: MINTEMP");
|
||||||
}
|
}
|
||||||
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
||||||
Stop();
|
Stop();
|
||||||
#endif
|
#endif
|
||||||
if (farm_mode) {
|
if (farm_mode) { prusa_statistics(92); }
|
||||||
prusa_statistics(92);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1442,9 +1421,9 @@ void bed_max_temp_error(void) {
|
||||||
SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !");
|
SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !");
|
||||||
LCD_ALERTMESSAGEPGM("Err: MAXTEMP BED");
|
LCD_ALERTMESSAGEPGM("Err: MAXTEMP BED");
|
||||||
}
|
}
|
||||||
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
||||||
Stop();
|
Stop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1479,11 +1458,11 @@ int read_max6675()
|
||||||
max6675_previous_millis = millis();
|
max6675_previous_millis = millis();
|
||||||
max6675_temp = 0;
|
max6675_temp = 0;
|
||||||
|
|
||||||
#ifdef PRR
|
#ifdef PRR
|
||||||
PRR &= ~(1<<PRSPI);
|
PRR &= ~(1<<PRSPI);
|
||||||
#elif defined PRR0
|
#elif defined PRR0
|
||||||
PRR0 &= ~(1<<PRSPI);
|
PRR0 &= ~(1<<PRSPI);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SPCR = (1<<MSTR) | (1<<SPE) | (1<<SPR0);
|
SPCR = (1<<MSTR) | (1<<SPE) | (1<<SPR0);
|
||||||
|
|
||||||
|
|
@ -1496,13 +1475,13 @@ int read_max6675()
|
||||||
|
|
||||||
// read MSB
|
// read MSB
|
||||||
SPDR = 0;
|
SPDR = 0;
|
||||||
for (; (SPSR & (1<<SPIF)) == 0;);
|
for (;(SPSR & (1<<SPIF)) == 0;);
|
||||||
max6675_temp = SPDR;
|
max6675_temp = SPDR;
|
||||||
max6675_temp <<= 8;
|
max6675_temp <<= 8;
|
||||||
|
|
||||||
// read LSB
|
// read LSB
|
||||||
SPDR = 0;
|
SPDR = 0;
|
||||||
for (; (SPSR & (1<<SPIF)) == 0;);
|
for (;(SPSR & (1<<SPIF)) == 0;);
|
||||||
max6675_temp |= SPDR;
|
max6675_temp |= SPDR;
|
||||||
|
|
||||||
// disable TT_MAX6675
|
// disable TT_MAX6675
|
||||||
|
|
@ -1526,8 +1505,8 @@ int read_max6675()
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
void adc_ready(void) //callback from adc when sampling finished
|
void adc_ready(void) //callback from adc when sampling finished
|
||||||
{
|
{
|
||||||
current_temperature_raw[0] = adc_values[ADC_PIN_IDX(TEMP_0_PIN)]; //heater
|
current_temperature_raw[0] = adc_values[ADC_PIN_IDX(TEMP_0_PIN)]; //heater
|
||||||
current_temperature_raw_pinda = adc_values[ADC_PIN_IDX(TEMP_PINDA_PIN)];
|
current_temperature_raw_pinda = adc_values[ADC_PIN_IDX(TEMP_PINDA_PIN)];
|
||||||
current_temperature_bed_raw = adc_values[ADC_PIN_IDX(TEMP_BED_PIN)];
|
current_temperature_bed_raw = adc_values[ADC_PIN_IDX(TEMP_BED_PIN)];
|
||||||
|
|
@ -1541,7 +1520,7 @@ extern "C" {
|
||||||
current_voltage_raw_bed = adc_values[ADC_PIN_IDX(VOLT_BED_PIN)]; // 6->9
|
current_voltage_raw_bed = adc_values[ADC_PIN_IDX(VOLT_BED_PIN)]; // 6->9
|
||||||
#endif
|
#endif
|
||||||
temp_meas_ready = true;
|
temp_meas_ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
|
|
@ -1611,23 +1590,19 @@ ISR(TIMER0_COMPB_vect)
|
||||||
} else WRITE(HEATER_0_PIN,0);
|
} else WRITE(HEATER_0_PIN,0);
|
||||||
#if EXTRUDERS > 1
|
#if EXTRUDERS > 1
|
||||||
soft_pwm_1 = soft_pwm[1];
|
soft_pwm_1 = soft_pwm[1];
|
||||||
if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1);
|
if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0);
|
||||||
else WRITE(HEATER_1_PIN,0);
|
|
||||||
#endif
|
#endif
|
||||||
#if EXTRUDERS > 2
|
#if EXTRUDERS > 2
|
||||||
soft_pwm_2 = soft_pwm[2];
|
soft_pwm_2 = soft_pwm[2];
|
||||||
if(soft_pwm_2 > 0) WRITE(HEATER_2_PIN,1);
|
if(soft_pwm_2 > 0) WRITE(HEATER_2_PIN,1); else WRITE(HEATER_2_PIN,0);
|
||||||
else WRITE(HEATER_2_PIN,0);
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
|
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
|
||||||
soft_pwm_b = soft_pwm_bed;
|
soft_pwm_b = soft_pwm_bed;
|
||||||
if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1);
|
if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0);
|
||||||
else WRITE(HEATER_BED_PIN,0);
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef FAN_SOFT_PWM
|
#ifdef FAN_SOFT_PWM
|
||||||
soft_pwm_fan = fanSpeedSoftPwm / 2;
|
soft_pwm_fan = fanSpeedSoftPwm / 2;
|
||||||
if(soft_pwm_fan > 0) WRITE(FAN_PIN,1);
|
if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0);
|
||||||
else WRITE(FAN_PIN,0);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if(soft_pwm_0 < pwm_count)
|
if(soft_pwm_0 < pwm_count)
|
||||||
|
|
@ -1835,10 +1810,9 @@ ISR(TIMER0_COMPB_vect)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FAN_SOFT_PWM
|
#ifdef FAN_SOFT_PWM
|
||||||
if (pwm_count == 0) {
|
if (pwm_count == 0){
|
||||||
soft_pwm_fan = fanSpeedSoftPwm / 2;
|
soft_pwm_fan = fanSpeedSoftPwm / 2;
|
||||||
if (soft_pwm_fan > 0) WRITE(FAN_PIN,1);
|
if (soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0);
|
||||||
else WRITE(FAN_PIN,0);
|
|
||||||
}
|
}
|
||||||
if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0);
|
if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1879,7 +1853,7 @@ ISR(TIMER0_COMPB_vect)
|
||||||
|
|
||||||
|
|
||||||
#ifdef BABYSTEPPING
|
#ifdef BABYSTEPPING
|
||||||
for(uint8_t axis=0; axis<3; axis++)
|
for(uint8_t axis=0;axis<3;axis++)
|
||||||
{
|
{
|
||||||
int curTodo=babystepsTodo[axis]; //get rid of volatile for performance
|
int curTodo=babystepsTodo[axis]; //get rid of volatile for performance
|
||||||
|
|
||||||
|
|
@ -1890,7 +1864,8 @@ ISR(TIMER0_COMPB_vect)
|
||||||
babystepsTodo[axis]--; //less to do next time
|
babystepsTodo[axis]--; //less to do next time
|
||||||
asm("sei");
|
asm("sei");
|
||||||
}
|
}
|
||||||
else if(curTodo<0)
|
else
|
||||||
|
if(curTodo<0)
|
||||||
{
|
{
|
||||||
asm("cli");
|
asm("cli");
|
||||||
babystep(axis,/*fwd*/false);
|
babystep(axis,/*fwd*/false);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include "Marlin.h"
|
#include "Marlin.h"
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
#ifdef PID_ADD_EXTRUSION_RATE
|
#ifdef PID_ADD_EXTRUSION_RATE
|
||||||
#include "stepper.h"
|
#include "stepper.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ENABLE_TEMPERATURE_INTERRUPT() TIMSK0 |= (1<<OCIE0B)
|
#define ENABLE_TEMPERATURE_INTERRUPT() TIMSK0 |= (1<<OCIE0B)
|
||||||
|
|
@ -39,8 +39,8 @@ void manage_heater(); //it is critical that this is called periodically.
|
||||||
extern int target_temperature[EXTRUDERS];
|
extern int target_temperature[EXTRUDERS];
|
||||||
extern float current_temperature[EXTRUDERS];
|
extern float current_temperature[EXTRUDERS];
|
||||||
#ifdef SHOW_TEMP_ADC_VALUES
|
#ifdef SHOW_TEMP_ADC_VALUES
|
||||||
extern int current_temperature_raw[EXTRUDERS];
|
extern int current_temperature_raw[EXTRUDERS];
|
||||||
extern int current_temperature_bed_raw;
|
extern int current_temperature_bed_raw;
|
||||||
#endif
|
#endif
|
||||||
extern int target_temperature_bed;
|
extern int target_temperature_bed;
|
||||||
extern float current_temperature_bed;
|
extern float current_temperature_bed;
|
||||||
|
|
@ -64,27 +64,27 @@ extern int current_voltage_raw_bed;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
||||||
extern float redundant_temperature;
|
extern float redundant_temperature;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
|
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
|
||||||
extern unsigned char soft_pwm_bed;
|
extern unsigned char soft_pwm_bed;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PIDTEMP
|
#ifdef PIDTEMP
|
||||||
extern int pid_cycle, pid_number_of_cycles;
|
extern int pid_cycle, pid_number_of_cycles;
|
||||||
extern float Kc,_Kp,_Ki,_Kd;
|
extern float Kc,_Kp,_Ki,_Kd;
|
||||||
extern bool pid_tuning_finished;
|
extern bool pid_tuning_finished;
|
||||||
float scalePID_i(float i);
|
float scalePID_i(float i);
|
||||||
float scalePID_d(float d);
|
float scalePID_d(float d);
|
||||||
float unscalePID_i(float i);
|
float unscalePID_i(float i);
|
||||||
float unscalePID_d(float d);
|
float unscalePID_d(float d);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef BABYSTEPPING
|
#ifdef BABYSTEPPING
|
||||||
extern volatile int babystepsTodo[3];
|
extern volatile int babystepsTodo[3];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline void babystepsTodoZadd(int n)
|
inline void babystepsTodoZadd(int n)
|
||||||
|
|
@ -114,13 +114,13 @@ FORCE_INLINE float degHotend(uint8_t extruder) {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SHOW_TEMP_ADC_VALUES
|
#ifdef SHOW_TEMP_ADC_VALUES
|
||||||
FORCE_INLINE float rawHotendTemp(uint8_t extruder) {
|
FORCE_INLINE float rawHotendTemp(uint8_t extruder) {
|
||||||
return current_temperature_raw[extruder];
|
return current_temperature_raw[extruder];
|
||||||
};
|
};
|
||||||
|
|
||||||
FORCE_INLINE float rawBedTemp() {
|
FORCE_INLINE float rawBedTemp() {
|
||||||
return current_temperature_bed_raw;
|
return current_temperature_bed_raw;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FORCE_INLINE float degBed() {
|
FORCE_INLINE float degBed() {
|
||||||
|
|
@ -146,14 +146,14 @@ static inline void setTargetHotendSafe(const float &celsius, uint8_t extruder)
|
||||||
|
|
||||||
static inline void setAllTargetHotends(const float &celsius)
|
static inline void setAllTargetHotends(const float &celsius)
|
||||||
{
|
{
|
||||||
for(int i=0; i<EXTRUDERS; i++) setTargetHotend(celsius,i);
|
for(int i=0;i<EXTRUDERS;i++) setTargetHotend(celsius,i);
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE_INLINE void setTargetBed(const float &celsius) {
|
FORCE_INLINE void setTargetBed(const float &celsius) {
|
||||||
target_temperature_bed = celsius;
|
target_temperature_bed = celsius;
|
||||||
};
|
};
|
||||||
|
|
||||||
FORCE_INLINE bool isHeatingHotend(uint8_t extruder) {
|
FORCE_INLINE bool isHeatingHotend(uint8_t extruder){
|
||||||
return target_temperature[extruder] > current_temperature[extruder];
|
return target_temperature[extruder] > current_temperature[extruder];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -202,15 +202,15 @@ void setWatch();
|
||||||
void updatePID();
|
void updatePID();
|
||||||
|
|
||||||
|
|
||||||
FORCE_INLINE void autotempShutdown() {
|
FORCE_INLINE void autotempShutdown(){
|
||||||
#ifdef AUTOTEMP
|
#ifdef AUTOTEMP
|
||||||
if(autotemp_enabled)
|
if(autotemp_enabled)
|
||||||
{
|
{
|
||||||
autotemp_enabled=false;
|
autotemp_enabled=false;
|
||||||
if(degTargetHotend(active_extruder)>autotemp_min)
|
if(degTargetHotend(active_extruder)>autotemp_min)
|
||||||
setTargetHotend(0,active_extruder);
|
setTargetHotend(0,active_extruder);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PID_autotune(float temp, int extruder, int ncycles);
|
void PID_autotune(float temp, int extruder, int ncycles);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue