Merge pull request #6491 from thinkyhead/rc_cleanup_wednesday

Various cleanups for recent merges
master
Scott Lahteine 8 years ago committed by GitHub
commit f169c04604

@ -2060,65 +2060,66 @@ static void clean_up_after_endstop_or_probe_move() {
#endif #endif
#if ENABLED(BLTOUCH) #if ENABLED(BLTOUCH)
void bltouch_command(int angle) { void bltouch_command(int angle) {
servo[Z_ENDSTOP_SERVO_NR].move(angle); // Give the BL-Touch the command and wait servo[Z_ENDSTOP_SERVO_NR].move(angle); // Give the BL-Touch the command and wait
safe_delay(BLTOUCH_DELAY); safe_delay(BLTOUCH_DELAY);
} }
// /**
// The BL-Touch probes have a HAL effect sensor. The high currents switching * BLTouch probes have a Hall effect sensor. The high currents switching
// on and off cause big magnetic fields that can affect the repeatability of the * on and off cause a magnetic field that can affect the repeatability of the
// sensor. So, for BL-Touch probes, we turn off the heaters during the actual probe. * sensor. So for BLTouch probes, heaters are turned off during the probe,
// And then we quickly turn them back on after we have sampled the point * then quickly turned back on after the point is sampled.
// */
#if ENABLED(BLTOUCH_HEATERS_OFF) #if ENABLED(BLTOUCH_HEATERS_OFF)
void turn_heaters_on_or_off_for_bltouch(const bool deploy) {
static int8_t bltouch_recursion_cnt=0; bool set_heaters_for_bltouch(const bool deploy) {
static millis_t last_emi_protection=0; static bool heaters_were_disabled = false;
static millis_t next_emi_protection;
static float temps_at_entry[HOTENDS]; static float temps_at_entry[HOTENDS];
#if HAS_TEMP_BED #if HAS_TEMP_BED
static float bed_temp_at_entry; static float bed_temp_at_entry;
#endif #endif
if (deploy && bltouch_recursion_cnt>0) // if already in the correct state, we don't need to do anything // If called out of order or far apart something is seriously wrong
return; // with the heaters. if (deploy == heaters_were_disabled
if (!deploy && bltouch_recursion_cnt<1) // if already in the correct state, we don't need to do anything || (next_emi_protection && ELAPSED(millis(), next_emi_protection)))
return; // with the heaters. kill(PSTR(MSG_KILLED));
if (deploy) { if (deploy) {
bltouch_recursion_cnt++; next_emi_protection = millis() + 20 * 1000UL;
last_emi_protection = millis(); HOTEND_LOOP() {
HOTEND_LOOP() temps_at_entry[e] = thermalManager.degTargetHotend(e); // save the current target temperatures temps_at_entry[e] = thermalManager.degTargetHotend(e);
HOTEND_LOOP() thermalManager.setTargetHotend(0, e); // so we know what to restore them to. thermalManager.setTargetHotend(0, e);
}
#if HAS_TEMP_BED #if HAS_TEMP_BED
bed_temp_at_entry = thermalManager.degTargetBed(); bed_temp_at_entry = thermalManager.degTargetBed();
thermalManager.setTargetBed(0.0); thermalManager.setTargetBed(0);
#endif #endif
} }
else { else {
bltouch_recursion_cnt--; // the heaters are only turned back on HOTEND_LOOP() thermalManager.setTargetHotend(temps_at_entry[e], e);
if (bltouch_recursion_cnt==0 && ((last_emi_protection+20000L)>millis())) { // if everything is perfect. It is expected #if HAS_TEMP_BED
HOTEND_LOOP() thermalManager.setTargetHotend(temps_at_entry[e], e); // that the bltouch_recursion_cnt is zero and thermalManager.setTargetBed(bed_temp_at_entry);
#if HAS_TEMP_BED // that the heaters were shut off less than
thermalManager.setTargetBed(bed_temp_at_entry); // 20 seconds ago
#endif #endif
} }
} }
}
#endif #endif // BLTOUCH_HEATERS_OFF
void set_bltouch_deployed(const bool deploy) { void set_bltouch_deployed(const bool deploy) {
#if ENABLED(BLTOUCH_HEATERS_OFF) #if ENABLED(BLTOUCH_HEATERS_OFF)
turn_heaters_on_or_off_for_bltouch(deploy); set_heaters_for_bltouch(deploy);
#endif #endif
if (deploy && TEST_BLTOUCH()) { // If BL-Touch says it's triggered if (deploy && TEST_BLTOUCH()) { // If BL-Touch says it's triggered
bltouch_command(BLTOUCH_RESET); // try to reset it. bltouch_command(BLTOUCH_RESET); // try to reset it.
bltouch_command(BLTOUCH_DEPLOY); // Also needs to deploy and stow to bltouch_command(BLTOUCH_DEPLOY); // Also needs to deploy and stow to
bltouch_command(BLTOUCH_STOW); // clear the triggered condition. bltouch_command(BLTOUCH_STOW); // clear the triggered condition.
safe_delay(1500); // wait for internal self test to complete safe_delay(1500); // Wait for internal self-test to complete.
// measured completion time was 0.65 seconds // (Measured completion time was 0.65 seconds
// after reset, deploy & stow sequence // after reset, deploy, and stow sequence)
if (TEST_BLTOUCH()) { // If it still claims to be triggered... if (TEST_BLTOUCH()) { // If it still claims to be triggered...
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_STOP_BLTOUCH); SERIAL_ERRORLNPGM(MSG_STOP_BLTOUCH);
@ -2134,7 +2135,8 @@ static void clean_up_after_endstop_or_probe_move() {
} }
#endif #endif
} }
#endif
#endif // BLTOUCH
// returns false for ok and true for failure // returns false for ok and true for failure
bool set_probe_deployed(bool deploy) { bool set_probe_deployed(bool deploy) {
@ -2146,10 +2148,8 @@ static void clean_up_after_endstop_or_probe_move() {
} }
#endif #endif
#if ENABLED(BLTOUCH) #if ENABLED(BLTOUCH) && ENABLED(BLTOUCH_HEATERS_OFF)
#if ENABLED(BLTOUCH_HEATERS_OFF) set_heaters_for_bltouch(deploy);
turn_heaters_on_or_off_for_bltouch(deploy);
#endif
#endif #endif
if (endstops.z_probe_enabled == deploy) return false; if (endstops.z_probe_enabled == deploy) return false;
@ -2330,15 +2330,15 @@ static void clean_up_after_endstop_or_probe_move() {
return current_position[Z_AXIS] + zprobe_zoffset; return current_position[Z_AXIS] + zprobe_zoffset;
} }
// /**
// - Move to the given XY * - Move to the given XY
// - Deploy the probe, if not already deployed * - Deploy the probe, if not already deployed
// - Probe the bed, get the Z position * - Probe the bed, get the Z position
// - Depending on the 'stow' flag * - Depending on the 'stow' flag
// - Stow the probe, or * - Stow the probe, or
// - Raise to the BETWEEN height * - Raise to the BETWEEN height
// - Return the probed Z position * - Return the probed Z position
// */
float probe_pt(const float x, const float y, const bool stow/*=true*/, const int verbose_level/*=1*/) { float probe_pt(const float x, const float y, const bool stow/*=true*/, const int verbose_level/*=1*/) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
@ -2507,14 +2507,14 @@ static void clean_up_after_endstop_or_probe_move() {
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING) #if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING)
// /**
// Enable if you prefer your output in JSON format * Enable to produce output in JSON format suitable
// suitable for SCAD or JavaScript mesh visualizers. * for SCAD or JavaScript mesh visualizers.
// *
// Visualize meshes in OpenSCAD using the included script. * Visualize meshes in OpenSCAD using the included script.
// *
// buildroot/shared/scripts/MarlinMesh.scad * buildroot/shared/scripts/MarlinMesh.scad
// */
//#define SCAD_MESH_OUTPUT //#define SCAD_MESH_OUTPUT
/** /**

@ -293,6 +293,7 @@
#define HEATER_1_MAXTEMP 245 #define HEATER_1_MAXTEMP 245
#define HEATER_2_MAXTEMP 245 #define HEATER_2_MAXTEMP 245
#define HEATER_3_MAXTEMP 245 #define HEATER_3_MAXTEMP 245
#define HEATER_4_MAXTEMP 245
#define BED_MAXTEMP 115 #define BED_MAXTEMP 115
//=========================================================================== //===========================================================================
@ -317,12 +318,16 @@
// 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
// FolgerTech i3-2020 // FolgerTech i3-2020
#define DEFAULT_Kp 11.50 #define DEFAULT_Kp 11.50
#define DEFAULT_Ki 0.50 #define DEFAULT_Ki 0.50
#define DEFAULT_Kd 60.00 #define DEFAULT_Kd 60.00
// Ultimaker
//#define DEFAULT_Kp 22.2
//#define DEFAULT_Ki 1.08
//#define DEFAULT_Kd 114
// MakerGear // MakerGear
//#define DEFAULT_Kp 7.0 //#define DEFAULT_Kp 7.0
//#define DEFAULT_Ki 0.1 //#define DEFAULT_Ki 0.1
@ -563,7 +568,6 @@
*/ */
//#define FIX_MOUNTED_PROBE //#define FIX_MOUNTED_PROBE
/** /**
* Z Servo Probe, such as an endstop switch on a rotating arm. * Z Servo Probe, such as an endstop switch on a rotating arm.
* NUM_SERVOS also needs to be set. This is found later in this file. Set it to * NUM_SERVOS also needs to be set. This is found later in this file. Set it to
@ -631,8 +635,10 @@
#define XY_PROBE_SPEED 7500 #define XY_PROBE_SPEED 7500
// Speed for the first approach when double-probing (with PROBE_DOUBLE_TOUCH) // Speed for the first approach when double-probing (with PROBE_DOUBLE_TOUCH)
#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z #define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
// Speed for the "accurate" probe of each point // Speed for the "accurate" probe of each point
#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2) #define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
// Use double touch for probing // Use double touch for probing
//#define PROBE_DOUBLE_TOUCH //#define PROBE_DOUBLE_TOUCH
@ -694,7 +700,6 @@
*/ */
//#define Z_MIN_PROBE_ENDSTOP //#define Z_MIN_PROBE_ENDSTOP
#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN #define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
// Enable Z Probe Repeatability test to see how accurate your probe is // Enable Z Probe Repeatability test to see how accurate your probe is
@ -771,7 +776,6 @@
#define Y_HOME_DIR -1 #define Y_HOME_DIR -1
#define Z_HOME_DIR -1 #define Z_HOME_DIR -1
// @section machine // @section machine
// Travel limits after homing (units are in mm) // Travel limits after homing (units are in mm)
@ -804,7 +808,6 @@
//=========================================================================== //===========================================================================
//=============================== Bed Leveling ============================== //=============================== Bed Leveling ==============================
//=========================================================================== //===========================================================================
// @section bedlevel // @section bedlevel
/** /**
@ -851,7 +854,6 @@
#define AUTO_BED_LEVELING_UBL #define AUTO_BED_LEVELING_UBL
//#define MESH_BED_LEVELING //#define MESH_BED_LEVELING
/** /**
* Enable detailed logging of G28, G29, M48, etc. * Enable detailed logging of G28, G29, M48, etc.
* Turn on with the command 'M111 S32'. * Turn on with the command 'M111 S32'.
@ -902,7 +904,6 @@
// 3 arbitrary points to probe. // 3 arbitrary points to probe.
// A simple cross-product is used to estimate the plane of the bed. // A simple cross-product is used to estimate the plane of the bed.
#define ABL_PROBE_PT_1_X 39 #define ABL_PROBE_PT_1_X 39
#define ABL_PROBE_PT_1_Y 170 #define ABL_PROBE_PT_1_Y 170
#define ABL_PROBE_PT_2_X 39 #define ABL_PROBE_PT_2_X 39
@ -928,6 +929,7 @@
#define UBL_PROBE_PT_3_X 180 #define UBL_PROBE_PT_3_X 180
#define UBL_PROBE_PT_3_Y 25 #define UBL_PROBE_PT_3_Y 25
#define UBL_G26_MESH_EDITING // Enable G26 mesh editing #define UBL_G26_MESH_EDITING // Enable G26 mesh editing
#elif ENABLED(MESH_BED_LEVELING) #elif ENABLED(MESH_BED_LEVELING)
//=========================================================================== //===========================================================================
@ -1607,7 +1609,7 @@
*/ */
//#define FILAMENT_WIDTH_SENSOR //#define FILAMENT_WIDTH_SENSOR
#define DEFAULT_NOMINAL_FILAMENT_DIA 1.75 //Enter the diameter (in mm) of the filament generally used (3.0 mm or 1.75 mm) - this is then used in the slicer software. Used for sensor reading validation #define DEFAULT_NOMINAL_FILAMENT_DIA 1.75 // (mm) Diameter of the filament generally used (3.0 or 1.75mm), also used in the slicer. Used to validate sensor reading.
#if ENABLED(FILAMENT_WIDTH_SENSOR) #if ENABLED(FILAMENT_WIDTH_SENSOR)
#define FILAMENT_SENSOR_EXTRUDER_NUM 0 // Index of the extruder that has the filament sensor (0,1,2,3) #define FILAMENT_SENSOR_EXTRUDER_NUM 0 // Index of the extruder that has the filament sensor (0,1,2,3)

@ -419,7 +419,6 @@
* M909, M910 & LCD - only PRINTRBOARD_REVF & RIGIDBOARD_V2 * M909, M910 & LCD - only PRINTRBOARD_REVF & RIGIDBOARD_V2
*/ */
//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps //#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps
//#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) //#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
//#define DAC_MOTOR_CURRENT_DEFAULT { 70, 80, 90, 80 } // Default drive percent - X, Y, Z, E axis //#define DAC_MOTOR_CURRENT_DEFAULT { 70, 80, 90, 80 } // Default drive percent - X, Y, Z, E axis
@ -587,10 +586,9 @@
*/ */
#define BABYSTEPPING #define BABYSTEPPING
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
#define BABYSTEP_XY //not only z, but also XY in the menu. more clutter, more functions #define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA!
//not implemented for deltabots! #define BABYSTEP_INVERT_Z false // Change if Z babysteps should go the other way
#define BABYSTEP_INVERT_Z false //true for inverse movements in Z #define BABYSTEP_MULTIPLICATOR 2 // Babysteps are very small. Increase for faster motion.
#define BABYSTEP_MULTIPLICATOR 2 //faster movements
//#define BABYSTEP_ZPROBE_OFFSET // Enable to combine M851 and Babystepping //#define BABYSTEP_ZPROBE_OFFSET // Enable to combine M851 and Babystepping
#define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping. #define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping.
#define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds. #define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds.
@ -1034,7 +1032,6 @@
* (https://github.com/ameyer/Arduino-L6470) * (https://github.com/ameyer/Arduino-L6470)
*/ */
//#define HAVE_L6470DRIVER //#define HAVE_L6470DRIVER
#if ENABLED(HAVE_L6470DRIVER) #if ENABLED(HAVE_L6470DRIVER)
@ -1155,7 +1152,6 @@
*/ */
//#define EXTENDED_CAPABILITIES_REPORT //#define EXTENDED_CAPABILITIES_REPORT
/** /**
* Volumetric extrusion default state * Volumetric extrusion default state
* Activate to make volumetric extrusion the default method, * Activate to make volumetric extrusion the default method,

@ -474,7 +474,7 @@
#define X_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define X_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
#define Y_MAX_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop. #define Y_MAX_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop.
#define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
#define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the probe.
// Enable this feature if all enabled endstop pins are interrupt-capable. // Enable this feature if all enabled endstop pins are interrupt-capable.
// This will remove the need to poll the interrupt pins, saving many CPU cycles. // This will remove the need to poll the interrupt pins, saving many CPU cycles.
@ -730,8 +730,6 @@
#define Z_CLEARANCE_DEPLOY_PROBE 15 // Z Clearance for Deploy/Stow #define Z_CLEARANCE_DEPLOY_PROBE 15 // Z Clearance for Deploy/Stow
#define Z_CLEARANCE_BETWEEN_PROBES 6 // Z Clearance between probe points #define Z_CLEARANCE_BETWEEN_PROBES 6 // Z Clearance between probe points
//
// For M851 give a range for adjusting the Z probe offset // For M851 give a range for adjusting the Z probe offset
#define Z_PROBE_OFFSET_RANGE_MIN -20 #define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20 #define Z_PROBE_OFFSET_RANGE_MAX 20
@ -1035,7 +1033,7 @@
// //
// M100 Free Memory Watcher // M100 Free Memory Watcher
// //
#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
// //
// G20/G21 Inch mode support // G20/G21 Inch mode support
@ -1619,7 +1617,7 @@
*/ */
//#define FILAMENT_WIDTH_SENSOR //#define FILAMENT_WIDTH_SENSOR
#define DEFAULT_NOMINAL_FILAMENT_DIA 1.75 //Enter the diameter (in mm) of the filament generally used (3.0 mm or 1.75 mm) - this is then used in the slicer software. Used for sensor reading validation #define DEFAULT_NOMINAL_FILAMENT_DIA 1.75 // (mm) Diameter of the filament generally used (3.0 or 1.75mm), also used in the slicer. Used to validate sensor reading.
#if ENABLED(FILAMENT_WIDTH_SENSOR) #if ENABLED(FILAMENT_WIDTH_SENSOR)
#define FILAMENT_SENSOR_EXTRUDER_NUM 0 // Index of the extruder that has the filament sensor (0,1,2,3) #define FILAMENT_SENSOR_EXTRUDER_NUM 0 // Index of the extruder that has the filament sensor (0,1,2,3)
@ -1633,6 +1631,6 @@
// Display filament width on the LCD status line. Status messages will expire after 5 seconds. // Display filament width on the LCD status line. Status messages will expire after 5 seconds.
//#define FILAMENT_LCD_DISPLAY //#define FILAMENT_LCD_DISPLAY
#endif //FILAMENT_WIDTH_SENSOR #endif
#endif // CONFIGURATION_H #endif // CONFIGURATION_H

@ -361,7 +361,7 @@
// Default stepper release if idle. Set to 0 to deactivate. // Default stepper release if idle. Set to 0 to deactivate.
// Steppers will shut down DEFAULT_STEPPER_DEACTIVE_TIME seconds after the last move when DISABLE_INACTIVE_? is true. // Steppers will shut down DEFAULT_STEPPER_DEACTIVE_TIME seconds after the last move when DISABLE_INACTIVE_? is true.
// Time can be set by M18 and M84. // Time can be set by M18 and M84.
#define DEFAULT_STEPPER_DEACTIVE_TIME 0 // usually is set to 120 seconds #define DEFAULT_STEPPER_DEACTIVE_TIME 0 // usually set to 120 seconds
#define DISABLE_INACTIVE_X true #define DISABLE_INACTIVE_X true
#define DISABLE_INACTIVE_Y true #define DISABLE_INACTIVE_Y true
#define DISABLE_INACTIVE_Z true // set to false if the nozzle will fall down on your printed part when print has finished. #define DISABLE_INACTIVE_Z true // set to false if the nozzle will fall down on your printed part when print has finished.

@ -106,5 +106,3 @@ const unsigned char custom_start_bmp[896] PROGMEM = {
0x03, 0x80, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x80, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x01, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
}; };

@ -408,6 +408,9 @@
#ifndef MSG_ZPROBE_OUT #ifndef MSG_ZPROBE_OUT
#define MSG_ZPROBE_OUT _UxGT("Z probe out. bed") #define MSG_ZPROBE_OUT _UxGT("Z probe out. bed")
#endif #endif
#ifndef MSG_BLTOUCH
#define MSG_BLTOUCH _UxGT("BLTouch")
#endif
#ifndef MSG_BLTOUCH_SELFTEST #ifndef MSG_BLTOUCH_SELFTEST
#define MSG_BLTOUCH_SELFTEST _UxGT("BLTouch Self-Test") #define MSG_BLTOUCH_SELFTEST _UxGT("BLTouch Self-Test")
#endif #endif

@ -21,7 +21,7 @@
*/ */
/** /**
* Least Squares Best Fit By Roxy and Ed Williams * Least Squares Best Fit by Roxy and Ed Williams
* *
* This algorithm is high speed and has a very small code footprint. * This algorithm is high speed and has a very small code footprint.
* Its results are identical to both the Iterative Least-Squares published * Its results are identical to both the Iterative Least-Squares published
@ -41,37 +41,26 @@
#include "least_squares_fit.h" #include "least_squares_fit.h"
void incremental_LSF_reset(struct linear_fit_data *lsf) { void incremental_LSF_reset(struct linear_fit_data *lsf) { ZERO(lsf); }
lsf->n = 0;
lsf->A = 0.0; // probably a memset() can be done to zero
lsf->B = 0.0; // this whole structure
lsf->D = 0.0;
lsf->xbar = lsf->ybar = lsf->zbar = 0.0;
lsf->x2bar = lsf->y2bar = lsf->z2bar = 0.0;
lsf->xybar = lsf->xzbar = lsf->yzbar = 0.0;
lsf->max_absx = lsf->max_absy = 0.0;
}
void incremental_LSF(struct linear_fit_data *lsf, float x, float y, float z) { void incremental_LSF(struct linear_fit_data *lsf, float x, float y, float z) {
lsf->xbar += x; lsf->xbar += x;
lsf->ybar += y; lsf->ybar += y;
lsf->zbar += z; lsf->zbar += z;
lsf->x2bar += x*x; lsf->x2bar += sq(x);
lsf->y2bar += y*y; lsf->y2bar += sq(y);
lsf->z2bar += z*z; lsf->z2bar += sq(z);
lsf->xybar += x*y; lsf->xybar += sq(x);
lsf->xzbar += x*z; lsf->xzbar += sq(x);
lsf->yzbar += y*z; lsf->yzbar += sq(y);
lsf->max_absx = (fabs(x) > lsf->max_absx) ? fabs(x) : lsf->max_absx; lsf->max_absx = max(fabs(x), lsf->max_absx);
lsf->max_absy = (fabs(y) > lsf->max_absy) ? fabs(y) : lsf->max_absy; lsf->max_absy = max(fabs(y), lsf->max_absy);
lsf->n++; lsf->n++;
return;
} }
int finish_incremental_LSF(struct linear_fit_data *lsf) { int finish_incremental_LSF(struct linear_fit_data *lsf) {
float DD, N; const float N = (float)lsf->n;
N = (float) lsf->n;
lsf->xbar /= N; lsf->xbar /= N;
lsf->ybar /= N; lsf->ybar /= N;
lsf->zbar /= N; lsf->zbar /= N;
@ -82,7 +71,7 @@ int finish_incremental_LSF(struct linear_fit_data *lsf) {
lsf->yzbar = lsf->yzbar / N - lsf->ybar * lsf->zbar; lsf->yzbar = lsf->yzbar / N - lsf->ybar * lsf->zbar;
lsf->xzbar = lsf->xzbar / N - lsf->xbar * lsf->zbar; lsf->xzbar = lsf->xzbar / N - lsf->xbar * lsf->zbar;
DD = lsf->x2bar*lsf->y2bar - lsf->xybar*lsf->xybar; const float DD = lsf->x2bar * lsf->y2bar - sq(lsf->xybar);
if (fabs(DD) <= 1e-10 * (lsf->max_absx + lsf->max_absy)) if (fabs(DD) <= 1e-10 * (lsf->max_absx + lsf->max_absy))
return -1; return -1;
@ -91,6 +80,5 @@ int finish_incremental_LSF(struct linear_fit_data *lsf) {
lsf->D = -(lsf->zbar + lsf->A * lsf->xbar + lsf->B * lsf->ybar); lsf->D = -(lsf->zbar + lsf->A * lsf->xbar + lsf->B * lsf->ybar);
return 0; return 0;
} }
#endif
#endif // AUTO_BED_LEVELING_UBL

@ -42,11 +42,11 @@
struct linear_fit_data { struct linear_fit_data {
int n; int n;
float xbar, ybar, zbar; float xbar, ybar, zbar,
float x2bar, y2bar, z2bar; x2bar, y2bar, z2bar,
float xybar, xzbar, yzbar; xybar, xzbar, yzbar,
float max_absx, max_absy; max_absx, max_absy,
float A, B, D; A, B, D;
}; };
void incremental_LSF_reset(struct linear_fit_data *); void incremental_LSF_reset(struct linear_fit_data *);

@ -91,11 +91,6 @@
public: public:
//
// Please do not put STATIC qualifiers in front of ANYTHING in this file. You WILL cause problems by doing that.
// The GCC optimizer inlines static functions and this DRAMATICALLY increases the size of the stack frame of
// functions that call STATIC functions.
//
void find_mean_mesh_height(); void find_mean_mesh_height();
void shift_mesh_height(); void shift_mesh_height();
void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest); void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);
@ -105,22 +100,12 @@
void save_ubl_active_state_and_disable(); void save_ubl_active_state_and_disable();
void restore_ubl_active_state_and_leave(); void restore_ubl_active_state_and_leave();
void g29_what_command(); void g29_what_command();
//
// Please do not put STATIC qualifiers in front of ANYTHING in this file. You WILL cause problems by doing that.
// The GCC optimizer inlines static functions and this DRAMATICALLY increases the size of the stack frame of
// functions that call STATIC functions.
//
void g29_eeprom_dump() ; void g29_eeprom_dump() ;
void g29_compare_current_mesh_to_stored_mesh(); void g29_compare_current_mesh_to_stored_mesh();
void fine_tune_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map); void fine_tune_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map);
void smart_fill_mesh(); void smart_fill_mesh();
void display_map(const int); void display_map(const int);
void reset(); void reset();
//
// Please do not put STATIC qualifiers in front of ANYTHING in this file. You WILL cause problems by doing that.
// The GCC optimizer inlines static functions and this DRAMATICALLY increases the size of the stack frame of
// functions that call STATIC functions.
//
void invalidate(); void invalidate();
void store_state(); void store_state();
void load_state(); void load_state();
@ -134,25 +119,27 @@
// 15 is the maximum nubmer of grid points supported + 1 safety margin for now, // 15 is the maximum nubmer of grid points supported + 1 safety margin for now,
// until determinism prevails // until determinism prevails
constexpr static float mesh_index_to_xpos[16] PROGMEM = { UBL_MESH_MIN_X+0*(MESH_X_DIST), constexpr static float mesh_index_to_xpos[16] PROGMEM = {
UBL_MESH_MIN_X+1*(MESH_X_DIST), UBL_MESH_MIN_X+2*(MESH_X_DIST), UBL_MESH_MIN_X + 0 * (MESH_X_DIST), UBL_MESH_MIN_X + 1 * (MESH_X_DIST),
UBL_MESH_MIN_X+3*(MESH_X_DIST), UBL_MESH_MIN_X+4*(MESH_X_DIST), UBL_MESH_MIN_X + 2 * (MESH_X_DIST), UBL_MESH_MIN_X + 3 * (MESH_X_DIST),
UBL_MESH_MIN_X+5*(MESH_X_DIST), UBL_MESH_MIN_X+6*(MESH_X_DIST), UBL_MESH_MIN_X + 4 * (MESH_X_DIST), UBL_MESH_MIN_X + 5 * (MESH_X_DIST),
UBL_MESH_MIN_X+7*(MESH_X_DIST), UBL_MESH_MIN_X+8*(MESH_X_DIST), UBL_MESH_MIN_X + 6 * (MESH_X_DIST), UBL_MESH_MIN_X + 7 * (MESH_X_DIST),
UBL_MESH_MIN_X+9*(MESH_X_DIST), UBL_MESH_MIN_X+10*(MESH_X_DIST), UBL_MESH_MIN_X + 8 * (MESH_X_DIST), UBL_MESH_MIN_X + 9 * (MESH_X_DIST),
UBL_MESH_MIN_X+11*(MESH_X_DIST), UBL_MESH_MIN_X+12*(MESH_X_DIST), UBL_MESH_MIN_X + 10 * (MESH_X_DIST), UBL_MESH_MIN_X + 11 * (MESH_X_DIST),
UBL_MESH_MIN_X+13*(MESH_X_DIST), UBL_MESH_MIN_X+14*(MESH_X_DIST), UBL_MESH_MIN_X + 12 * (MESH_X_DIST), UBL_MESH_MIN_X + 13 * (MESH_X_DIST),
UBL_MESH_MIN_X+15*(MESH_X_DIST) }; UBL_MESH_MIN_X + 14 * (MESH_X_DIST), UBL_MESH_MIN_X + 15 * (MESH_X_DIST)
};
constexpr static float mesh_index_to_ypos[16] PROGMEM = { UBL_MESH_MIN_Y+0*(MESH_Y_DIST),
UBL_MESH_MIN_Y+1*(MESH_Y_DIST), UBL_MESH_MIN_Y+2*(MESH_Y_DIST), constexpr static float mesh_index_to_ypos[16] PROGMEM = {
UBL_MESH_MIN_Y+3*(MESH_Y_DIST), UBL_MESH_MIN_Y+4*(MESH_Y_DIST), UBL_MESH_MIN_Y + 0 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 1 * (MESH_Y_DIST),
UBL_MESH_MIN_Y+5*(MESH_Y_DIST), UBL_MESH_MIN_Y+6*(MESH_Y_DIST), UBL_MESH_MIN_Y + 2 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 3 * (MESH_Y_DIST),
UBL_MESH_MIN_Y+7*(MESH_Y_DIST), UBL_MESH_MIN_Y+8*(MESH_Y_DIST), UBL_MESH_MIN_Y + 4 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 5 * (MESH_Y_DIST),
UBL_MESH_MIN_Y+9*(MESH_Y_DIST), UBL_MESH_MIN_Y+10*(MESH_Y_DIST), UBL_MESH_MIN_Y + 6 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 7 * (MESH_Y_DIST),
UBL_MESH_MIN_Y+11*(MESH_Y_DIST), UBL_MESH_MIN_Y+12*(MESH_Y_DIST), UBL_MESH_MIN_Y + 8 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 9 * (MESH_Y_DIST),
UBL_MESH_MIN_Y+13*(MESH_Y_DIST), UBL_MESH_MIN_Y+14*(MESH_Y_DIST), UBL_MESH_MIN_Y + 10 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 11 * (MESH_Y_DIST),
UBL_MESH_MIN_Y+15*(MESH_Y_DIST) }; UBL_MESH_MIN_Y + 12 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 13 * (MESH_Y_DIST),
UBL_MESH_MIN_Y + 14 * (MESH_Y_DIST), UBL_MESH_MIN_Y + 15 * (MESH_Y_DIST)
};
static bool g26_debug_flag, has_control_of_lcd_panel; static bool g26_debug_flag, has_control_of_lcd_panel;
@ -163,11 +150,6 @@
unified_bed_leveling(); unified_bed_leveling();
//
// Please do not put STATIC qualifiers in front of ANYTHING in this file. You WILL cause problems by doing that.
// The GCC optimizer inlines static functions and this DRAMATICALLY increases the size of the stack frame of
// functions that call STATIC functions.
//
FORCE_INLINE void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; } FORCE_INLINE void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
int8_t get_cell_index_x(const float &x) { int8_t get_cell_index_x(const float &x) {
const int8_t cx = (x - (UBL_MESH_MIN_X)) * (1.0 / (MESH_X_DIST)); const int8_t cx = (x - (UBL_MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
@ -184,11 +166,6 @@
// that is OK because something else should be keeping that from // that is OK because something else should be keeping that from
// happening and should not be worried about at this level. // happening and should not be worried about at this level.
//
// Please do not put STATIC qualifiers in front of ANYTHING in this file. You WILL cause problems by doing that.
// The GCC optimizer inlines static functions and this DRAMATICALLY increases the size of the stack frame of
// functions that call STATIC functions.
//
int8_t find_closest_x_index(const float &x) { int8_t find_closest_x_index(const float &x) {
const int8_t px = (x - (UBL_MESH_MIN_X) + (MESH_X_DIST) * 0.5) * (1.0 / (MESH_X_DIST)); const int8_t px = (x - (UBL_MESH_MIN_X) + (MESH_X_DIST) * 0.5) * (1.0 / (MESH_X_DIST));
return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1; return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
@ -217,11 +194,6 @@
FORCE_INLINE float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) { FORCE_INLINE float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) {
return z1 + (z2 - z1) * (a0 - a1) / (a2 - a1); return z1 + (z2 - z1) * (a0 - a1) / (a2 - a1);
} }
//
// Please do not put STATIC qualifiers in front of ANYTHING in this file. You WILL cause problems by doing that.
// The GCC optimizer inlines static functions and this DRAMATICALLY increases the size of the stack frame of
// functions that call STATIC functions.
//
/** /**
* z_correction_for_x_on_horizontal_mesh_line is an optimization for * z_correction_for_x_on_horizontal_mesh_line is an optimization for

@ -54,7 +54,6 @@
bool ProbeStay = true; bool ProbeStay = true;
#define SIZE_OF_LITTLE_RAISE 0 #define SIZE_OF_LITTLE_RAISE 0
#define BIG_RAISE_NOT_NEEDED 0 #define BIG_RAISE_NOT_NEEDED 0
extern void lcd_quick_feedback(); extern void lcd_quick_feedback();

@ -34,10 +34,6 @@
#include "buzzer.h" #include "buzzer.h"
#endif #endif
#if ENABLED(BLTOUCH)
#include "endstops.h"
#endif
#if ENABLED(PRINTCOUNTER) #if ENABLED(PRINTCOUNTER)
#include "printcounter.h" #include "printcounter.h"
#include "duration_t.h" #include "duration_t.h"
@ -723,6 +719,28 @@ void kill_screen(const char* lcd_msg) {
#endif // MENU_ITEM_CASE_LIGHT #endif // MENU_ITEM_CASE_LIGHT
#if ENABLED(BLTOUCH)
/**
*
* "BLTouch" submenu
*
*/
static void bltouch_menu() {
START_MENU();
//
// ^ Main
//
MENU_BACK(MSG_MAIN);
MENU_ITEM(gcode, MSG_BLTOUCH_RESET, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_RESET)));
MENU_ITEM(gcode, MSG_BLTOUCH_SELFTEST, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_SELFTEST)));
MENU_ITEM(gcode, MSG_BLTOUCH_DEPLOY, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_DEPLOY)));
MENU_ITEM(gcode, MSG_BLTOUCH_STOW, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_STOW)));
END_MENU();
}
#endif // BLTOUCH
#if ENABLED(LCD_PROGRESS_BAR_TEST) #if ENABLED(LCD_PROGRESS_BAR_TEST)
static void progress_bar_test() { static void progress_bar_test() {
@ -792,8 +810,7 @@ void kill_screen(const char* lcd_msg) {
#endif #endif
#if ENABLED(BLTOUCH) #if ENABLED(BLTOUCH)
if (!endstops.z_probe_enabled && TEST_BLTOUCH()) MENU_ITEM(submenu, MSG_BLTOUCH, bltouch_menu);
MENU_ITEM(gcode, MSG_BLTOUCH_RESET, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_RESET)));
#endif #endif
if (planner.movesplanned() || IS_SD_PRINTING) { if (planner.movesplanned() || IS_SD_PRINTING) {

Loading…
Cancel
Save