clean up and fix

This commit is contained in:
Scott Lahteine
2021-10-09 18:41:47 -05:00
parent 4f62ae9764
commit ec7a4eb69e
11 changed files with 35 additions and 40 deletions
+2 -2
View File
@@ -28,8 +28,8 @@
BLTouch bltouch;
bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
bool BLTouch::bltouch_high_speed; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed
bool BLTouch::last_written_mode, // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
BLTouch::high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed
#include "../module/servo.h"
#include "../module/probe.h"
+5 -2
View File
@@ -66,9 +66,12 @@ typedef unsigned char BLTCommand;
class BLTouch {
public:
static void init(const bool set_voltage=false);
static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
static bool bltouch_high_speed; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed
static bool last_written_mode, // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed
const float z_extra_clearance() { return high_speed_mode ? 7 : 0; }
// DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing
static bool deploy() { return deploy_proc(); }
+1 -2
View File
@@ -102,8 +102,7 @@ void GcodeSuite::G35() {
// In BLTOUCH HS mode, the probe travels in a deployed state.
// Users of G35 might have a badly misaligned bed, so raise Z by the
// length of the deployed pin (BLTOUCH stroke < 7mm)
float z_raise_probe = Z_CLEARANCE_BETWEEN_PROBES if(bltouch.bltouch_high_speed) + 7;
do_blocking_move_to_z(z_raise_probe);
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES + TERN0(BLTOUCH, bltouch.z_extra_clearance()));
const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE, 0, true);
if (isnan(z_probed_height)) {
+1 -1
View File
@@ -149,7 +149,7 @@ void GcodeSuite::G34() {
// In BLTOUCH HS mode, the probe travels in a deployed state.
// Users of G34 might have a badly misaligned bed, so raise Z by the
// length of the deployed pin (BLTOUCH stroke < 7mm)
#define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + 7.0f * bltouch.bltouch_high_speed)
#define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + TERN0(BLTOUCH, bltouch.z_extra_clearance()))
// Compute a worst-case clearance height to probe from. After the first
// iteration this will be re-calculated based on the actual bed position
+2 -7
View File
@@ -38,13 +38,8 @@
*/
void GcodeSuite::M401() {
#if ENABLED(BLTOUCH)
const bool seen_S = parser.seen('S'),
to_enable = (seen_S && parser.value_bool());
if (seen_S) {
if(to_enable)
bltouch.bltouch_high_speed = true;
else
bltouch.bltouch_high_speed = false;
if (parser.seen('S')) {
bltouch.high_speed_mode = parser.value_bool();
return;
}
#endif
+6 -7
View File
@@ -221,13 +221,13 @@ static void _lcd_level_bed_corners_get_next_position() {
bool _lcd_level_bed_corners_probe(bool verify=false) {
if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed
if(!bltouch.bltouch_high_speed) bltouch.deploy(); // Deploy in LOW SPEED MODE on every probe action
if (!bltouch.high_speed_mode) bltouch.deploy(); // Deploy in LOW SPEED MODE on every probe action
do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance
if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered
endstops.hit_on_purpose();
set_current_from_steppers_for_axis(Z_AXIS);
sync_plan_position();
if(!bltouch.bltouch_high_speed) bltouch.stow(); // Stow in LOW SPEED MODE on every trigger
if (!bltouch.high_speed_mode) bltouch.stow(); // Stow in LOW SPEED MODE on every trigger
// Triggered outside tolerance range?
if (ABS(current_position.z - last_z) > LEVEL_CORNERS_PROBE_TOLERANCE) {
last_z = current_position.z; // Above tolerance. Set a new Z for subsequent corners.
@@ -253,7 +253,7 @@ static void _lcd_level_bed_corners_get_next_position() {
}
idle();
}
if(!bltouch.bltouch_high_speed) bltouch.stow();
if (!bltouch.high_speed_mode) bltouch.stow();
ui.goto_screen(_lcd_draw_probing);
return (probe_triggered);
}
@@ -267,14 +267,13 @@ static void _lcd_level_bed_corners_get_next_position() {
do {
ui.refresh(LCDVIEW_REDRAW_NOW);
_lcd_draw_probing(); // update screen with # of good points
float z_raise_probe = Z_CLEARANCE_BETWEEN_PROBES if(bltouch.bltouch_high_speed) + 7;
do_blocking_move_to_z(SUM_TERN(z_raise_probe, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance
do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP + (bltouch.high_speed_mode ? 7, 0)); // clearance
_lcd_level_bed_corners_get_next_position(); // Select next corner coordinates
current_position -= probe.offset_xy; // Account for probe offsets
do_blocking_move_to_xy(current_position); // Goto corner
if(bltouch.bltouch_high_speed) bltouch.deploy(); // Deploy in HIGH SPEED MODE
if (bltouch.high_speed_mode) bltouch.deploy(); // Deploy in HIGH SPEED MODE
if (!_lcd_level_bed_corners_probe()) { // Probe down to tolerance
if (_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed
#if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) // Verify
@@ -295,7 +294,7 @@ static void _lcd_level_bed_corners_get_next_position() {
} while (good_points < nr_edge_points); // loop until all points within tolerance
if (bltouch.bltouch_high_speed)
if (bltouch.high_speed_mode)
// In HIGH SPEED MODE do clearance and stow at the very end
do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP);
bltouch.stow();
+1 -1
View File
@@ -235,7 +235,7 @@ void menu_advanced_settings();
ACTION_ITEM(MSG_BLTOUCH_DEPLOY, bltouch._deploy);
ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow);
ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode);
EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.bltouch_high_speed);
EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.high_speed_mode);
#if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU)
CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
+1 -1
View File
@@ -52,7 +52,7 @@ static bool probe_single_point() {
do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES));
// Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety
const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], if(bltouch.bltouch_high_speed) PROBE_PT_STOW else PROBE_PT_RAISE), 0, true);
const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], bltouch.high_speed_mode ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true);
z_measured[tram_index] = z_probed_height;
if (reference_index < 0) reference_index = tram_index;
move_to_tramming_wait_pos();
+3 -3
View File
@@ -1800,7 +1800,7 @@ void prepare_line_to_destination() {
do_homing_move(axis, move_length, 0.0, !use_probe_bump);
#if ENABLED(HOMING_Z_WITH_PROBE, BLTOUCH)
if (axis == Z_AXIS && !bltouch.bltouch_high_speed) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE)
if (axis == Z_AXIS && !bltouch.high_speed_mode) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE)
#endif
// If a second homing move is configured...
@@ -1834,8 +1834,8 @@ void prepare_line_to_destination() {
#endif
#if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH)
if(!bltouch.bltouch_high_speed)
if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE)
if (axis == Z_AXIS && !bltouch.high_speed_mode && bltouch.deploy())
return; // Intermediate DEPLOY (in LOW SPEED MODE)
#endif
// Slow move towards endstop until triggered
+5 -6
View File
@@ -488,8 +488,8 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
thermalManager.wait_for_hotend_heating(active_extruder);
#endif
#if ENABLED(BLTOUCH)
if(!bltouch.bltouch_high_speed)
if (bltouch.deploy()) return true; // Deploy in LOW SPEED MODE on every probe action
if (!bltouch.high_speed_mode && bltouch.deploy())
return true; // Deploy in LOW SPEED MODE on every probe action
#endif
// Disable stealthChop if used. Enable diag1 pin on driver.
@@ -531,9 +531,8 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
set_homing_current(false);
#endif
#if ENABLED(BLTOUCH)
if(!bltouch.bltouch_high_speed)
if (probe_triggered && bltouch.stow()) // Stow in LOW SPEED MODE on every trigger
return true;
if (!bltouch.high_speed_mode && probe_triggered && bltouch.stow())
return true; // Stow in LOW SPEED MODE on every trigger
#endif
// Clear endstop flags
endstops.hit_on_purpose();
@@ -764,7 +763,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
}
#if ENABLED(BLTOUCH)
if (bltouch.triggered() && bltouch.bltouch_high_speed) bltouch._reset();
if (bltouch.triggered() && bltouch.high_speed_mode) bltouch._reset();
#endif
// On delta keep Z below clip height or do_blocking_move_to will abort
+8 -8
View File
@@ -277,7 +277,7 @@ typedef struct SettingsDataStruct {
// BLTOUCH
//
bool bltouch_last_written_mode;
bool bltouch_high_speed;
bool high_speed_mode;
//
// Kinematic Settings
@@ -863,9 +863,9 @@ void MarlinSettings::postprocess() {
const bool bltouch_last_written_mode = TERN(BLTOUCH, bltouch.last_written_mode, false);
EEPROM_WRITE(bltouch_last_written_mode);
_FIELD_TEST(bltouch_high_speed);
const bool bltouch_high_speed = TERN(BLTOUCH, bltouch.bltouch_high_speed, false);
EEPROM_WRITE(bltouch_high_speed);
_FIELD_TEST(high_speed_mode);
const bool high_speed_mode = TERN(BLTOUCH, bltouch.high_speed_mode, false);
EEPROM_WRITE(high_speed_mode);
}
//
@@ -1738,11 +1738,11 @@ void MarlinSettings::postprocess() {
#endif
EEPROM_READ(bltouch_last_written_mode);
_FIELD_TEST(bltouch_high_speed);
_FIELD_TEST(high_speed_mode);
#if ENABLED(BLTOUCH)
const bool &bltouch_high_speed = bltouch.bltouch_high_speed;
const bool &high_speed_mode = bltouch.high_speed_mode;
#else
bool bltouch_high_speed;
bool high_speed_mode;
#endif
EEPROM_READ(bltouch_last_written_mode);
}
@@ -2744,7 +2744,7 @@ void MarlinSettings::reset() {
//
// BLTouch
//
TERN_(BLTOUCH_HS_MODE, bltouch.bltouch_high_speed = true);
TERN_(BLTOUCH_HS_MODE, bltouch.high_speed_mode = true);
//
// Kinematic settings
//