diff --git a/Marlin/src/HAL/shared/Delay.h b/Marlin/src/HAL/shared/Delay.h index 1bcfb9e8a..1c2ee47c2 100644 --- a/Marlin/src/HAL/shared/Delay.h +++ b/Marlin/src/HAL/shared/Delay.h @@ -29,8 +29,8 @@ * DELAY_US(count): Delay execution in microseconds */ -#include "../../core/macros.h" #include "../../core/millis_t.h" +#include "../../core/macros.h" #if defined(__arm__) || defined(__thumb__) diff --git a/Marlin/src/core/enum.h b/Marlin/src/core/enum.h index 08883c8b4..15118f7b2 100644 --- a/Marlin/src/core/enum.h +++ b/Marlin/src/core/enum.h @@ -61,14 +61,3 @@ enum AxisEnum : unsigned char { #define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS) #define LOOP_ABCE(VAR) LOOP_S_LE_N(VAR, A_AXIS, E_AXIS) #define LOOP_ABCE_N(VAR) LOOP_S_L_N(VAR, A_AXIS, XYZE_N) - -typedef enum { - LINEARUNIT_MM, - LINEARUNIT_INCH -} LinearUnit; - -typedef enum { - TEMPUNIT_C, - TEMPUNIT_K, - TEMPUNIT_F -} TempUnit; diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 8bca0a2c7..a24aea3ef 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -198,12 +198,22 @@ }while(0) // Macros for initializing arrays -#define ARRAY_6(v1, v2, v3, v4, v5, v6, ...) { v1, v2, v3, v4, v5, v6 } -#define ARRAY_5(v1, v2, v3, v4, v5, ...) { v1, v2, v3, v4, v5 } -#define ARRAY_4(v1, v2, v3, v4, ...) { v1, v2, v3, v4 } -#define ARRAY_3(v1, v2, v3, ...) { v1, v2, v3 } -#define ARRAY_2(v1, v2, ...) { v1, v2 } -#define ARRAY_1(v1, ...) { v1 } +#define ARRAY_16(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) { A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P } +#define ARRAY_15(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) { A,B,C,D,E,F,G,H,I,J,K,L,M,N,O } +#define ARRAY_14(A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) { A,B,C,D,E,F,G,H,I,J,K,L,M,N } +#define ARRAY_13(A,B,C,D,E,F,G,H,I,J,K,L,M,...) { A,B,C,D,E,F,G,H,I,J,K,L,M } +#define ARRAY_12(A,B,C,D,E,F,G,H,I,J,K,L,...) { A,B,C,D,E,F,G,H,I,J,K,L } +#define ARRAY_11(A,B,C,D,E,F,G,H,I,J,K,...) { A,B,C,D,E,F,G,H,I,J,K } +#define ARRAY_10(A,B,C,D,E,F,G,H,I,J,...) { A,B,C,D,E,F,G,H,I,J } +#define ARRAY_9( A,B,C,D,E,F,G,H,I,...) { A,B,C,D,E,F,G,H,I } +#define ARRAY_8( A,B,C,D,E,F,G,H,...) { A,B,C,D,E,F,G,H } +#define ARRAY_7( A,B,C,D,E,F,G,...) { A,B,C,D,E,F,G } +#define ARRAY_6( A,B,C,D,E,F,...) { A,B,C,D,E,F } +#define ARRAY_5( A,B,C,D,E,...) { A,B,C,D,E } +#define ARRAY_4( A,B,C,D,...) { A,B,C,D } +#define ARRAY_3( A,B,C,...) { A,B,C } +#define ARRAY_2( A,B,...) { A,B } +#define ARRAY_1( A,...) { A } #define _ARRAY_N(N,V...) ARRAY_##N(V) #define ARRAY_N(N,V...) _ARRAY_N(N,V) diff --git a/Marlin/src/feature/I2CPositionEncoder.cpp b/Marlin/src/feature/I2CPositionEncoder.cpp index 8e879d8bb..bc6b49bab 100644 --- a/Marlin/src/feature/I2CPositionEncoder.cpp +++ b/Marlin/src/feature/I2CPositionEncoder.cpp @@ -334,11 +334,10 @@ bool I2CPositionEncoder::test_axis() { ec = false; - LOOP_NA(i) { + LOOP_XYZ(i) { startCoord[i] = planner.get_axis_position_mm((AxisEnum)i); endCoord[i] = planner.get_axis_position_mm((AxisEnum)i); } - startCoord[encoderAxis] = startPosition; endCoord[encoderAxis] = endPosition; @@ -393,9 +392,9 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) { endDistance = soft_endstop[encoderAxis].max - 20; travelDistance = endDistance - startDistance; - LOOP_NA(i) { - startCoord[i] = planner.get_axis_position_mm((AxisEnum)i); - endCoord[i] = planner.get_axis_position_mm((AxisEnum)i); + LOOP_XYZ(a) { + startCoord[a] = planner.get_axis_position_mm((AxisEnum)a); + endCoord[a] = planner.get_axis_position_mm((AxisEnum)a); } startCoord[encoderAxis] = startDistance; diff --git a/Marlin/src/feature/babystep.h b/Marlin/src/feature/babystep.h index ea465bd46..617108316 100644 --- a/Marlin/src/feature/babystep.h +++ b/Marlin/src/feature/babystep.h @@ -22,7 +22,6 @@ #pragma once #include "../inc/MarlinConfigPre.h" -#include "../core/enum.h" #if IS_CORE || EITHER(BABYSTEP_XY, I2C_POSITION_ENCODERS) #define BS_TODO_AXIS(A) A diff --git a/Marlin/src/feature/bedlevel/abl/abl.cpp b/Marlin/src/feature/bedlevel/abl/abl.cpp index 57c8ddb60..9e7fc0d67 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.cpp +++ b/Marlin/src/feature/bedlevel/abl/abl.cpp @@ -24,7 +24,6 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) -#include "abl.h" #include "../bedlevel.h" #include "../../../module/motion.h" diff --git a/Marlin/src/feature/bedlevel/bedlevel.h b/Marlin/src/feature/bedlevel/bedlevel.h index fc5813373..d01751407 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.h +++ b/Marlin/src/feature/bedlevel/bedlevel.h @@ -23,11 +23,6 @@ #include "../../inc/MarlinConfigPre.h" -typedef struct { - int8_t x_index, y_index; - float distance; // When populated, the distance from the search location -} mesh_index_pair; - #if ENABLED(PROBE_MANUALLY) extern bool g29_in_progress; #else @@ -60,7 +55,12 @@ class TemporaryBedLevelingState { #if HAS_MESH - typedef float (&bed_mesh_t)[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; + typedef float bed_mesh_t[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; + + typedef struct { + int8_t x_index, y_index; + float distance; // When populated, the distance from the search location + } mesh_index_pair; #if ENABLED(AUTO_BED_LEVELING_BILINEAR) #include "abl/abl.h" diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h index ef77896fe..4885cd825 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h @@ -32,8 +32,8 @@ enum MeshLevelingState : char { MeshReset // G29 S5 }; -#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 MESH_X_DIST (float(MESH_MAX_X - (MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1)) +#define MESH_Y_DIST (float(MESH_MAX_Y - (MESH_MIN_Y)) / float(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 diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 5716f2955..10a3b90dc 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -24,13 +24,14 @@ #if ENABLED(AUTO_BED_LEVELING_UBL) - #include "ubl.h" + #include "../bedlevel.h" + unified_bed_leveling ubl; #include "../../../module/configuration_store.h" #include "../../../module/planner.h" #include "../../../module/motion.h" - #include "../../bedlevel/bedlevel.h" + #include "../../../module/probe.h" #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extensible_ui/ui_api.h" @@ -66,10 +67,21 @@ float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; - // 15 is the maximum nubmer of grid points supported + 1 safety margin for now, - // until determinism prevails - constexpr float unified_bed_leveling::_mesh_index_to_xpos[16], - unified_bed_leveling::_mesh_index_to_ypos[16]; + #define _GRIDPOS(A,N) (MESH_MIN_##A + N * (MESH_##A##_DIST)) + + const float + unified_bed_leveling::_mesh_index_to_xpos[GRID_MAX_POINTS_X] PROGMEM = ARRAY_N(GRID_MAX_POINTS_X, + _GRIDPOS(X, 0), _GRIDPOS(X, 1), _GRIDPOS(X, 2), _GRIDPOS(X, 3), + _GRIDPOS(X, 4), _GRIDPOS(X, 5), _GRIDPOS(X, 6), _GRIDPOS(X, 7), + _GRIDPOS(X, 8), _GRIDPOS(X, 9), _GRIDPOS(X, 10), _GRIDPOS(X, 11), + _GRIDPOS(X, 12), _GRIDPOS(X, 13), _GRIDPOS(X, 14), _GRIDPOS(X, 15) + ), + unified_bed_leveling::_mesh_index_to_ypos[GRID_MAX_POINTS_Y] PROGMEM = ARRAY_N(GRID_MAX_POINTS_Y, + _GRIDPOS(Y, 0), _GRIDPOS(Y, 1), _GRIDPOS(Y, 2), _GRIDPOS(Y, 3), + _GRIDPOS(Y, 4), _GRIDPOS(Y, 5), _GRIDPOS(Y, 6), _GRIDPOS(Y, 7), + _GRIDPOS(Y, 8), _GRIDPOS(Y, 9), _GRIDPOS(Y, 10), _GRIDPOS(Y, 11), + _GRIDPOS(Y, 12), _GRIDPOS(Y, 13), _GRIDPOS(Y, 14), _GRIDPOS(Y, 15) + ); #if HAS_LCD_MENU bool unified_bed_leveling::lcd_map_control = false; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index a231f9d43..5183dc848 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -23,11 +23,7 @@ //#define UBL_DEVEL_DEBUGGING -#include "../bedlevel.h" -#include "../../../module/planner.h" #include "../../../module/motion.h" -#include "../../../lcd/ultralcd.h" -#include "../../../Marlin.h" #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../../core/debug_out.h" @@ -108,31 +104,9 @@ class unified_bed_leveling { static int8_t storage_slot; - static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; - - // 15 is the maximum nubmer of grid points supported + 1 safety margin for now, - // until determinism prevails - static constexpr float _mesh_index_to_xpos[16] PROGMEM = { - MESH_MIN_X + 0 * (MESH_X_DIST), MESH_MIN_X + 1 * (MESH_X_DIST), - MESH_MIN_X + 2 * (MESH_X_DIST), MESH_MIN_X + 3 * (MESH_X_DIST), - MESH_MIN_X + 4 * (MESH_X_DIST), MESH_MIN_X + 5 * (MESH_X_DIST), - MESH_MIN_X + 6 * (MESH_X_DIST), MESH_MIN_X + 7 * (MESH_X_DIST), - MESH_MIN_X + 8 * (MESH_X_DIST), MESH_MIN_X + 9 * (MESH_X_DIST), - MESH_MIN_X + 10 * (MESH_X_DIST), MESH_MIN_X + 11 * (MESH_X_DIST), - MESH_MIN_X + 12 * (MESH_X_DIST), MESH_MIN_X + 13 * (MESH_X_DIST), - MESH_MIN_X + 14 * (MESH_X_DIST), MESH_MIN_X + 15 * (MESH_X_DIST) - }; - - static constexpr float _mesh_index_to_ypos[16] PROGMEM = { - MESH_MIN_Y + 0 * (MESH_Y_DIST), MESH_MIN_Y + 1 * (MESH_Y_DIST), - MESH_MIN_Y + 2 * (MESH_Y_DIST), MESH_MIN_Y + 3 * (MESH_Y_DIST), - MESH_MIN_Y + 4 * (MESH_Y_DIST), MESH_MIN_Y + 5 * (MESH_Y_DIST), - MESH_MIN_Y + 6 * (MESH_Y_DIST), MESH_MIN_Y + 7 * (MESH_Y_DIST), - MESH_MIN_Y + 8 * (MESH_Y_DIST), MESH_MIN_Y + 9 * (MESH_Y_DIST), - MESH_MIN_Y + 10 * (MESH_Y_DIST), MESH_MIN_Y + 11 * (MESH_Y_DIST), - MESH_MIN_Y + 12 * (MESH_Y_DIST), MESH_MIN_Y + 13 * (MESH_Y_DIST), - MESH_MIN_Y + 14 * (MESH_Y_DIST), MESH_MIN_Y + 15 * (MESH_Y_DIST) - }; + static bed_mesh_t z_values; + static const float _mesh_index_to_xpos[GRID_MAX_POINTS_X], + _mesh_index_to_ypos[GRID_MAX_POINTS_Y]; #if HAS_LCD_MENU static bool lcd_map_control; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 650e9f9a6..9ee05a5a7 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -24,7 +24,7 @@ #if ENABLED(AUTO_BED_LEVELING_UBL) - #include "ubl.h" + #include "../bedlevel.h" #include "../../../Marlin.h" #include "../../../HAL/shared/persistent_store_api.h" @@ -33,11 +33,9 @@ #include "../../../lcd/ultralcd.h" #include "../../../module/stepper.h" #include "../../../module/planner.h" + #include "../../../module/motion.h" #include "../../../module/probe.h" #include "../../../gcode/gcode.h" - #include "../../../core/serial.h" - #include "../../../gcode/parser.h" - #include "../../../feature/bedlevel/bedlevel.h" #include "../../../libs/least_squares_fit.h" #if ENABLED(DUAL_X_CARRIAGE) @@ -783,7 +781,7 @@ if (location.x_index >= 0) { // mesh point found and is reachable by probe const float rawx = mesh_index_to_xpos(location.x_index), rawy = mesh_index_to_ypos(location.y_index), - measured_z = probe_pt(rawx, rawy, stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling + measured_z = probe_at_point(rawx, rawy, stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling z_values[location.x_index][location.y_index] = measured_z; #if ENABLED(EXTENSIBLE_UI) ExtUI::onMeshUpdate(location.x_index, location.y_index, measured_z); @@ -1410,7 +1408,7 @@ ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 1/3")); #endif - measured_z = probe_pt(PROBE_PT_1_X, PROBE_PT_1_Y, PROBE_PT_RAISE, g29_verbose_level); + measured_z = probe_at_point(PROBE_PT_1_X, PROBE_PT_1_Y, PROBE_PT_RAISE, g29_verbose_level); if (isnan(measured_z)) abort_flag = true; else { @@ -1429,7 +1427,7 @@ ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 2/3")); #endif - measured_z = probe_pt(PROBE_PT_2_X, PROBE_PT_2_Y, PROBE_PT_RAISE, g29_verbose_level); + measured_z = probe_at_point(PROBE_PT_2_X, PROBE_PT_2_Y, PROBE_PT_RAISE, g29_verbose_level); //z2 = measured_z; if (isnan(measured_z)) abort_flag = true; @@ -1449,7 +1447,7 @@ ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 3/3")); #endif - measured_z = probe_pt(PROBE_PT_3_X, PROBE_PT_3_Y, PROBE_PT_STOW, g29_verbose_level); + measured_z = probe_at_point(PROBE_PT_3_X, PROBE_PT_3_Y, PROBE_PT_STOW, g29_verbose_level); //z3 = measured_z; if (isnan(measured_z)) abort_flag = true; @@ -1490,7 +1488,7 @@ ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " %i/%i"), point_num, total_points); #endif - measured_z = probe_pt(rx, ry, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling + measured_z = probe_at_point(rx, ry, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling abort_flag = isnan(measured_z); diff --git a/Marlin/src/feature/digipot/digipot_mcp4018.cpp b/Marlin/src/feature/digipot/digipot_mcp4018.cpp index 91a64d543..86eeab63b 100644 --- a/Marlin/src/feature/digipot/digipot_mcp4018.cpp +++ b/Marlin/src/feature/digipot/digipot_mcp4018.cpp @@ -24,7 +24,6 @@ #if BOTH(DIGIPOT_I2C, DIGIPOT_MCP4018) -#include "../../core/enum.h" #include "Stream.h" #include "utility/twi.h" #include //https://github.com/stawel/SlowSoftI2CMaster diff --git a/Marlin/src/feature/host_actions.h b/Marlin/src/feature/host_actions.h index fa3c43ab6..11078ce20 100644 --- a/Marlin/src/feature/host_actions.h +++ b/Marlin/src/feature/host_actions.h @@ -23,8 +23,6 @@ #include "../inc/MarlinConfigPre.h" -#include - void host_action(const char * const pstr, const bool eol=true); #ifdef ACTION_ON_KILL diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 85af12c65..0c08a132d 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -714,7 +714,7 @@ G29_TYPE GcodeSuite::G29() { ui.status_printf_P(0, PSTR(MSG_PROBING_MESH " %i/%i"), int(pt_index), int(GRID_MAX_POINTS)); #endif - measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, raise_after, verbose_level); + measured_z = faux ? 0.001 * random(-100, 101) : probe_at_point(xProbe, yProbe, raise_after, verbose_level); if (isnan(measured_z)) { set_bed_leveling_enabled(abl_should_enable); @@ -759,7 +759,7 @@ G29_TYPE GcodeSuite::G29() { // Retain the last probe position xProbe = points[i].x; yProbe = points[i].y; - measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, raise_after, verbose_level); + measured_z = faux ? 0.001 * random(-100, 101) : probe_at_point(xProbe, yProbe, raise_after, verbose_level); if (isnan(measured_z)) { set_bed_leveling_enabled(abl_should_enable); break; diff --git a/Marlin/src/gcode/bedlevel/abl/M421.cpp b/Marlin/src/gcode/bedlevel/abl/M421.cpp index f75511531..b9470528a 100644 --- a/Marlin/src/gcode/bedlevel/abl/M421.cpp +++ b/Marlin/src/gcode/bedlevel/abl/M421.cpp @@ -29,7 +29,7 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) #include "../../gcode.h" -#include "../../../feature/bedlevel/abl/abl.h" +#include "../../../feature/bedlevel/bedlevel.h" #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extensible_ui/ui_api.h" diff --git a/Marlin/src/gcode/bedlevel/ubl/G29.cpp b/Marlin/src/gcode/bedlevel/ubl/G29.cpp index cb130c39d..c0f8f2043 100644 --- a/Marlin/src/gcode/bedlevel/ubl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/ubl/G29.cpp @@ -29,7 +29,7 @@ #if ENABLED(AUTO_BED_LEVELING_UBL) #include "../../gcode.h" -#include "../../../feature/bedlevel/ubl/ubl.h" +#include "../../../feature/bedlevel/bedlevel.h" void GcodeSuite::G29() { ubl.G29(); } diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 455b5b267..08045d8cb 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -190,7 +190,7 @@ static float std_dev_points(float z_pt[NPP + 1], const bool _0p_cal, const bool */ static float calibration_probe(const float &nx, const float &ny, const bool stow) { #if HAS_BED_PROBE - return probe_pt(nx, ny, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, false); + return probe_at_point(nx, ny, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, false); #else UNUSED(stow); return lcd_probe_pt(nx, ny); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 2ec665214..e55eacdc8 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -162,7 +162,7 @@ void GcodeSuite::G34() { if (iteration == 0 || izstepper > 0) do_blocking_move_to_z(z_probe); // Probe a Z height for each stepper. - const float z_probed_height = probe_pt(z_auto_align_xpos[zstepper], z_auto_align_ypos[zstepper], raise_after, 0, true); + const float z_probed_height = probe_at_point(z_auto_align_xpos[zstepper], z_auto_align_ypos[zstepper], raise_after, 0, true); if (isnan(z_probed_height)) { SERIAL_ECHOLNPGM("Probing failed."); err_break = true; diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 49b43eae7..dd0039e9b 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -116,7 +116,7 @@ void GcodeSuite::M48() { float mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples]; // Move to the first point, deploy, and probe - const float t = probe_pt(X_probe_location, Y_probe_location, raise_after, verbose_level); + const float t = probe_at_point(X_probe_location, Y_probe_location, raise_after, verbose_level); bool probing_good = !isnan(t); if (probing_good) { @@ -190,7 +190,7 @@ void GcodeSuite::M48() { } // n_legs // Probe a single point - sample_set[n] = probe_pt(X_probe_location, Y_probe_location, raise_after, 0); + sample_set[n] = probe_at_point(X_probe_location, Y_probe_location, raise_after, 0); // Break the loop if the probe fails probing_good = !isnan(sample_set[n]); diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 1917faa74..4f5128bb9 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -34,6 +34,14 @@ #include "../libs/hex_print_routines.h" #endif +#if ENABLED(TEMPERATURE_UNITS_SUPPORT) + typedef enum : uint8_t { TEMPUNIT_C, TEMPUNIT_K, TEMPUNIT_F } TempUnit; +#endif + +#if ENABLED(INCH_MODE_SUPPORT) + typedef enum : uint8_t { LINEARUNIT_MM, LINEARUNIT_INCH } LinearUnit; +#endif + /** * GCode parser * @@ -254,7 +262,6 @@ public: // Units modes: Inches, Fahrenheit, Kelvin #if ENABLED(INCH_MODE_SUPPORT) - static inline float mm_to_linear_unit(const float mm) { return mm / linear_unit_factor; } static inline float mm_to_volumetric_unit(const float mm) { return mm / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); } @@ -298,7 +305,7 @@ public: #if ENABLED(TEMPERATURE_UNITS_SUPPORT) - static inline void set_input_temp_units(TempUnit units) { input_temp_units = units; } + static inline void set_input_temp_units(const TempUnit units) { input_temp_units = units; } #if HAS_LCD_MENU && DISABLED(DISABLE_M503) diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index 9150f680f..68bdb5d3b 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -52,7 +52,7 @@ void GcodeSuite::G30() { setup_for_endstop_or_probe_move(); const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; - const float measured_z = probe_pt(xpos, ypos, raise_after, 1); + const float measured_z = probe_at_point(xpos, ypos, raise_after, 1); if (!isnan(measured_z)) SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(xpos), " Y: ", FIXFLOAT(ypos), " Z: ", FIXFLOAT(measured_z)); diff --git a/Marlin/src/inc/MarlinConfigPre.h b/Marlin/src/inc/MarlinConfigPre.h index 3aec32b24..96ee5d347 100644 --- a/Marlin/src/inc/MarlinConfigPre.h +++ b/Marlin/src/inc/MarlinConfigPre.h @@ -28,6 +28,7 @@ // // Prefix header to acquire configurations // +#include #include "../HAL/platforms.h" @@ -45,5 +46,3 @@ #include "Conditionals_adv.h" #include HAL_PATH(../HAL, inc/Conditionals_adv.h) - -#include diff --git a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp index b7ccbfec7..b16a29865 100644 --- a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp @@ -47,7 +47,7 @@ #endif #if ENABLED(AUTO_BED_LEVELING_UBL) - #include "../../feature/bedlevel/ubl/ubl.h" + #include "../../feature/bedlevel/bedlevel.h" #endif // diff --git a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp index b71af96a9..3d48243ad 100644 --- a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp +++ b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp @@ -60,7 +60,7 @@ #endif #if ENABLED(AUTO_BED_LEVELING_UBL) - #include "../../feature/bedlevel/ubl/ubl.h" + #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 aa65a0734..23e6718e1 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.cpp +++ b/Marlin/src/lcd/extensible_ui/ui_api.cpp @@ -809,7 +809,7 @@ namespace ExtUI { void setLevelingActive(const bool state) { set_bed_leveling_enabled(state); } bool getMeshValid() { return leveling_is_valid(); } #if HAS_MESH - bed_mesh_t getMeshArray() { return Z_VALUES_ARR; } + bed_mesh_t& getMeshArray() { return Z_VALUES_ARR; } float getMeshPoint(const uint8_t xpos, const uint8_t ypos) { return Z_VALUES(xpos,ypos); } 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)) { diff --git a/Marlin/src/lcd/extensible_ui/ui_api.h b/Marlin/src/lcd/extensible_ui/ui_api.h index e143c764d..31cd4c294 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.h +++ b/Marlin/src/lcd/extensible_ui/ui_api.h @@ -61,7 +61,7 @@ namespace ExtUI { constexpr uint8_t fanCount = FAN_COUNT; #if HAS_MESH - typedef float (&bed_mesh_t)[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; + typedef float bed_mesh_t[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; #endif bool isMoving(); @@ -128,7 +128,7 @@ namespace ExtUI { void setLevelingActive(const bool); bool getMeshValid(); #if HAS_MESH - bed_mesh_t getMeshArray(); + bed_mesh_t& getMeshArray(); float getMeshPoint(const uint8_t xpos, const uint8_t ypos); void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zval); void onMeshUpdate(const uint8_t xpos, const uint8_t ypos, const float zval); diff --git a/Marlin/src/lcd/fontutils.h b/Marlin/src/lcd/fontutils.h index 28921aef2..8839e36a2 100644 --- a/Marlin/src/lcd/fontutils.h +++ b/Marlin/src/lcd/fontutils.h @@ -8,13 +8,13 @@ */ #pragma once -#include "../HAL/shared/Marduino.h" -#include "../core/macros.h" - #include #include // wchar_t #include // uint32_t +#include "../HAL/shared/Marduino.h" +#include "../core/macros.h" + // read a byte from ROM or RAM typedef uint8_t (*read_byte_cb_t)(uint8_t * str); diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index a764b85bd..79b0e1421 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -420,8 +420,8 @@ void _lcd_ubl_map_homing() { */ void _lcd_ubl_map_lcd_edit_cmd() { char ubl_lcd_gcode[50], str[10], str2[10]; - dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str); - dtostrf(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]), 0, 2, str2); + dtostrf(ubl.mesh_index_to_xpos(x_plot), 0, 2, str); + dtostrf(ubl.mesh_index_to_ypos(y_plot), 0, 2, str2); snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, int(n_edit_pts)); lcd_enqueue_one_now(ubl_lcd_gcode); } diff --git a/Marlin/src/libs/least_squares_fit.h b/Marlin/src/libs/least_squares_fit.h index 164819b21..bfef8b14a 100644 --- a/Marlin/src/libs/least_squares_fit.h +++ b/Marlin/src/libs/least_squares_fit.h @@ -44,11 +44,11 @@ struct linear_fit_data { A, B, D, N; }; -void inline incremental_LSF_reset(struct linear_fit_data *lsf) { +inline void incremental_LSF_reset(struct linear_fit_data *lsf) { memset(lsf, 0, sizeof(linear_fit_data)); } -void inline incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) { +inline void incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) { // weight each accumulator by factor w, including the "number" of samples // (analogous to calling inc_LSF twice with same values to weight it by 2X) const float wx = w * x, wy = w * y, wz = w * z; @@ -66,7 +66,7 @@ void inline incremental_WLSF(struct linear_fit_data *lsf, const float &x, const lsf->max_absy = _MAX(ABS(wy), lsf->max_absy); } -void inline incremental_LSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z) { +inline void incremental_LSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z) { lsf->xbar += x; lsf->ybar += y; lsf->zbar += z; diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 5a8a42d7f..3f9d0e9bd 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -34,6 +34,10 @@ #include "scara.h" #endif +#if HAS_BED_PROBE + #include "probe.h" +#endif + // Axis homed and known-position states extern uint8_t axis_homed, axis_known_position; constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 34ca2871c..f47082263 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -683,7 +683,7 @@ static float run_z_probe() { * - Raise to the BETWEEN height * - Return the probed Z position */ -float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) { +float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) { if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPAIR( ">>> probe_pt(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry), diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index f08a452e5..361952658 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -39,7 +39,7 @@ PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe PROBE_PT_BIG_RAISE // Raise to big clearance after run_z_probe }; - float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true); + float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true); #define DEPLOY_PROBE() set_probe_deployed(true) #define STOW_PROBE() set_probe_deployed(false) #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 6388530af..314747735 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -245,7 +245,7 @@ Temperature thermalManager; int16_t Temperature::maxtemp_raw_CHAMBER = HEATER_CHAMBER_RAW_HI_TEMP; #endif #if WATCH_CHAMBER - heater_watch_t Temperature::watch_chamber = { 0 }; + heater_watch_t Temperature::watch_chamber{0}; #endif millis_t Temperature::next_chamber_check_ms; #endif // HAS_HEATED_CHAMBER @@ -930,7 +930,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) { #if DISABLED(PID_OPENLOOP) - static PID_t work_pid = { 0 }; + static PID_t work_pid{0}; static float temp_iState = 0, temp_dState = 0; static bool pid_reset = true; float pid_output = 0;