From 5b2c37d6c1318079687eed6e14aecd3a4ef2ce47 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Mon, 18 Mar 2019 17:31:11 -0400 Subject: [PATCH] Followup to BLTouch (#13422) --- Marlin/src/feature/bedlevel/abl/abl.h | 4 +- Marlin/src/feature/bedlevel/bedlevel.h | 55 +++++++++---------- .../feature/bedlevel/mbl/mesh_bed_leveling.h | 5 +- Marlin/src/feature/bedlevel/ubl/ubl.h | 4 +- Marlin/src/feature/bltouch.cpp | 18 +++--- Marlin/src/gcode/calibrate/G34_M422.cpp | 4 ++ Marlin/src/lcd/extensible_ui/ui_api.cpp | 2 +- Marlin/src/lcd/extensible_ui/ui_api.h | 1 - Marlin/src/pins/pins_RAMPS.h | 10 ++-- buildroot/share/tests/DUE-tests | 2 +- 10 files changed, 56 insertions(+), 49 deletions(-) diff --git a/Marlin/src/feature/bedlevel/abl/abl.h b/Marlin/src/feature/bedlevel/abl/abl.h index 541d98a412..8f2a900beb 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.h +++ b/Marlin/src/feature/bedlevel/abl/abl.h @@ -40,4 +40,6 @@ void refresh_bed_level(); void bilinear_line_to_destination(const float fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF); #endif -#define Z_VALUES(X,Y) z_values[X][Y] +#define _GET_MESH_X(I) (bilinear_start[X_AXIS] + (I) * bilinear_grid_spacing[X_AXIS]) +#define _GET_MESH_Y(J) (bilinear_start[Y_AXIS] + (J) * bilinear_grid_spacing[Y_AXIS]) +#define Z_VALUES_ARR z_values diff --git a/Marlin/src/feature/bedlevel/bedlevel.h b/Marlin/src/feature/bedlevel/bedlevel.h index 94437a8b21..fe05e7c4ff 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.h +++ b/Marlin/src/feature/bedlevel/bedlevel.h @@ -48,38 +48,35 @@ void reset_bed_level(); void set_z_fade_height(const float zfh, const bool do_report=true); #endif -#if EITHER(AUTO_BED_LEVELING_BILINEAR, MESH_BED_LEVELING) - - #include - - typedef float (*element_2d_fn)(const uint8_t, const uint8_t); - - /** - * Print calibration results for plotting or manual frame adjustment. - */ - void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, element_2d_fn fn); - -#endif - #if EITHER(MESH_BED_LEVELING, PROBE_MANUALLY) void _manual_goto_xy(const float &x, const float &y); #endif -#if ENABLED(AUTO_BED_LEVELING_BILINEAR) - #define _GET_MESH_X(I) (bilinear_start[X_AXIS] + (I) * bilinear_grid_spacing[X_AXIS]) - #define _GET_MESH_Y(J) (bilinear_start[Y_AXIS] + (J) * bilinear_grid_spacing[Y_AXIS]) -#elif ENABLED(AUTO_BED_LEVELING_UBL) - #define _GET_MESH_X(I) ubl.mesh_index_to_xpos(I) - #define _GET_MESH_Y(J) ubl.mesh_index_to_ypos(J) -#elif ENABLED(MESH_BED_LEVELING) - #define _GET_MESH_X(I) mbl.index_to_xpos[I] - #define _GET_MESH_Y(J) mbl.index_to_ypos[J] -#endif +#if HAS_MESH + + typedef float (&bed_mesh_t)[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; + + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + #include "abl/abl.h" + #elif ENABLED(AUTO_BED_LEVELING_UBL) + #include "ubl/ubl.h" + #elif ENABLED(MESH_BED_LEVELING) + #include "mbl/mesh_bed_leveling.h" + #endif + + #define Z_VALUES(X,Y) Z_VALUES_ARR[X][Y] + + #if EITHER(AUTO_BED_LEVELING_BILINEAR, MESH_BED_LEVELING) + + #include + + typedef float (*element_2d_fn)(const uint8_t, const uint8_t); + + /** + * Print calibration results for plotting or manual frame adjustment. + */ + void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, element_2d_fn fn); + + #endif -#if ENABLED(MESH_BED_LEVELING) - #include "mbl/mesh_bed_leveling.h" -#elif ENABLED(AUTO_BED_LEVELING_UBL) - #include "ubl/ubl.h" -#elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - #include "abl/abl.h" #endif diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h index 9a746f6b91..1869187afe 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h @@ -34,6 +34,9 @@ enum MeshLevelingState : char { #define MESH_X_DIST ((MESH_MAX_X - (MESH_MIN_X)) / (GRID_MAX_POINTS_X - 1)) #define MESH_Y_DIST ((MESH_MAX_Y - (MESH_MIN_Y)) / (GRID_MAX_POINTS_Y - 1)) +#define _GET_MESH_X(I) mbl.index_to_xpos[I] +#define _GET_MESH_Y(J) mbl.index_to_ypos[J] +#define Z_VALUES_ARR mbl.z_values class mesh_bed_leveling { public: @@ -118,5 +121,3 @@ public: }; extern mesh_bed_leveling mbl; - -#define Z_VALUES(X,Y) mbl.z_values[X][Y] diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index b71ddee982..969fd209dc 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -335,7 +335,9 @@ class unified_bed_leveling { extern unified_bed_leveling ubl; -#define Z_VALUES(X,Y) ubl.z_values[X][Y] +#define _GET_MESH_X(I) ubl.mesh_index_to_xpos(I) +#define _GET_MESH_Y(J) ubl.mesh_index_to_ypos(J) +#define Z_VALUES_ARR ubl.z_values // Prevent debugging propagating to other files #include "../../../core/debug_out.h" diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index a1cc959483..fc3757a47a 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -69,19 +69,19 @@ bool BLTouch::set_deployed(const bool in_deploy) { } } - #if ENABLED(BLTOUCH_V3) - #if ENABLED(BLTOUCH_FORCE_5V_MODE) - set_5V_mode(); // Assume 5V DC logic level if endstop pullup resistors are enabled - #else - set_OD_mode(); - #endif + #if ENABLED(BLTOUCH_FORCE_5V_MODE) + set_5V_mode(); + #elif ENABLED(BLTOUCH_FORCE_OPEN_DRAIN_MODE) + set_OD_mode(); + #elif ENABLED(ENDSTOPPULLUPS) || ALL(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, ENDSTOPPULLUP_ZMIN) || (USES_Z_MIN_PROBE_ENDSTOP && ENABLED(ENDSTOPPULLUP_ZMIN_PROBE)) + set_5V_mode(); // Assume 5V DC logic level if endstop pullup resistors are enabled + #else + set_OD_mode(); #endif if (in_deploy) { _deploy(); - #if ENABLED(BLTOUCH_V3) - set_SW_mode(); // Ensure Switch mode is activated for BLTouch V3. Ignored on V2. - #endif + set_SW_mode(); // Ensure Switch mode is activated for BLTouch V3. Ignored on V2. } else _stow(); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 0f7c237f17..9a26400a97 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -38,6 +38,10 @@ #include "../../module/probe.h" #endif +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif + #if HAS_LEVELING #include "../../feature/bedlevel/bedlevel.h" #endif diff --git a/Marlin/src/lcd/extensible_ui/ui_api.cpp b/Marlin/src/lcd/extensible_ui/ui_api.cpp index 6f2edfe4f1..e8595b1eec 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.cpp +++ b/Marlin/src/lcd/extensible_ui/ui_api.cpp @@ -588,7 +588,7 @@ namespace ExtUI { void setLevelingActive(const bool state) { set_bed_leveling_enabled(state); } #if HAS_MESH bool getMeshValid() { return leveling_is_valid(); } - bed_mesh_t getMeshArray() { return Z_VALUES; } + bed_mesh_t getMeshArray() { return Z_VALUES_ARR; } void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zoff) { if (WITHIN(xpos, 0, GRID_MAX_POINTS_X) && WITHIN(ypos, 0, GRID_MAX_POINTS_Y)) { Z_VALUES(xpos, ypos) = zoff; diff --git a/Marlin/src/lcd/extensible_ui/ui_api.h b/Marlin/src/lcd/extensible_ui/ui_api.h index c7e33d77b1..46b5d805b7 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.h +++ b/Marlin/src/lcd/extensible_ui/ui_api.h @@ -95,7 +95,6 @@ namespace ExtUI { bool getLevelingActive(); void setLevelingActive(const bool); #if HAS_MESH - typedef float (&bed_mesh_t)[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; bool getMeshValid(); bed_mesh_t getMeshArray(); void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zval); diff --git a/Marlin/src/pins/pins_RAMPS.h b/Marlin/src/pins/pins_RAMPS.h index 8da975ab93..1f06992cfa 100644 --- a/Marlin/src/pins/pins_RAMPS.h +++ b/Marlin/src/pins/pins_RAMPS.h @@ -63,10 +63,12 @@ // // Servos // -#ifdef IS_RAMPS_13 - #define SERVO0_PIN 7 // RAMPS_13 // Will conflict with BTN_EN2 on LCD_I2C_VIKI -#else - #define SERVO0_PIN 11 +#ifndef SERVO0_PIN + #ifdef IS_RAMPS_13 + #define SERVO0_PIN 7 // RAMPS_13 // Will conflict with BTN_EN2 on LCD_I2C_VIKI + #else + #define SERVO0_PIN 11 + #endif #endif #define SERVO1_PIN 6 #define SERVO2_PIN 5 diff --git a/buildroot/share/tests/DUE-tests b/buildroot/share/tests/DUE-tests index a9b4a13598..8a04f42443 100755 --- a/buildroot/share/tests/DUE-tests +++ b/buildroot/share/tests/DUE-tests @@ -15,7 +15,7 @@ exec_test $1 $2 "RAMPS4DUE_EFB S_CURVE_ACCELERATION EEPROM_SETTINGS" restore_configs opt_set MOTHERBOARD BOARD_RADDS -opt_enable USE_XMAX_PLUG USE_YMAX_PLUG FIX_MOUNTED_PROBE AUTO_BED_LEVELING_BILINEAR \ +opt_enable USE_XMAX_PLUG USE_YMAX_PLUG BLTOUCH AUTO_BED_LEVELING_BILINEAR \ Z_TRIPLE_STEPPER_DRIVERS Z_TRIPLE_ENDSTOPS Z_STEPPER_AUTO_ALIGN opt_add Z2_MAX_ENDSTOP_INVERTING false opt_add Z3_MAX_ENDSTOP_INVERTING false