Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Marlin/I2CPositionEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
if (errPrstIdx >= I2CPE_ERR_PRST_ARRAY_SIZE) {
float sumP = 0;
LOOP_L_N(i, I2CPE_ERR_PRST_ARRAY_SIZE) sumP += errPrst[i];
const int32_t errorP = int32_t(sumP * (1.0 / (I2CPE_ERR_PRST_ARRAY_SIZE)));
const int32_t errorP = int32_t(sumP * (1.0f / (I2CPE_ERR_PRST_ARRAY_SIZE)));
SERIAL_ECHO(axis_codes[encoderAxis]);
SERIAL_ECHOPAIR(" - err detected: ", errorP * planner.steps_to_mm[encoderAxis]);
SERIAL_ECHOLNPGM("mm; correcting!");
Expand Down
4 changes: 0 additions & 4 deletions Marlin/I2CPositionEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,12 @@
nextErrorCountTime = 0,
lastErrorTime;

//double positionMm; //calculate

#if ENABLED(I2CPE_ERR_ROLLING_AVERAGE)
uint8_t errIdx = 0, errPrstIdx = 0;
int err[I2CPE_ERR_ARRAY_SIZE] = { 0 },
errPrst[I2CPE_ERR_PRST_ARRAY_SIZE] = { 0 };
#endif

//float positionMm; //calculate

public:
void init(const uint8_t address, const AxisEnum axis);
void reset();
Expand Down
34 changes: 11 additions & 23 deletions Marlin/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ inline void reset_stepper_timeout() { previous_move_ms = millis(); }
extern float feedrate_mm_s;
extern int16_t feedrate_percentage;

#define MMS_SCALED(MM_S) ((MM_S)*feedrate_percentage*0.01)
#define MMS_SCALED(MM_S) ((MM_S)*feedrate_percentage*0.01f)

extern bool axis_relative_modes[XYZE];

Expand Down Expand Up @@ -321,22 +321,15 @@ void report_current_position();
void recalc_delta_settings();
float delta_safe_distance_from_top();

#if ENABLED(DELTA_FAST_SQRT)
float Q_rsqrt(const float number);
#define _SQRT(n) (1.0f / Q_rsqrt(n))
#else
#define _SQRT(n) SQRT(n)
#endif

// Macro to obtain the Z position of an individual tower
#define DELTA_Z(V,T) V[Z_AXIS] + _SQRT( \
#define DELTA_Z(V,T) V[Z_AXIS] + SQRT( \
delta_diagonal_rod_2_tower[T] - HYPOT2( \
delta_tower[T][X_AXIS] - V[X_AXIS], \
delta_tower[T][Y_AXIS] - V[Y_AXIS] \
) \
)

#define DELTA_IK(V) do { \
#define DELTA_IK(V) do { \
delta[A_AXIS] = DELTA_Z(V, A_AXIS); \
delta[B_AXIS] = DELTA_Z(V, B_AXIS); \
delta[C_AXIS] = DELTA_Z(V, C_AXIS); \
Expand Down Expand Up @@ -375,11 +368,6 @@ void report_current_position();
void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, const element_2d_fn fn);
#endif

#if ENABLED(AUTO_BED_LEVELING_UBL)
typedef struct { double A, B, D; } linear_fit;
linear_fit* lsf_linear_fit(double x[], double y[], double z[], const int);
#endif

#if HAS_LEVELING
bool leveling_is_valid();
void set_bed_leveling_enabled(const bool enable=true);
Expand Down Expand Up @@ -473,10 +461,10 @@ void prepare_move_to_destination();
/**
* Blocking movement and shorthand functions
*/
void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s=0.0);
void do_blocking_move_to_x(const float &rx, const float &fr_mm_s=0.0);
void do_blocking_move_to_z(const float &rz, const float &fr_mm_s=0.0);
void do_blocking_move_to_xy(const float &rx, const float &ry, const float &fr_mm_s=0.0);
void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s=0);
void do_blocking_move_to_x(const float &rx, const float &fr_mm_s=0);
void do_blocking_move_to_z(const float &rz, const float &fr_mm_s=0);
void do_blocking_move_to_xy(const float &rx, const float &ry, const float &fr_mm_s=0);

#if ENABLED(ARC_SUPPORT)
void plan_arc(const float(&cart)[XYZE], const float(&offset)[2], const bool clockwise);
Expand Down Expand Up @@ -536,8 +524,8 @@ void do_blocking_move_to_xy(const float &rx, const float &ry, const float &fr_mm
// Return true if the given position is within the machine bounds.
inline bool position_is_reachable(const float &rx, const float &ry) {
// Add 0.001 margin to deal with float imprecision
return WITHIN(rx, X_MIN_POS - 0.001, X_MAX_POS + 0.001)
&& WITHIN(ry, Y_MIN_POS - 0.001, Y_MAX_POS + 0.001);
return WITHIN(rx, X_MIN_POS - 0.001f, X_MAX_POS + 0.001f)
&& WITHIN(ry, Y_MIN_POS - 0.001f, Y_MAX_POS + 0.001f);
}

#if HAS_BED_PROBE
Expand All @@ -550,8 +538,8 @@ void do_blocking_move_to_xy(const float &rx, const float &ry, const float &fr_mm
*/
inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
return position_is_reachable(rx - (X_PROBE_OFFSET_FROM_EXTRUDER), ry - (Y_PROBE_OFFSET_FROM_EXTRUDER))
&& WITHIN(rx, MIN_PROBE_X - 0.001, MAX_PROBE_X + 0.001)
&& WITHIN(ry, MIN_PROBE_Y - 0.001, MAX_PROBE_Y + 0.001);
&& WITHIN(rx, MIN_PROBE_X - 0.001f, MAX_PROBE_X + 0.001f)
&& WITHIN(ry, MIN_PROBE_Y - 0.001f, MAX_PROBE_Y + 0.001f);
}
#endif

Expand Down
Loading