Misc changes from struct refactor (#15289)

This commit is contained in:
Scott Lahteine 2019-09-17 18:16:28 -05:00 committed by GitHub
parent c7acd5c45b
commit c353eaa146
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 97 additions and 110 deletions

View file

@ -29,8 +29,8 @@
* DELAY_US(count): Delay execution in microseconds * DELAY_US(count): Delay execution in microseconds
*/ */
#include "../../core/macros.h"
#include "../../core/millis_t.h" #include "../../core/millis_t.h"
#include "../../core/macros.h"
#if defined(__arm__) || defined(__thumb__) #if defined(__arm__) || defined(__thumb__)

View file

@ -61,14 +61,3 @@ enum AxisEnum : unsigned char {
#define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS) #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(VAR) LOOP_S_LE_N(VAR, A_AXIS, E_AXIS)
#define LOOP_ABCE_N(VAR) LOOP_S_L_N(VAR, A_AXIS, XYZE_N) #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;

View file

@ -198,12 +198,22 @@
}while(0) }while(0)
// Macros for initializing arrays // Macros for initializing arrays
#define ARRAY_6(v1, v2, v3, v4, v5, v6, ...) { v1, v2, v3, v4, v5, v6 } #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_5(v1, v2, v3, v4, v5, ...) { v1, v2, v3, v4, v5 } #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_4(v1, v2, v3, v4, ...) { v1, v2, v3, v4 } #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_3(v1, v2, v3, ...) { v1, v2, v3 } #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_2(v1, v2, ...) { v1, v2 } #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_1(v1, ...) { v1 } #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(V)
#define ARRAY_N(N,V...) _ARRAY_N(N,V) #define ARRAY_N(N,V...) _ARRAY_N(N,V)

View file

@ -334,11 +334,10 @@ bool I2CPositionEncoder::test_axis() {
ec = false; ec = false;
LOOP_NA(i) { LOOP_XYZ(i) {
startCoord[i] = planner.get_axis_position_mm((AxisEnum)i); startCoord[i] = planner.get_axis_position_mm((AxisEnum)i);
endCoord[i] = planner.get_axis_position_mm((AxisEnum)i); endCoord[i] = planner.get_axis_position_mm((AxisEnum)i);
} }
startCoord[encoderAxis] = startPosition; startCoord[encoderAxis] = startPosition;
endCoord[encoderAxis] = endPosition; endCoord[encoderAxis] = endPosition;
@ -393,9 +392,9 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) {
endDistance = soft_endstop[encoderAxis].max - 20; endDistance = soft_endstop[encoderAxis].max - 20;
travelDistance = endDistance - startDistance; travelDistance = endDistance - startDistance;
LOOP_NA(i) { LOOP_XYZ(a) {
startCoord[i] = planner.get_axis_position_mm((AxisEnum)i); startCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
endCoord[i] = planner.get_axis_position_mm((AxisEnum)i); endCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
} }
startCoord[encoderAxis] = startDistance; startCoord[encoderAxis] = startDistance;

View file

@ -22,7 +22,6 @@
#pragma once #pragma once
#include "../inc/MarlinConfigPre.h" #include "../inc/MarlinConfigPre.h"
#include "../core/enum.h"
#if IS_CORE || EITHER(BABYSTEP_XY, I2C_POSITION_ENCODERS) #if IS_CORE || EITHER(BABYSTEP_XY, I2C_POSITION_ENCODERS)
#define BS_TODO_AXIS(A) A #define BS_TODO_AXIS(A) A

View file

@ -24,7 +24,6 @@
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
#include "abl.h"
#include "../bedlevel.h" #include "../bedlevel.h"
#include "../../../module/motion.h" #include "../../../module/motion.h"

View file

@ -23,11 +23,6 @@
#include "../../inc/MarlinConfigPre.h" #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) #if ENABLED(PROBE_MANUALLY)
extern bool g29_in_progress; extern bool g29_in_progress;
#else #else
@ -60,7 +55,12 @@ class TemporaryBedLevelingState {
#if HAS_MESH #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) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
#include "abl/abl.h" #include "abl/abl.h"

View file

@ -32,8 +32,8 @@ enum MeshLevelingState : char {
MeshReset // G29 S5 MeshReset // G29 S5
}; };
#define MESH_X_DIST ((MESH_MAX_X - (MESH_MIN_X)) / (GRID_MAX_POINTS_X - 1)) #define MESH_X_DIST (float(MESH_MAX_X - (MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
#define MESH_Y_DIST ((MESH_MAX_Y - (MESH_MIN_Y)) / (GRID_MAX_POINTS_Y - 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_X(I) mbl.index_to_xpos[I]
#define _GET_MESH_Y(J) mbl.index_to_ypos[J] #define _GET_MESH_Y(J) mbl.index_to_ypos[J]
#define Z_VALUES_ARR mbl.z_values #define Z_VALUES_ARR mbl.z_values

View file

@ -24,13 +24,14 @@
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
#include "ubl.h" #include "../bedlevel.h"
unified_bed_leveling ubl; unified_bed_leveling ubl;
#include "../../../module/configuration_store.h" #include "../../../module/configuration_store.h"
#include "../../../module/planner.h" #include "../../../module/planner.h"
#include "../../../module/motion.h" #include "../../../module/motion.h"
#include "../../bedlevel/bedlevel.h" #include "../../../module/probe.h"
#if ENABLED(EXTENSIBLE_UI) #if ENABLED(EXTENSIBLE_UI)
#include "../../../lcd/extensible_ui/ui_api.h" #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]; 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, #define _GRIDPOS(A,N) (MESH_MIN_##A + N * (MESH_##A##_DIST))
// until determinism prevails
constexpr float unified_bed_leveling::_mesh_index_to_xpos[16], const float
unified_bed_leveling::_mesh_index_to_ypos[16]; 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 #if HAS_LCD_MENU
bool unified_bed_leveling::lcd_map_control = false; bool unified_bed_leveling::lcd_map_control = false;

View file

@ -23,11 +23,7 @@
//#define UBL_DEVEL_DEBUGGING //#define UBL_DEVEL_DEBUGGING
#include "../bedlevel.h"
#include "../../../module/planner.h"
#include "../../../module/motion.h" #include "../../../module/motion.h"
#include "../../../lcd/ultralcd.h"
#include "../../../Marlin.h"
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../../core/debug_out.h" #include "../../../core/debug_out.h"
@ -108,31 +104,9 @@ class unified_bed_leveling {
static int8_t storage_slot; static int8_t storage_slot;
static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; static bed_mesh_t z_values;
static const float _mesh_index_to_xpos[GRID_MAX_POINTS_X],
// 15 is the maximum nubmer of grid points supported + 1 safety margin for now, _mesh_index_to_ypos[GRID_MAX_POINTS_Y];
// 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)
};
#if HAS_LCD_MENU #if HAS_LCD_MENU
static bool lcd_map_control; static bool lcd_map_control;

View file

@ -24,7 +24,7 @@
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
#include "ubl.h" #include "../bedlevel.h"
#include "../../../Marlin.h" #include "../../../Marlin.h"
#include "../../../HAL/shared/persistent_store_api.h" #include "../../../HAL/shared/persistent_store_api.h"
@ -33,11 +33,9 @@
#include "../../../lcd/ultralcd.h" #include "../../../lcd/ultralcd.h"
#include "../../../module/stepper.h" #include "../../../module/stepper.h"
#include "../../../module/planner.h" #include "../../../module/planner.h"
#include "../../../module/motion.h"
#include "../../../module/probe.h" #include "../../../module/probe.h"
#include "../../../gcode/gcode.h" #include "../../../gcode/gcode.h"
#include "../../../core/serial.h"
#include "../../../gcode/parser.h"
#include "../../../feature/bedlevel/bedlevel.h"
#include "../../../libs/least_squares_fit.h" #include "../../../libs/least_squares_fit.h"
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
@ -783,7 +781,7 @@
if (location.x_index >= 0) { // mesh point found and is reachable by probe if (location.x_index >= 0) { // mesh point found and is reachable by probe
const float rawx = mesh_index_to_xpos(location.x_index), const float rawx = mesh_index_to_xpos(location.x_index),
rawy = mesh_index_to_ypos(location.y_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; z_values[location.x_index][location.y_index] = measured_z;
#if ENABLED(EXTENSIBLE_UI) #if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(location.x_index, location.y_index, measured_z); 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")); ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 1/3"));
#endif #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)) if (isnan(measured_z))
abort_flag = true; abort_flag = true;
else { else {
@ -1429,7 +1427,7 @@
ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 2/3")); ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 2/3"));
#endif #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; //z2 = measured_z;
if (isnan(measured_z)) if (isnan(measured_z))
abort_flag = true; abort_flag = true;
@ -1449,7 +1447,7 @@
ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 3/3")); ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " 3/3"));
#endif #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; //z3 = measured_z;
if (isnan(measured_z)) if (isnan(measured_z))
abort_flag = true; abort_flag = true;
@ -1490,7 +1488,7 @@
ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " %i/%i"), point_num, total_points); ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " %i/%i"), point_num, total_points);
#endif #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); abort_flag = isnan(measured_z);

View file

@ -24,7 +24,6 @@
#if BOTH(DIGIPOT_I2C, DIGIPOT_MCP4018) #if BOTH(DIGIPOT_I2C, DIGIPOT_MCP4018)
#include "../../core/enum.h"
#include "Stream.h" #include "Stream.h"
#include "utility/twi.h" #include "utility/twi.h"
#include <SlowSoftI2CMaster.h> //https://github.com/stawel/SlowSoftI2CMaster #include <SlowSoftI2CMaster.h> //https://github.com/stawel/SlowSoftI2CMaster

View file

@ -23,8 +23,6 @@
#include "../inc/MarlinConfigPre.h" #include "../inc/MarlinConfigPre.h"
#include <stddef.h>
void host_action(const char * const pstr, const bool eol=true); void host_action(const char * const pstr, const bool eol=true);
#ifdef ACTION_ON_KILL #ifdef ACTION_ON_KILL

View file

@ -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)); ui.status_printf_P(0, PSTR(MSG_PROBING_MESH " %i/%i"), int(pt_index), int(GRID_MAX_POINTS));
#endif #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)) { if (isnan(measured_z)) {
set_bed_leveling_enabled(abl_should_enable); set_bed_leveling_enabled(abl_should_enable);
@ -759,7 +759,7 @@ G29_TYPE GcodeSuite::G29() {
// Retain the last probe position // Retain the last probe position
xProbe = points[i].x; xProbe = points[i].x;
yProbe = points[i].y; 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)) { if (isnan(measured_z)) {
set_bed_leveling_enabled(abl_should_enable); set_bed_leveling_enabled(abl_should_enable);
break; break;

View file

@ -29,7 +29,7 @@
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
#include "../../gcode.h" #include "../../gcode.h"
#include "../../../feature/bedlevel/abl/abl.h" #include "../../../feature/bedlevel/bedlevel.h"
#if ENABLED(EXTENSIBLE_UI) #if ENABLED(EXTENSIBLE_UI)
#include "../../../lcd/extensible_ui/ui_api.h" #include "../../../lcd/extensible_ui/ui_api.h"

View file

@ -29,7 +29,7 @@
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
#include "../../gcode.h" #include "../../gcode.h"
#include "../../../feature/bedlevel/ubl/ubl.h" #include "../../../feature/bedlevel/bedlevel.h"
void GcodeSuite::G29() { ubl.G29(); } void GcodeSuite::G29() { ubl.G29(); }

View file

@ -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) { static float calibration_probe(const float &nx, const float &ny, const bool stow) {
#if HAS_BED_PROBE #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 #else
UNUSED(stow); UNUSED(stow);
return lcd_probe_pt(nx, ny); return lcd_probe_pt(nx, ny);

View file

@ -162,7 +162,7 @@ void GcodeSuite::G34() {
if (iteration == 0 || izstepper > 0) do_blocking_move_to_z(z_probe); if (iteration == 0 || izstepper > 0) do_blocking_move_to_z(z_probe);
// Probe a Z height for each stepper. // 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)) { if (isnan(z_probed_height)) {
SERIAL_ECHOLNPGM("Probing failed."); SERIAL_ECHOLNPGM("Probing failed.");
err_break = true; err_break = true;

View file

@ -116,7 +116,7 @@ void GcodeSuite::M48() {
float mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples]; 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 // 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); bool probing_good = !isnan(t);
if (probing_good) { if (probing_good) {
@ -190,7 +190,7 @@ void GcodeSuite::M48() {
} // n_legs } // n_legs
// Probe a single point // 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 // Break the loop if the probe fails
probing_good = !isnan(sample_set[n]); probing_good = !isnan(sample_set[n]);

View file

@ -34,6 +34,14 @@
#include "../libs/hex_print_routines.h" #include "../libs/hex_print_routines.h"
#endif #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 * GCode parser
* *
@ -254,7 +262,6 @@ public:
// Units modes: Inches, Fahrenheit, Kelvin // Units modes: Inches, Fahrenheit, Kelvin
#if ENABLED(INCH_MODE_SUPPORT) #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_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); } 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) #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) #if HAS_LCD_MENU && DISABLED(DISABLE_M503)

View file

@ -52,7 +52,7 @@ void GcodeSuite::G30() {
setup_for_endstop_or_probe_move(); setup_for_endstop_or_probe_move();
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; 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)) if (!isnan(measured_z))
SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(xpos), " Y: ", FIXFLOAT(ypos), " Z: ", FIXFLOAT(measured_z)); SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(xpos), " Y: ", FIXFLOAT(ypos), " Z: ", FIXFLOAT(measured_z));

View file

@ -28,6 +28,7 @@
// //
// Prefix header to acquire configurations // Prefix header to acquire configurations
// //
#include <stdint.h>
#include "../HAL/platforms.h" #include "../HAL/platforms.h"
@ -45,5 +46,3 @@
#include "Conditionals_adv.h" #include "Conditionals_adv.h"
#include HAL_PATH(../HAL, inc/Conditionals_adv.h) #include HAL_PATH(../HAL, inc/Conditionals_adv.h)
#include <stdint.h>

View file

@ -47,7 +47,7 @@
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
#include "../../feature/bedlevel/ubl/ubl.h" #include "../../feature/bedlevel/bedlevel.h"
#endif #endif
// //

View file

@ -60,7 +60,7 @@
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
#include "../../feature/bedlevel/ubl/ubl.h" #include "../../feature/bedlevel/bedlevel.h"
#endif #endif
/** /**

View file

@ -809,7 +809,7 @@ namespace ExtUI {
void setLevelingActive(const bool state) { set_bed_leveling_enabled(state); } void setLevelingActive(const bool state) { set_bed_leveling_enabled(state); }
bool getMeshValid() { return leveling_is_valid(); } bool getMeshValid() { return leveling_is_valid(); }
#if HAS_MESH #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); } 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) { 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)) { if (WITHIN(xpos, 0, GRID_MAX_POINTS_X) && WITHIN(ypos, 0, GRID_MAX_POINTS_Y)) {

View file

@ -61,7 +61,7 @@ namespace ExtUI {
constexpr uint8_t fanCount = FAN_COUNT; constexpr uint8_t fanCount = FAN_COUNT;
#if HAS_MESH #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 #endif
bool isMoving(); bool isMoving();
@ -128,7 +128,7 @@ namespace ExtUI {
void setLevelingActive(const bool); void setLevelingActive(const bool);
bool getMeshValid(); bool getMeshValid();
#if HAS_MESH #if HAS_MESH
bed_mesh_t getMeshArray(); bed_mesh_t& getMeshArray();
float getMeshPoint(const uint8_t xpos, const uint8_t ypos); float getMeshPoint(const uint8_t xpos, const uint8_t ypos);
void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zval); 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); void onMeshUpdate(const uint8_t xpos, const uint8_t ypos, const float zval);

View file

@ -8,13 +8,13 @@
*/ */
#pragma once #pragma once
#include "../HAL/shared/Marduino.h"
#include "../core/macros.h"
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> // wchar_t #include <stddef.h> // wchar_t
#include <stdint.h> // uint32_t #include <stdint.h> // uint32_t
#include "../HAL/shared/Marduino.h"
#include "../core/macros.h"
// read a byte from ROM or RAM // read a byte from ROM or RAM
typedef uint8_t (*read_byte_cb_t)(uint8_t * str); typedef uint8_t (*read_byte_cb_t)(uint8_t * str);

View file

@ -420,8 +420,8 @@ void _lcd_ubl_map_homing() {
*/ */
void _lcd_ubl_map_lcd_edit_cmd() { void _lcd_ubl_map_lcd_edit_cmd() {
char ubl_lcd_gcode[50], str[10], str2[10]; char ubl_lcd_gcode[50], str[10], str2[10];
dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str); dtostrf(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_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)); 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); lcd_enqueue_one_now(ubl_lcd_gcode);
} }

View file

@ -44,11 +44,11 @@ struct linear_fit_data {
A, B, D, N; 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)); 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 // 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) // (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; 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); 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->xbar += x;
lsf->ybar += y; lsf->ybar += y;
lsf->zbar += z; lsf->zbar += z;

View file

@ -34,6 +34,10 @@
#include "scara.h" #include "scara.h"
#endif #endif
#if HAS_BED_PROBE
#include "probe.h"
#endif
// Axis homed and known-position states // Axis homed and known-position states
extern uint8_t axis_homed, axis_known_position; extern uint8_t axis_homed, axis_known_position;
constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS); constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);

View file

@ -683,7 +683,7 @@ static float run_z_probe() {
* - 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 &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)) { if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPAIR( DEBUG_ECHOLNPAIR(
">>> probe_pt(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry), ">>> probe_pt(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry),

View file

@ -39,7 +39,7 @@
PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe
PROBE_PT_BIG_RAISE // Raise to big 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 DEPLOY_PROBE() set_probe_deployed(true)
#define STOW_PROBE() set_probe_deployed(false) #define STOW_PROBE() set_probe_deployed(false)
#if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)

View file

@ -245,7 +245,7 @@ Temperature thermalManager;
int16_t Temperature::maxtemp_raw_CHAMBER = HEATER_CHAMBER_RAW_HI_TEMP; int16_t Temperature::maxtemp_raw_CHAMBER = HEATER_CHAMBER_RAW_HI_TEMP;
#endif #endif
#if WATCH_CHAMBER #if WATCH_CHAMBER
heater_watch_t Temperature::watch_chamber = { 0 }; heater_watch_t Temperature::watch_chamber{0};
#endif #endif
millis_t Temperature::next_chamber_check_ms; millis_t Temperature::next_chamber_check_ms;
#endif // HAS_HEATED_CHAMBER #endif // HAS_HEATED_CHAMBER
@ -930,7 +930,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) {
#if DISABLED(PID_OPENLOOP) #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 float temp_iState = 0, temp_dState = 0;
static bool pid_reset = true; static bool pid_reset = true;
float pid_output = 0; float pid_output = 0;