Float maths updates for 2.0.x parity (#11213)
Co-Authored-By: ejtagle <ejtagle@hotmail.com>
This commit is contained in:
parent
fc9f4ce2c0
commit
ccb225f43a
25 changed files with 317 additions and 353 deletions
|
@ -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!");
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
@ -321,15 +321,8 @@ 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] \
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -378,7 +378,7 @@ uint8_t marlin_debug_flags = DEBUG_NONE;
|
|||
* Used by 'buffer_line_to_current_position' to do a move after changing it.
|
||||
* Used by 'SYNC_PLAN_POSITION_KINEMATIC' to update 'planner.position'.
|
||||
*/
|
||||
float current_position[XYZE] = { 0.0 };
|
||||
float current_position[XYZE] = { 0 };
|
||||
|
||||
/**
|
||||
* Cartesian Destination
|
||||
|
@ -386,7 +386,7 @@ float current_position[XYZE] = { 0.0 };
|
|||
* and expected by functions like 'prepare_move_to_destination'.
|
||||
* Set with 'gcode_get_destination' or 'set_destination_from_current'.
|
||||
*/
|
||||
float destination[XYZE] = { 0.0 };
|
||||
float destination[XYZE] = { 0 };
|
||||
|
||||
/**
|
||||
* axis_homed
|
||||
|
@ -446,7 +446,7 @@ static const float homing_feedrate_mm_s[] PROGMEM = {
|
|||
};
|
||||
FORCE_INLINE float homing_feedrate(const AxisEnum a) { return pgm_read_float(&homing_feedrate_mm_s[a]); }
|
||||
|
||||
float feedrate_mm_s = MMM_TO_MMS(1500.0);
|
||||
float feedrate_mm_s = MMM_TO_MMS(1500.0f);
|
||||
static float saved_feedrate_mm_s;
|
||||
int16_t feedrate_percentage = 100, saved_feedrate_percentage;
|
||||
|
||||
|
@ -1571,7 +1571,7 @@ inline void buffer_line_to_destination(const float &fr_mm_s) {
|
|||
/**
|
||||
* Calculate delta, start a line, and set current_position to destination
|
||||
*/
|
||||
void prepare_uninterpolated_move_to_destination(const float fr_mm_s=0.0) {
|
||||
void prepare_uninterpolated_move_to_destination(const float fr_mm_s=0) {
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
|
||||
#endif
|
||||
|
@ -2335,7 +2335,7 @@ void clean_up_after_endstop_or_probe_move() {
|
|||
#if MULTIPLE_PROBING > 2
|
||||
|
||||
// Return the average value of all probes
|
||||
const float measured_z = probes_total * (1.0 / (MULTIPLE_PROBING));
|
||||
const float measured_z = probes_total * (1.0f / (MULTIPLE_PROBING));
|
||||
|
||||
#elif MULTIPLE_PROBING == 2
|
||||
|
||||
|
@ -2931,7 +2931,7 @@ void clean_up_after_endstop_or_probe_move() {
|
|||
/**
|
||||
* Home an individual linear axis
|
||||
*/
|
||||
static void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm_s=0.0) {
|
||||
static void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm_s=0) {
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
|
@ -3095,7 +3095,7 @@ static void homeaxis(const AxisEnum axis) {
|
|||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Home 1 Fast:");
|
||||
#endif
|
||||
do_homing_move(axis, 1.5 * max_length(axis) * axis_home_dir);
|
||||
do_homing_move(axis, 1.5f * max_length(axis) * axis_home_dir);
|
||||
|
||||
// When homing Z with probe respect probe clearance
|
||||
const float bump = axis_home_dir * (
|
||||
|
@ -3276,7 +3276,7 @@ void gcode_get_destination() {
|
|||
destination[i] = current_position[i];
|
||||
}
|
||||
|
||||
if (parser.linearval('F') > 0.0)
|
||||
if (parser.linearval('F') > 0)
|
||||
feedrate_mm_s = MMM_TO_MMS(parser.value_feedrate());
|
||||
|
||||
#if ENABLED(PRINTCOUNTER)
|
||||
|
@ -3426,7 +3426,7 @@ inline void gcode_G0_G1(
|
|||
relative_mode = relative_mode_backup;
|
||||
#endif
|
||||
|
||||
float arc_offset[2] = { 0.0, 0.0 };
|
||||
float arc_offset[2] = { 0, 0 };
|
||||
if (parser.seenval('R')) {
|
||||
const float r = parser.value_linear_units(),
|
||||
p1 = current_position[X_AXIS], q1 = current_position[Y_AXIS],
|
||||
|
@ -3435,8 +3435,8 @@ inline void gcode_G0_G1(
|
|||
const float e = clockwise ^ (r < 0) ? -1 : 1, // clockwise -1/1, counterclockwise 1/-1
|
||||
dx = p2 - p1, dy = q2 - q1, // X and Y differences
|
||||
d = HYPOT(dx, dy), // Linear distance between the points
|
||||
h = SQRT(sq(r) - sq(d * 0.5)), // Distance to the arc pivot-point
|
||||
mx = (p1 + p2) * 0.5, my = (q1 + q2) * 0.5, // Point between the two points
|
||||
h = SQRT(sq(r) - sq(d * 0.5f)), // Distance to the arc pivot-point
|
||||
mx = (p1 + p2) * 0.5f, my = (q1 + q2) * 0.5f, // Point between the two points
|
||||
sx = -dy / d, sy = dx / d, // Slope of the perpendicular bisector
|
||||
cx = mx + e * h * sx, cy = my + e * h * sy; // Pivot-point of the arc
|
||||
arc_offset[0] = cx - p1;
|
||||
|
@ -4737,8 +4737,8 @@ void home_all_axes() { gcode_G28(true); }
|
|||
|
||||
if (!isnan(rx) && !isnan(ry)) {
|
||||
// Get nearest i / j from rx / ry
|
||||
i = (rx - bilinear_start[X_AXIS] + 0.5 * xGridSpacing) / xGridSpacing;
|
||||
j = (ry - bilinear_start[Y_AXIS] + 0.5 * yGridSpacing) / yGridSpacing;
|
||||
i = (rx - bilinear_start[X_AXIS] + 0.5f * xGridSpacing) / xGridSpacing;
|
||||
j = (ry - bilinear_start[Y_AXIS] + 0.5f * yGridSpacing) / yGridSpacing;
|
||||
i = constrain(i, 0, GRID_MAX_POINTS_X - 1);
|
||||
j = constrain(j, 0, GRID_MAX_POINTS_Y - 1);
|
||||
}
|
||||
|
@ -5631,7 +5631,7 @@ void home_all_axes() { gcode_G28(true); }
|
|||
S2 += sq(z_pt[rad]);
|
||||
N++;
|
||||
}
|
||||
return round(SQRT(S2 / N) * 1000.0) / 1000.0 + 0.00001;
|
||||
return LROUND(SQRT(S2 / N) * 1000.0) / 1000.0 + 0.00001;
|
||||
}
|
||||
}
|
||||
return 0.00001;
|
||||
|
@ -5723,8 +5723,8 @@ void home_all_axes() { gcode_G28(true); }
|
|||
const float z_temp = calibration_probe(cos(a) * r, sin(a) * r, stow_after_each, set_up);
|
||||
if (isnan(z_temp)) return false;
|
||||
// split probe point to neighbouring calibration points
|
||||
z_pt[uint8_t(round(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
|
||||
z_pt[uint8_t(round(rad - interpol)) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
|
||||
z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
|
||||
z_pt[uint8_t(LROUND(rad - interpol)) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
|
||||
}
|
||||
zig_zag = !zig_zag;
|
||||
}
|
||||
|
@ -5805,7 +5805,7 @@ void home_all_axes() { gcode_G28(true); }
|
|||
float h_fac = 0.0;
|
||||
|
||||
h_fac = r_quot / (2.0 / 3.0);
|
||||
h_fac = 1.0 / h_fac; // (2/3)/CR
|
||||
h_fac = 1.0f / h_fac; // (2/3)/CR
|
||||
return h_fac;
|
||||
}
|
||||
|
||||
|
@ -6126,9 +6126,9 @@ void home_all_axes() { gcode_G28(true); }
|
|||
char mess[21];
|
||||
strcpy_P(mess, PSTR("Calibration sd:"));
|
||||
if (zero_std_dev_min < 1)
|
||||
sprintf_P(&mess[15], PSTR("0.%03i"), (int)round(zero_std_dev_min * 1000.0));
|
||||
sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev_min * 1000.0));
|
||||
else
|
||||
sprintf_P(&mess[15], PSTR("%03i.x"), (int)round(zero_std_dev_min));
|
||||
sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev_min));
|
||||
lcd_setstatus(mess);
|
||||
print_calibration_settings(_endstop_results, _angle_results);
|
||||
serialprintPGM(save_message);
|
||||
|
@ -6162,9 +6162,9 @@ void home_all_axes() { gcode_G28(true); }
|
|||
strcpy_P(mess, enddryrun);
|
||||
strcpy_P(&mess[11], PSTR(" sd:"));
|
||||
if (zero_std_dev < 1)
|
||||
sprintf_P(&mess[15], PSTR("0.%03i"), (int)round(zero_std_dev * 1000.0));
|
||||
sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev * 1000.0));
|
||||
else
|
||||
sprintf_P(&mess[15], PSTR("%03i.x"), (int)round(zero_std_dev));
|
||||
sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev));
|
||||
lcd_setstatus(mess);
|
||||
}
|
||||
ac_home();
|
||||
|
@ -6531,12 +6531,12 @@ inline void gcode_G92() {
|
|||
delay_for_power_down();
|
||||
}
|
||||
else {
|
||||
int16_t ocr_val = (spindle_laser_power - (SPEED_POWER_INTERCEPT)) * (1.0 / (SPEED_POWER_SLOPE)); // convert RPM to PWM duty cycle
|
||||
int16_t ocr_val = (spindle_laser_power - (SPEED_POWER_INTERCEPT)) * (1.0f / (SPEED_POWER_SLOPE)); // convert RPM to PWM duty cycle
|
||||
NOMORE(ocr_val, 255); // limit to max the Atmel PWM will support
|
||||
if (spindle_laser_power <= SPEED_POWER_MIN)
|
||||
ocr_val = (SPEED_POWER_MIN - (SPEED_POWER_INTERCEPT)) * (1.0 / (SPEED_POWER_SLOPE)); // minimum setting
|
||||
ocr_val = (SPEED_POWER_MIN - (SPEED_POWER_INTERCEPT)) * (1.0f / (SPEED_POWER_SLOPE)); // minimum setting
|
||||
if (spindle_laser_power >= SPEED_POWER_MAX)
|
||||
ocr_val = (SPEED_POWER_MAX - (SPEED_POWER_INTERCEPT)) * (1.0 / (SPEED_POWER_SLOPE)); // limit to max RPM
|
||||
ocr_val = (SPEED_POWER_MAX - (SPEED_POWER_INTERCEPT)) * (1.0f / (SPEED_POWER_SLOPE)); // limit to max RPM
|
||||
if (SPINDLE_LASER_PWM_INVERT) ocr_val = 255 - ocr_val;
|
||||
WRITE(SPINDLE_LASER_ENABLE_PIN, SPINDLE_LASER_ENABLE_INVERT); // turn spindle on (active low)
|
||||
analogWrite(SPINDLE_LASER_PWM_PIN, ocr_val & 0xFF); // only write low byte
|
||||
|
@ -7685,7 +7685,7 @@ inline void gcode_M42() {
|
|||
|
||||
setup_for_endstop_or_probe_move();
|
||||
|
||||
double 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
|
||||
const float t = probe_pt(X_probe_location, Y_probe_location, raise_after, verbose_level);
|
||||
|
@ -7716,7 +7716,7 @@ inline void gcode_M42() {
|
|||
}
|
||||
|
||||
for (uint8_t l = 0; l < n_legs - 1; l++) {
|
||||
double delta_angle;
|
||||
float delta_angle;
|
||||
|
||||
if (schizoid_flag)
|
||||
// The points of a 5 point star are 72 degrees apart. We need to
|
||||
|
@ -7773,7 +7773,7 @@ inline void gcode_M42() {
|
|||
/**
|
||||
* Get the current mean for the data points we have so far
|
||||
*/
|
||||
double sum = 0.0;
|
||||
float sum = 0.0;
|
||||
for (uint8_t j = 0; j <= n; j++) sum += sample_set[j];
|
||||
mean = sum / (n + 1);
|
||||
|
||||
|
@ -8123,7 +8123,7 @@ inline void gcode_M109() {
|
|||
#define TEMP_CONDITIONS (wants_to_cool ? thermalManager.isCoolingHotend(target_extruder) : thermalManager.isHeatingHotend(target_extruder))
|
||||
#endif
|
||||
|
||||
float target_temp = -1.0, old_temp = 9999.0;
|
||||
float target_temp = -1, old_temp = 9999;
|
||||
bool wants_to_cool = false;
|
||||
wait_for_heatup = true;
|
||||
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
||||
|
@ -8202,7 +8202,7 @@ inline void gcode_M109() {
|
|||
// break after MIN_COOLING_SLOPE_TIME seconds
|
||||
// if the temperature did not drop at least MIN_COOLING_SLOPE_DEG
|
||||
if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
|
||||
if (old_temp - temp < MIN_COOLING_SLOPE_DEG) break;
|
||||
if (old_temp - temp < float(MIN_COOLING_SLOPE_DEG)) break;
|
||||
next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME;
|
||||
old_temp = temp;
|
||||
}
|
||||
|
@ -8348,7 +8348,7 @@ inline void gcode_M109() {
|
|||
// Break after MIN_COOLING_SLOPE_TIME_BED seconds
|
||||
// if the temperature did not drop at least MIN_COOLING_SLOPE_DEG_BED
|
||||
if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
|
||||
if (old_temp - temp < MIN_COOLING_SLOPE_DEG_BED) break;
|
||||
if (old_temp - temp < float(MIN_COOLING_SLOPE_DEG_BED)) break;
|
||||
next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME_BED;
|
||||
old_temp = temp;
|
||||
}
|
||||
|
@ -8659,7 +8659,7 @@ inline void gcode_M92() {
|
|||
if (parser.seen(axis_codes[i])) {
|
||||
if (i == E_AXIS) {
|
||||
const float value = parser.value_per_axis_unit((AxisEnum)(E_AXIS + TARGET_EXTRUDER));
|
||||
if (value < 20.0) {
|
||||
if (value < 20) {
|
||||
float factor = planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
|
||||
#if DISABLED(JUNCTION_DEVIATION)
|
||||
planner.max_jerk[E_AXIS] *= factor;
|
||||
|
@ -9077,7 +9077,7 @@ inline void gcode_M121() { endstops.enable_globally(false); }
|
|||
// setting any extruder filament size disables volumetric on the assumption that
|
||||
// slicers either generate in extruder values as cubic mm or as as filament feeds
|
||||
// for all extruders
|
||||
if ( (parser.volumetric_enabled = (parser.value_linear_units() != 0.0)) )
|
||||
if ( (parser.volumetric_enabled = (parser.value_linear_units() != 0)) )
|
||||
planner.set_filament_size(target_extruder, parser.value_linear_units());
|
||||
}
|
||||
planner.calculate_volumetric_multipliers();
|
||||
|
@ -9180,7 +9180,7 @@ inline void gcode_M205() {
|
|||
#if ENABLED(JUNCTION_DEVIATION)
|
||||
if (parser.seen('J')) {
|
||||
const float junc_dev = parser.value_linear_units();
|
||||
if (WITHIN(junc_dev, 0.01, 0.3)) {
|
||||
if (WITHIN(junc_dev, 0.01f, 0.3f)) {
|
||||
planner.junction_deviation_mm = junc_dev;
|
||||
planner.recalculate_max_e_jerk();
|
||||
}
|
||||
|
@ -9195,7 +9195,7 @@ inline void gcode_M205() {
|
|||
if (parser.seen('Z')) {
|
||||
planner.max_jerk[Z_AXIS] = parser.value_linear_units();
|
||||
#if HAS_MESH
|
||||
if (planner.max_jerk[Z_AXIS] <= 0.1)
|
||||
if (planner.max_jerk[Z_AXIS] <= 0.1f)
|
||||
SERIAL_ECHOLNPGM("WARNING! Low Z Jerk may lead to unwanted pauses.");
|
||||
#endif
|
||||
}
|
||||
|
@ -12861,27 +12861,6 @@ void ok_to_send() {
|
|||
axis_homed = 0;
|
||||
}
|
||||
|
||||
#if ENABLED(DELTA_FAST_SQRT)
|
||||
/**
|
||||
* Fast inverse sqrt from Quake III Arena
|
||||
* See: https://en.wikipedia.org/wiki/Fast_inverse_square_root
|
||||
*/
|
||||
float Q_rsqrt(const float number) {
|
||||
long i;
|
||||
float x2, y;
|
||||
const float threehalfs = 1.5f;
|
||||
x2 = number * 0.5f;
|
||||
y = number;
|
||||
i = * ( long * ) &y; // evil floating point bit level hacking
|
||||
i = 0x5F3759DF - ( i >> 1 ); // what the f***?
|
||||
y = * ( float * ) &i;
|
||||
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
|
||||
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
|
||||
return y;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Delta Inverse Kinematics
|
||||
*
|
||||
|
@ -12896,9 +12875,6 @@ void ok_to_send() {
|
|||
*
|
||||
* - Disable the home_offset (M206) and/or position_shift (G92)
|
||||
* features to remove up to 12 float additions.
|
||||
*
|
||||
* - Use a fast-inverse-sqrt function and add the reciprocal.
|
||||
* (see above)
|
||||
*/
|
||||
|
||||
#define DELTA_DEBUG(VAR) do { \
|
||||
|
@ -12964,7 +12940,7 @@ void ok_to_send() {
|
|||
*
|
||||
* The result is stored in the cartes[] array.
|
||||
*/
|
||||
void forward_kinematics_DELTA(float z1, float z2, float z3) {
|
||||
void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3) {
|
||||
// Create a vector in old coordinates along x axis of new coordinate
|
||||
const float p12[] = {
|
||||
delta_tower[B_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS],
|
||||
|
@ -12972,11 +12948,11 @@ void ok_to_send() {
|
|||
z2 - z1
|
||||
},
|
||||
|
||||
// Get the Magnitude of vector.
|
||||
d = SQRT(sq(p12[0]) + sq(p12[1]) + sq(p12[2])),
|
||||
// Get the reciprocal of Magnitude of vector.
|
||||
d2 = sq(p12[0]) + sq(p12[1]) + sq(p12[2]), inv_d = RSQRT(d2),
|
||||
|
||||
// Create unit vector by dividing by magnitude.
|
||||
ex[3] = { p12[0] / d, p12[1] / d, p12[2] / d },
|
||||
// Create unit vector by multiplying by the inverse of the magnitude.
|
||||
ex[3] = { p12[0] * inv_d, p12[1] * inv_d, p12[2] * inv_d },
|
||||
|
||||
// Get the vector from the origin of the new system to the third point.
|
||||
p13[3] = {
|
||||
|
@ -12995,11 +12971,11 @@ void ok_to_send() {
|
|||
// variable that will be the unit vector after we scale it.
|
||||
float ey[3] = { p13[0] - iex[0], p13[1] - iex[1], p13[2] - iex[2] };
|
||||
|
||||
// The magnitude of Y component
|
||||
const float j = SQRT(sq(ey[0]) + sq(ey[1]) + sq(ey[2]));
|
||||
// The magnitude and the inverse of the magnitude of Y component
|
||||
const float j2 = sq(ey[0]) + sq(ey[1]) + sq(ey[2]), inv_j = RSQRT(j2);
|
||||
|
||||
// Convert to a unit vector
|
||||
ey[0] /= j; ey[1] /= j; ey[2] /= j;
|
||||
ey[0] *= inv_j; ey[1] *= inv_j; ey[2] *= inv_j;
|
||||
|
||||
// The cross product of the unit x and y is the unit z
|
||||
// float[] ez = vectorCrossProd(ex, ey);
|
||||
|
@ -13010,8 +12986,8 @@ void ok_to_send() {
|
|||
},
|
||||
// We now have the d, i and j values defined in Wikipedia.
|
||||
// Plug them into the equations defined in Wikipedia for Xnew, Ynew and Znew
|
||||
Xnew = (delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[B_AXIS] + sq(d)) / (d * 2),
|
||||
Ynew = ((delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[C_AXIS] + HYPOT2(i, j)) / 2 - i * Xnew) / j,
|
||||
Xnew = (delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[B_AXIS] + d2) * inv_d * 0.5,
|
||||
Ynew = ((delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[C_AXIS] + sq(i) + j2) * 0.5 - i * Xnew) * inv_j,
|
||||
Znew = SQRT(delta_diagonal_rod_2_tower[A_AXIS] - HYPOT2(Xnew, Ynew));
|
||||
|
||||
// Start from the origin of the old coordinates and add vectors in the
|
||||
|
@ -13022,7 +12998,7 @@ void ok_to_send() {
|
|||
cartes[Z_AXIS] = z1 + ex[2] * Xnew + ey[2] * Ynew - ez[2] * Znew;
|
||||
}
|
||||
|
||||
void forward_kinematics_DELTA(float point[ABC]) {
|
||||
void forward_kinematics_DELTA(const float (&point)[ABC]) {
|
||||
forward_kinematics_DELTA(point[A_AXIS], point[B_AXIS], point[C_AXIS]);
|
||||
}
|
||||
|
||||
|
@ -13118,7 +13094,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|||
NOLESS(segments, 1);
|
||||
|
||||
// The approximate length of each segment
|
||||
const float inv_segments = 1.0 / float(segments),
|
||||
const float inv_segments = 1.0f / float(segments),
|
||||
cartesian_segment_mm = cartesian_mm * inv_segments,
|
||||
segment_distance[XYZE] = {
|
||||
xdiff * inv_segments,
|
||||
|
@ -13304,7 +13280,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|||
* but may produce jagged lines. Try 0.5mm, 1.0mm, and 2.0mm
|
||||
* and compare the difference.
|
||||
*/
|
||||
#define SCARA_MIN_SEGMENT_LENGTH 0.5
|
||||
#define SCARA_MIN_SEGMENT_LENGTH 0.5f
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -13353,14 +13329,14 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|||
|
||||
// For SCARA enforce a minimum segment size
|
||||
#if IS_SCARA
|
||||
NOMORE(segments, cartesian_mm * (1.0 / SCARA_MIN_SEGMENT_LENGTH));
|
||||
NOMORE(segments, cartesian_mm * (1.0f / float(SCARA_MIN_SEGMENT_LENGTH)));
|
||||
#endif
|
||||
|
||||
// At least one segment is required
|
||||
NOLESS(segments, 1);
|
||||
|
||||
// The approximate length of each segment
|
||||
const float inv_segments = 1.0 / float(segments),
|
||||
const float inv_segments = 1.0f / float(segments),
|
||||
segment_distance[XYZE] = {
|
||||
xdiff * inv_segments,
|
||||
ydiff * inv_segments,
|
||||
|
@ -13386,7 +13362,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|||
// SCARA needs to scale the feed rate from mm/s to degrees/s
|
||||
// i.e., Complete the angular vector in the given time.
|
||||
const float segment_length = cartesian_mm * inv_segments,
|
||||
inv_segment_length = 1.0 / segment_length, // 1/mm/segs
|
||||
inv_segment_length = 1.0f / segment_length, // 1/mm/segs
|
||||
inverse_secs = inv_segment_length * _feedrate_mm_s;
|
||||
|
||||
float oldA = planner.position_float[A_AXIS],
|
||||
|
@ -13729,7 +13705,7 @@ void prepare_move_to_destination() {
|
|||
|
||||
const float flat_mm = radius * angular_travel,
|
||||
mm_of_travel = linear_travel ? HYPOT(flat_mm, linear_travel) : ABS(flat_mm);
|
||||
if (mm_of_travel < 0.001) return;
|
||||
if (mm_of_travel < 0.001f) return;
|
||||
|
||||
uint16_t segments = FLOOR(mm_of_travel / (MM_PER_ARC_SEGMENT));
|
||||
NOLESS(segments, 1);
|
||||
|
@ -13766,7 +13742,7 @@ void prepare_move_to_destination() {
|
|||
linear_per_segment = linear_travel / segments,
|
||||
extruder_per_segment = extruder_travel / segments,
|
||||
sin_T = theta_per_segment,
|
||||
cos_T = 1 - 0.5 * sq(theta_per_segment); // Small angle approximation
|
||||
cos_T = 1 - 0.5f * sq(theta_per_segment); // Small angle approximation
|
||||
|
||||
// Initialize the linear axis
|
||||
raw[l_axis] = current_position[l_axis];
|
||||
|
@ -13780,7 +13756,7 @@ void prepare_move_to_destination() {
|
|||
|
||||
#if HAS_FEEDRATE_SCALING
|
||||
// SCARA needs to scale the feed rate from mm/s to degrees/s
|
||||
const float inv_segment_length = 1.0 / (MM_PER_ARC_SEGMENT),
|
||||
const float inv_segment_length = 1.0f / (MM_PER_ARC_SEGMENT),
|
||||
inverse_secs = inv_segment_length * fr_mm_s;
|
||||
float oldA = planner.position_float[A_AXIS],
|
||||
oldB = planner.position_float[B_AXIS]
|
||||
|
|
|
@ -402,7 +402,7 @@ void MarlinSettings::postprocess() {
|
|||
* M500 - Store Configuration
|
||||
*/
|
||||
bool MarlinSettings::save() {
|
||||
float dummy = 0.0f;
|
||||
float dummy = 0;
|
||||
char ver[4] = "ERR";
|
||||
|
||||
uint16_t working_crc = 0;
|
||||
|
@ -432,12 +432,12 @@ void MarlinSettings::postprocess() {
|
|||
EEPROM_WRITE(planner.min_travel_feedrate_mm_s);
|
||||
|
||||
#if ENABLED(JUNCTION_DEVIATION)
|
||||
const float planner_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK };
|
||||
const float planner_max_jerk[] = { float(DEFAULT_XJERK), float(DEFAULT_YJERK), float(DEFAULT_ZJERK), float(DEFAULT_EJERK) };
|
||||
EEPROM_WRITE(planner_max_jerk);
|
||||
EEPROM_WRITE(planner.junction_deviation_mm);
|
||||
#else
|
||||
EEPROM_WRITE(planner.max_jerk);
|
||||
dummy = 0.02;
|
||||
dummy = 0.02f;
|
||||
EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
|
||||
|
@ -481,7 +481,7 @@ void MarlinSettings::postprocess() {
|
|||
EEPROM_WRITE(mesh_num_y);
|
||||
EEPROM_WRITE(mbl.z_values);
|
||||
#else // For disabled MBL write a default mesh
|
||||
dummy = 0.0f;
|
||||
dummy = 0;
|
||||
const uint8_t mesh_num_x = 3, mesh_num_y = 3;
|
||||
EEPROM_WRITE(dummy); // z_offset
|
||||
EEPROM_WRITE(mesh_num_x);
|
||||
|
@ -503,7 +503,7 @@ void MarlinSettings::postprocess() {
|
|||
#if ABL_PLANAR
|
||||
EEPROM_WRITE(planner.bed_level_matrix);
|
||||
#else
|
||||
dummy = 0.0;
|
||||
dummy = 0;
|
||||
for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
|
||||
|
@ -527,7 +527,7 @@ void MarlinSettings::postprocess() {
|
|||
// For disabled Bilinear Grid write an empty 3x3 grid
|
||||
const uint8_t grid_max_x = 3, grid_max_y = 3;
|
||||
const int bilinear_start[2] = { 0 }, bilinear_grid_spacing[2] = { 0 };
|
||||
dummy = 0.0f;
|
||||
dummy = 0;
|
||||
EEPROM_WRITE(grid_max_x);
|
||||
EEPROM_WRITE(grid_max_y);
|
||||
EEPROM_WRITE(bilinear_grid_spacing);
|
||||
|
@ -565,7 +565,7 @@ void MarlinSettings::postprocess() {
|
|||
_FIELD_TEST(x_endstop_adj);
|
||||
|
||||
// Write dual endstops in X, Y, Z order. Unused = 0.0
|
||||
dummy = 0.0f;
|
||||
dummy = 0;
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
EEPROM_WRITE(endstops.x_endstop_adj); // 1 float
|
||||
#else
|
||||
|
@ -617,7 +617,7 @@ void MarlinSettings::postprocess() {
|
|||
{
|
||||
dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
|
||||
EEPROM_WRITE(dummy); // Kp
|
||||
dummy = 0.0f;
|
||||
dummy = 0;
|
||||
for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy); // Ki, Kd, Kc
|
||||
}
|
||||
|
||||
|
@ -863,7 +863,7 @@ void MarlinSettings::postprocess() {
|
|||
#if ENABLED(LIN_ADVANCE)
|
||||
EEPROM_WRITE(planner.extruder_advance_K);
|
||||
#else
|
||||
dummy = 0.0f;
|
||||
dummy = 0;
|
||||
EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
|
||||
|
@ -885,7 +885,7 @@ void MarlinSettings::postprocess() {
|
|||
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
||||
EEPROM_WRITE(coordinate_system); // 27 floats
|
||||
#else
|
||||
dummy = 0.0f;
|
||||
dummy = 0;
|
||||
for (uint8_t q = MAX_COORDINATE_SYSTEMS * XYZ; q--;) EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
|
||||
|
@ -900,7 +900,7 @@ void MarlinSettings::postprocess() {
|
|||
EEPROM_WRITE(planner.xz_skew_factor);
|
||||
EEPROM_WRITE(planner.yz_skew_factor);
|
||||
#else
|
||||
dummy = 0.0f;
|
||||
dummy = 0;
|
||||
for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
|
||||
|
@ -920,7 +920,7 @@ void MarlinSettings::postprocess() {
|
|||
EEPROM_WRITE(dummy);
|
||||
}
|
||||
#else
|
||||
dummy = 0.0f;
|
||||
dummy = 0;
|
||||
for (uint8_t q = MAX_EXTRUDERS * 2; q--;) EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
|
||||
|
@ -1729,7 +1729,7 @@ void MarlinSettings::reset() {
|
|||
planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
|
||||
|
||||
#if ENABLED(JUNCTION_DEVIATION)
|
||||
planner.junction_deviation_mm = JUNCTION_DEVIATION_MM;
|
||||
planner.junction_deviation_mm = float(JUNCTION_DEVIATION_MM);
|
||||
#else
|
||||
planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
|
||||
planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
|
||||
|
@ -1831,7 +1831,7 @@ void MarlinSettings::reset() {
|
|||
HOTEND_LOOP()
|
||||
#endif
|
||||
{
|
||||
PID_PARAM(Kp, e) = DEFAULT_Kp;
|
||||
PID_PARAM(Kp, e) = float(DEFAULT_Kp);
|
||||
PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
|
||||
PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
|
||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||
|
|
|
@ -89,7 +89,7 @@ static void i2c_send(const uint8_t channel, const byte v) {
|
|||
|
||||
// This is for the MCP4018 I2C based digipot
|
||||
void digipot_i2c_set_current(uint8_t channel, float current) {
|
||||
i2c_send(channel, current_to_wiper(MIN(MAX(current, 0.0f), float(DIGIPOT_A4988_MAX_CURRENT))));
|
||||
i2c_send(channel, current_to_wiper(MIN(MAX(current, 0), float(DIGIPOT_A4988_MAX_CURRENT))));
|
||||
}
|
||||
|
||||
void digipot_i2c_init() {
|
||||
|
|
|
@ -50,7 +50,7 @@ static void i2c_send(const byte addr, const byte a, const byte b) {
|
|||
|
||||
// This is for the MCP4451 I2C based digipot
|
||||
void digipot_i2c_set_current(uint8_t channel, float current) {
|
||||
current = MIN((float) MAX(current, 0.0f), DIGIPOT_I2C_MAX_CURRENT);
|
||||
current = MIN((float) MAX(current, 0), DIGIPOT_I2C_MAX_CURRENT);
|
||||
// these addresses are specific to Azteeg X3 Pro, can be set to others,
|
||||
// In this case first digipot is at address A0=0, A1= 0, second one is at A0=0, A1= 1
|
||||
byte addr = 0x2C; // channel 0-3
|
||||
|
|
|
@ -81,15 +81,14 @@
|
|||
#define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
|
||||
|
||||
// Macros for maths shortcuts
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
#define RADIANS(d) ((d)*M_PI/180.0)
|
||||
#define DEGREES(r) ((r)*180.0/M_PI)
|
||||
#undef M_PI
|
||||
#define M_PI 3.14159265358979323846f
|
||||
#define RADIANS(d) ((d)*M_PI/180.0f)
|
||||
#define DEGREES(r) ((r)*180.0f/M_PI)
|
||||
#define HYPOT2(x,y) (sq(x)+sq(y))
|
||||
|
||||
#define CIRCLE_AREA(R) (M_PI * sq(R))
|
||||
#define CIRCLE_CIRC(R) (2.0 * M_PI * (R))
|
||||
#define CIRCLE_AREA(R) (M_PI * sq(float(R)))
|
||||
#define CIRCLE_CIRC(R) (2 * M_PI * (float(R)))
|
||||
|
||||
#define SIGN(a) ((a>0)-(a<0))
|
||||
#define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
|
||||
|
@ -162,8 +161,8 @@
|
|||
#define PENDING(NOW,SOON) ((long)(NOW-(SOON))<0)
|
||||
#define ELAPSED(NOW,SOON) (!PENDING(NOW,SOON))
|
||||
|
||||
#define MMM_TO_MMS(MM_M) ((MM_M)/60.0)
|
||||
#define MMS_TO_MMM(MM_S) ((MM_S)*60.0)
|
||||
#define MMM_TO_MMS(MM_M) ((MM_M)/60.0f)
|
||||
#define MMS_TO_MMM(MM_S) ((MM_S)*60.0f)
|
||||
|
||||
#define NOOP do{} while(0)
|
||||
|
||||
|
@ -212,23 +211,24 @@
|
|||
#define MAX4(a, b, c, d) MAX(MAX3(a, b, c), d)
|
||||
#define MAX5(a, b, c, d, e) MAX(MAX4(a, b, c, d), e)
|
||||
|
||||
#define UNEAR_ZERO(x) ((x) < 0.000001)
|
||||
#define NEAR_ZERO(x) WITHIN(x, -0.000001, 0.000001)
|
||||
#define UNEAR_ZERO(x) ((x) < 0.000001f)
|
||||
#define NEAR_ZERO(x) WITHIN(x, -0.000001f, 0.000001f)
|
||||
#define NEAR(x,y) NEAR_ZERO((x)-(y))
|
||||
|
||||
#define RECIPROCAL(x) (NEAR_ZERO(x) ? 0.0 : 1.0 / (x))
|
||||
#define FIXFLOAT(f) (f + (f < 0.0 ? -0.00005 : 0.00005))
|
||||
#define RECIPROCAL(x) (NEAR_ZERO(x) ? 0.0f : 1.0f / (x))
|
||||
#define FIXFLOAT(f) (f + (f < 0.0f ? -0.00005f : 0.00005f))
|
||||
|
||||
//
|
||||
// Maths macros that can be overridden by HAL
|
||||
//
|
||||
#define ATAN2(y, x) atan2(y, x)
|
||||
#define POW(x, y) pow(x, y)
|
||||
#define SQRT(x) sqrt(x)
|
||||
#define CEIL(x) ceil(x)
|
||||
#define FLOOR(x) floor(x)
|
||||
#define LROUND(x) lround(x)
|
||||
#define FMOD(x, y) fmod(x, y)
|
||||
#define ATAN2(y, x) atan2f(y, x)
|
||||
#define POW(x, y) powf(x, y)
|
||||
#define SQRT(x) sqrtf(x)
|
||||
#define RSQRT(x) (1 / sqrtf(x))
|
||||
#define CEIL(x) ceilf(x)
|
||||
#define FLOOR(x) floorf(x)
|
||||
#define LROUND(x) lroundf(x)
|
||||
#define FMOD(x, y) fmodf(x, y)
|
||||
#define HYPOT(x,y) SQRT(HYPOT2(x,y))
|
||||
|
||||
#endif //__MACROS_H
|
||||
|
|
|
@ -72,22 +72,22 @@ public:
|
|||
}
|
||||
|
||||
static int8_t cell_index_x(const float &x) {
|
||||
int8_t cx = (x - (MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
|
||||
int8_t cx = (x - (MESH_MIN_X)) * (1.0f / (MESH_X_DIST));
|
||||
return constrain(cx, 0, (GRID_MAX_POINTS_X) - 2);
|
||||
}
|
||||
|
||||
static int8_t cell_index_y(const float &y) {
|
||||
int8_t cy = (y - (MESH_MIN_Y)) * (1.0 / (MESH_Y_DIST));
|
||||
int8_t cy = (y - (MESH_MIN_Y)) * (1.0f / (MESH_Y_DIST));
|
||||
return constrain(cy, 0, (GRID_MAX_POINTS_Y) - 2);
|
||||
}
|
||||
|
||||
static int8_t probe_index_x(const float &x) {
|
||||
int8_t px = (x - (MESH_MIN_X) + 0.5 * (MESH_X_DIST)) * (1.0 / (MESH_X_DIST));
|
||||
int8_t px = (x - (MESH_MIN_X) + 0.5f * (MESH_X_DIST)) * (1.0f / (MESH_X_DIST));
|
||||
return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
|
||||
}
|
||||
|
||||
static int8_t probe_index_y(const float &y) {
|
||||
int8_t py = (y - (MESH_MIN_Y) + 0.5 * (MESH_Y_DIST)) * (1.0 / (MESH_Y_DIST));
|
||||
int8_t py = (y - (MESH_MIN_Y) + 0.5f * (MESH_Y_DIST)) * (1.0f / (MESH_Y_DIST));
|
||||
return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include "serial.h"
|
||||
#endif
|
||||
|
||||
#define strtof strtod
|
||||
|
||||
/**
|
||||
* GCode parser
|
||||
*
|
||||
|
@ -194,15 +196,15 @@ public:
|
|||
if (c == '\0' || c == ' ') break;
|
||||
if (c == 'E' || c == 'e') {
|
||||
*e = '\0';
|
||||
const float ret = strtod(value_ptr, NULL);
|
||||
const float ret = strtof(value_ptr, NULL);
|
||||
*e = c;
|
||||
return ret;
|
||||
}
|
||||
++e;
|
||||
}
|
||||
return strtod(value_ptr, NULL);
|
||||
return strtof(value_ptr, NULL);
|
||||
}
|
||||
return 0.0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Code value as a long or ulong
|
||||
|
|
|
@ -139,11 +139,11 @@ float Planner::max_feedrate_mm_s[XYZE_N], // (mm/s) M203 XYZE - Max speeds
|
|||
|
||||
int16_t Planner::flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100); // Extrusion factor for each extruder
|
||||
|
||||
float Planner::e_factor[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(1.0); // The flow percentage and volumetric multiplier combine to scale E movement
|
||||
float Planner::e_factor[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(1.0f); // The flow percentage and volumetric multiplier combine to scale E movement
|
||||
|
||||
#if DISABLED(NO_VOLUMETRICS)
|
||||
float Planner::filament_size[EXTRUDERS], // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder
|
||||
Planner::volumetric_area_nominal = CIRCLE_AREA((DEFAULT_NOMINAL_FILAMENT_DIA) * 0.5), // Nominal cross-sectional area
|
||||
Planner::volumetric_area_nominal = CIRCLE_AREA(float(DEFAULT_NOMINAL_FILAMENT_DIA) * 0.5f), // Nominal cross-sectional area
|
||||
Planner::volumetric_multiplier[EXTRUDERS]; // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner
|
||||
#endif
|
||||
|
||||
|
@ -177,7 +177,7 @@ float Planner::e_factor[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(1.0); // The flow perce
|
|||
#if ENABLED(AUTOTEMP)
|
||||
float Planner::autotemp_max = 250,
|
||||
Planner::autotemp_min = 210,
|
||||
Planner::autotemp_factor = 0.1;
|
||||
Planner::autotemp_factor = 0.1f;
|
||||
bool Planner::autotemp_enabled = false;
|
||||
#endif
|
||||
|
||||
|
@ -225,7 +225,7 @@ void Planner::init() {
|
|||
ZERO(position_float);
|
||||
#endif
|
||||
ZERO(previous_speed);
|
||||
previous_nominal_speed_sqr = 0.0;
|
||||
previous_nominal_speed_sqr = 0;
|
||||
#if ABL_PLANAR
|
||||
bed_level_matrix.set_to_identity();
|
||||
#endif
|
||||
|
@ -842,7 +842,7 @@ void Planner::reverse_pass_kernel(block_t* const current, const block_t * const
|
|||
|
||||
const float new_entry_speed_sqr = TEST(current->flag, BLOCK_BIT_NOMINAL_LENGTH)
|
||||
? max_entry_speed_sqr
|
||||
: MIN(max_entry_speed_sqr, max_allowable_speed_sqr(-current->acceleration, next ? next->entry_speed_sqr : sq(MINIMUM_PLANNER_SPEED), current->millimeters));
|
||||
: MIN(max_entry_speed_sqr, max_allowable_speed_sqr(-current->acceleration, next ? next->entry_speed_sqr : sq(float(MINIMUM_PLANNER_SPEED)), current->millimeters));
|
||||
if (current->entry_speed_sqr != new_entry_speed_sqr) {
|
||||
|
||||
// Need to recalculate the block speed - Mark it now, so the stepper
|
||||
|
@ -1059,7 +1059,7 @@ void Planner::recalculate_trapezoids() {
|
|||
|
||||
// NOTE: Entry and exit factors always > 0 by all previous logic operations.
|
||||
const float current_nominal_speed = SQRT(current->nominal_speed_sqr),
|
||||
nomr = 1.0 / current_nominal_speed;
|
||||
nomr = 1.0f / current_nominal_speed;
|
||||
calculate_trapezoid_for_block(current, current_entry_speed * nomr, next_entry_speed * nomr);
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
if (current->use_advance_lead) {
|
||||
|
@ -1098,8 +1098,8 @@ void Planner::recalculate_trapezoids() {
|
|||
// Block is not BUSY, we won the race against the Stepper ISR:
|
||||
|
||||
const float next_nominal_speed = SQRT(next->nominal_speed_sqr),
|
||||
nomr = 1.0 / next_nominal_speed;
|
||||
calculate_trapezoid_for_block(next, next_entry_speed * nomr, (MINIMUM_PLANNER_SPEED) * nomr);
|
||||
nomr = 1.0f / next_nominal_speed;
|
||||
calculate_trapezoid_for_block(next, next_entry_speed * nomr, float(MINIMUM_PLANNER_SPEED) * nomr);
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
if (next->use_advance_lead) {
|
||||
const float comp = next->e_D_ratio * extruder_advance_K * axis_steps_per_mm[E_AXIS];
|
||||
|
@ -1145,7 +1145,7 @@ void Planner::recalculate() {
|
|||
|
||||
float t = autotemp_min + high * autotemp_factor;
|
||||
t = constrain(t, autotemp_min, autotemp_max);
|
||||
if (t < oldt) t = t * (1 - (AUTOTEMP_OLDWEIGHT)) + oldt * (AUTOTEMP_OLDWEIGHT);
|
||||
if (t < oldt) t = t * (1 - float(AUTOTEMP_OLDWEIGHT)) + oldt * float(AUTOTEMP_OLDWEIGHT);
|
||||
oldt = t;
|
||||
thermalManager.setTargetHotend(t, 0);
|
||||
}
|
||||
|
@ -1300,7 +1300,7 @@ void Planner::check_axes_activity() {
|
|||
* Return 1.0 with volumetric off or a diameter of 0.0.
|
||||
*/
|
||||
inline float calculate_volumetric_multiplier(const float &diameter) {
|
||||
return (parser.volumetric_enabled && diameter) ? 1.0 / CIRCLE_AREA(diameter * 0.5) : 1.0;
|
||||
return (parser.volumetric_enabled && diameter) ? 1.0f / CIRCLE_AREA(diameter * 0.5) : 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1324,11 +1324,11 @@ void Planner::check_axes_activity() {
|
|||
*/
|
||||
void Planner::calculate_volumetric_for_width_sensor(const int8_t encoded_ratio) {
|
||||
// Reconstitute the nominal/measured ratio
|
||||
const float nom_meas_ratio = 1.0 + 0.01 * encoded_ratio,
|
||||
const float nom_meas_ratio = 1 + 0.01f * encoded_ratio,
|
||||
ratio_2 = sq(nom_meas_ratio);
|
||||
|
||||
volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = parser.volumetric_enabled
|
||||
? ratio_2 / CIRCLE_AREA(filament_width_nominal * 0.5) // Volumetric uses a true volumetric multiplier
|
||||
? ratio_2 / CIRCLE_AREA(filament_width_nominal * 0.5f) // Volumetric uses a true volumetric multiplier
|
||||
: ratio_2; // Linear squares the ratio, which scales the volume
|
||||
|
||||
refresh_e_factor(FILAMENT_SENSOR_EXTRUDER_NUM);
|
||||
|
@ -1673,7 +1673,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
if (de < 0) SBI(dm, E_AXIS);
|
||||
|
||||
const float esteps_float = de * e_factor[extruder];
|
||||
const uint32_t esteps = ABS(esteps_float) + 0.5;
|
||||
const uint32_t esteps = ABS(esteps_float) + 0.5f;
|
||||
|
||||
// Clear all flags, including the "busy" bit
|
||||
block->flag = 0x00;
|
||||
|
@ -1928,7 +1928,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
else
|
||||
block->millimeters = millimeters;
|
||||
|
||||
const float inverse_millimeters = 1.0 / block->millimeters; // Inverse millimeters to remove multiple divides
|
||||
const float inverse_millimeters = 1.0f / block->millimeters; // Inverse millimeters to remove multiple divides
|
||||
|
||||
// Calculate inverse time for this move. No divide by zero due to previous checks.
|
||||
// Example: At 120mm/s a 60mm move takes 0.5s. So this will give 2.0.
|
||||
|
@ -1940,7 +1940,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
// Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
|
||||
#if ENABLED(SLOWDOWN) || ENABLED(ULTRA_LCD) || defined(XY_FREQUENCY_LIMIT)
|
||||
// Segment time im micro seconds
|
||||
uint32_t segment_time_us = LROUND(1000000.0 / inverse_secs);
|
||||
uint32_t segment_time_us = LROUND(1000000.0f / inverse_secs);
|
||||
#endif
|
||||
|
||||
#if ENABLED(SLOWDOWN)
|
||||
|
@ -1948,7 +1948,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
if (segment_time_us < min_segment_time_us) {
|
||||
// buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
|
||||
const uint32_t nst = segment_time_us + LROUND(2 * (min_segment_time_us - segment_time_us) / moves_queued);
|
||||
inverse_secs = 1000000.0 / nst;
|
||||
inverse_secs = 1000000.0f / nst;
|
||||
#if defined(XY_FREQUENCY_LIMIT) || ENABLED(ULTRA_LCD)
|
||||
segment_time_us = nst;
|
||||
#endif
|
||||
|
@ -1988,7 +1988,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
while (filwidth_delay_dist >= MMD_MM) filwidth_delay_dist -= MMD_MM;
|
||||
|
||||
// Convert into an index into the measurement array
|
||||
filwidth_delay_index[0] = int8_t(filwidth_delay_dist * 0.1);
|
||||
filwidth_delay_index[0] = int8_t(filwidth_delay_dist * 0.1f);
|
||||
|
||||
// If the index has changed (must have gone forward)...
|
||||
if (filwidth_delay_index[0] != filwidth_delay_index[1]) {
|
||||
|
@ -2004,7 +2004,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
#endif
|
||||
|
||||
// Calculate and limit speed in mm/sec for each axis
|
||||
float current_speed[NUM_AXIS], speed_factor = 1.0; // factor <1 decreases speed
|
||||
float current_speed[NUM_AXIS], speed_factor = 1.0f; // factor <1 decreases speed
|
||||
LOOP_XYZE(i) {
|
||||
const float cs = ABS((current_speed[i] = delta_mm[i] * inverse_secs));
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
|
@ -2052,7 +2052,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
#endif // XY_FREQUENCY_LIMIT
|
||||
|
||||
// Correct the speed
|
||||
if (speed_factor < 1.0) {
|
||||
if (speed_factor < 1.0f) {
|
||||
LOOP_XYZE(i) current_speed[i] *= speed_factor;
|
||||
block->nominal_rate *= speed_factor;
|
||||
block->nominal_speed_sqr = block->nominal_speed_sqr * sq(speed_factor);
|
||||
|
@ -2125,7 +2125,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
|
||||
// Check for unusual high e_D ratio to detect if a retract move was combined with the last print move due to min. steps per segment. Never execute this with advance!
|
||||
// This assumes no one will use a retract length of 0mm < retr_length < ~0.2mm and no one will print 100mm wide lines using 3mm filament or 35mm wide lines using 1.75mm filament.
|
||||
if (block->e_D_ratio > 3.0)
|
||||
if (block->e_D_ratio > 3.0f)
|
||||
block->use_advance_lead = false;
|
||||
else {
|
||||
const uint32_t max_accel_steps_per_s2 = MAX_E_JERK / (extruder_advance_K * block->e_D_ratio) * steps_per_mm;
|
||||
|
@ -2160,7 +2160,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
block->acceleration_steps_per_s2 = accel;
|
||||
block->acceleration = accel / steps_per_mm;
|
||||
#if DISABLED(S_CURVE_ACCELERATION)
|
||||
block->acceleration_rate = (uint32_t)(accel * (4096.0 * 4096.0 / (STEPPER_TIMER_RATE)));
|
||||
block->acceleration_rate = (uint32_t)(accel * (4096.0f * 4096.0f / (STEPPER_TIMER_RATE)));
|
||||
#endif
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
if (block->use_advance_lead) {
|
||||
|
@ -2233,12 +2233,12 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
;
|
||||
|
||||
// NOTE: Computed without any expensive trig, sin() or acos(), by trig half angle identity of cos(theta).
|
||||
if (junction_cos_theta > 0.999999) {
|
||||
if (junction_cos_theta > 0.999999f) {
|
||||
// For a 0 degree acute junction, just set minimum junction speed.
|
||||
vmax_junction_sqr = sq(MINIMUM_PLANNER_SPEED);
|
||||
vmax_junction_sqr = sq(float(MINIMUM_PLANNER_SPEED));
|
||||
}
|
||||
else {
|
||||
NOLESS(junction_cos_theta, -0.999999); // Check for numerical round-off to avoid divide by zero.
|
||||
NOLESS(junction_cos_theta, -0.999999f); // Check for numerical round-off to avoid divide by zero.
|
||||
|
||||
// Convert delta vector to unit vector
|
||||
float junction_unit_vec[XYZE] = {
|
||||
|
@ -2250,13 +2250,13 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
normalize_junction_vector(junction_unit_vec);
|
||||
|
||||
const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec),
|
||||
sin_theta_d2 = SQRT(0.5 * (1.0 - junction_cos_theta)); // Trig half angle identity. Always positive.
|
||||
sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive.
|
||||
|
||||
vmax_junction_sqr = (junction_acceleration * junction_deviation_mm * sin_theta_d2) / (1.0 - sin_theta_d2);
|
||||
if (block->millimeters < 1.0) {
|
||||
vmax_junction_sqr = (junction_acceleration * junction_deviation_mm * sin_theta_d2) / (1.0f - sin_theta_d2);
|
||||
if (block->millimeters < 1) {
|
||||
|
||||
// Fast acos approximation, minus the error bar to be safe
|
||||
const float junction_theta = (RADIANS(-40) * sq(junction_cos_theta) - RADIANS(50)) * junction_cos_theta + RADIANS(90) - 0.18;
|
||||
const float junction_theta = (RADIANS(-40) * sq(junction_cos_theta) - RADIANS(50)) * junction_cos_theta + RADIANS(90) - 0.18f;
|
||||
|
||||
// If angle is greater than 135 degrees (octagon), find speed for approximate arc
|
||||
if (junction_theta > RADIANS(135)) {
|
||||
|
@ -2270,7 +2270,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
vmax_junction_sqr = MIN3(vmax_junction_sqr, block->nominal_speed_sqr, previous_nominal_speed_sqr);
|
||||
}
|
||||
else // Init entry speed to zero. Assume it starts from rest. Planner will correct this later.
|
||||
vmax_junction_sqr = 0.0;
|
||||
vmax_junction_sqr = 0;
|
||||
|
||||
COPY(previous_unit_vec, unit_vec);
|
||||
|
||||
|
@ -2361,11 +2361,11 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||
block->max_entry_speed_sqr = vmax_junction_sqr;
|
||||
|
||||
// Initialize block entry speed. Compute based on deceleration to user-defined MINIMUM_PLANNER_SPEED.
|
||||
const float v_allowable_sqr = max_allowable_speed_sqr(-block->acceleration, sq(MINIMUM_PLANNER_SPEED), block->millimeters);
|
||||
const float v_allowable_sqr = max_allowable_speed_sqr(-block->acceleration, sq(float(MINIMUM_PLANNER_SPEED)), block->millimeters);
|
||||
|
||||
// If we are trying to add a split block, start with the
|
||||
// max. allowed speed to avoid an interrupted first move.
|
||||
block->entry_speed_sqr = !split_move ? sq(MINIMUM_PLANNER_SPEED) : MIN(vmax_junction_sqr, v_allowable_sqr);
|
||||
block->entry_speed_sqr = !split_move ? sq(float(MINIMUM_PLANNER_SPEED)) : MIN(vmax_junction_sqr, v_allowable_sqr);
|
||||
|
||||
// Initialize planner efficiency flags
|
||||
// Set flag if block will always reach maximum junction speed regardless of entry/exit speeds.
|
||||
|
@ -2601,7 +2601,7 @@ void Planner::reset_acceleration_rates() {
|
|||
|
||||
// Recalculate position, steps_to_mm if axis_steps_per_mm changes!
|
||||
void Planner::refresh_positioning() {
|
||||
LOOP_XYZE_N(i) steps_to_mm[i] = 1.0 / axis_steps_per_mm[i];
|
||||
LOOP_XYZE_N(i) steps_to_mm[i] = 1.0f / axis_steps_per_mm[i];
|
||||
set_position_mm_kinematic(current_position);
|
||||
reset_acceleration_rates();
|
||||
}
|
||||
|
|
|
@ -319,7 +319,7 @@ class Planner {
|
|||
static void refresh_positioning();
|
||||
|
||||
FORCE_INLINE static void refresh_e_factor(const uint8_t e) {
|
||||
e_factor[e] = (flow_percentage[e] * 0.01
|
||||
e_factor[e] = (flow_percentage[e] * 0.01f
|
||||
#if DISABLED(NO_VOLUMETRICS)
|
||||
* volumetric_multiplier[e]
|
||||
#endif
|
||||
|
@ -357,19 +357,19 @@ class Planner {
|
|||
* Returns 0.0 if Z is past the specified 'Fade Height'.
|
||||
*/
|
||||
inline static float fade_scaling_factor_for_z(const float &rz) {
|
||||
static float z_fade_factor = 1.0;
|
||||
static float z_fade_factor = 1;
|
||||
if (z_fade_height) {
|
||||
if (rz >= z_fade_height) return 0.0;
|
||||
if (rz >= z_fade_height) return 0;
|
||||
if (last_fade_z != rz) {
|
||||
last_fade_z = rz;
|
||||
z_fade_factor = 1.0 - rz * inverse_z_fade_height;
|
||||
z_fade_factor = 1 - rz * inverse_z_fade_height;
|
||||
}
|
||||
return z_fade_factor;
|
||||
}
|
||||
return 1.0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
FORCE_INLINE static void force_fade_recalc() { last_fade_z = -999.999; }
|
||||
FORCE_INLINE static void force_fade_recalc() { last_fade_z = -999.999f; }
|
||||
|
||||
FORCE_INLINE static void set_z_fade_height(const float &zfh) {
|
||||
z_fade_height = zfh > 0 ? zfh : 0;
|
||||
|
@ -385,7 +385,7 @@ class Planner {
|
|||
|
||||
FORCE_INLINE static float fade_scaling_factor_for_z(const float &rz) {
|
||||
UNUSED(rz);
|
||||
return 1.0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
FORCE_INLINE static bool leveling_active_at_z(const float &rz) { UNUSED(rz); return true; }
|
||||
|
@ -812,9 +812,9 @@ class Planner {
|
|||
#if ENABLED(JUNCTION_DEVIATION)
|
||||
|
||||
FORCE_INLINE static void normalize_junction_vector(float (&vector)[XYZE]) {
|
||||
float magnitude_sq = 0.0;
|
||||
float magnitude_sq = 0;
|
||||
LOOP_XYZE(idx) if (vector[idx]) magnitude_sq += sq(vector[idx]);
|
||||
const float inv_magnitude = 1.0 / SQRT(magnitude_sq);
|
||||
const float inv_magnitude = RSQRT(magnitude_sq);
|
||||
LOOP_XYZE(idx) vector[idx] *= inv_magnitude;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@
|
|||
#include "Marlin.h"
|
||||
|
||||
// See the meaning in the documentation of cubic_b_spline().
|
||||
#define MIN_STEP 0.002
|
||||
#define MAX_STEP 0.1
|
||||
#define SIGMA 0.1
|
||||
#define MIN_STEP 0.002f
|
||||
#define MAX_STEP 0.1f
|
||||
#define SIGMA 0.1f
|
||||
|
||||
// Compute the linear interpolation between two real numbers.
|
||||
inline static float interp(float a, float b, float t) { return (1.0 - t) * a + t * b; }
|
||||
inline static float interp(float a, float b, float t) { return (1.0f - t) * a + t * b; }
|
||||
|
||||
/**
|
||||
* Compute a Bézier curve using the De Casteljau's algorithm (see
|
||||
|
@ -111,7 +111,7 @@ void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS]
|
|||
first1 = position[Y_AXIS] + offset[1],
|
||||
second0 = target[X_AXIS] + offset[2],
|
||||
second1 = target[Y_AXIS] + offset[3];
|
||||
float t = 0.0;
|
||||
float t = 0;
|
||||
|
||||
float bez_target[4];
|
||||
bez_target[X_AXIS] = position[X_AXIS];
|
||||
|
@ -120,7 +120,7 @@ void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS]
|
|||
|
||||
millis_t next_idle_ms = millis() + 200UL;
|
||||
|
||||
while (t < 1.0) {
|
||||
while (t < 1) {
|
||||
|
||||
thermalManager.manage_heater();
|
||||
millis_t now = millis();
|
||||
|
@ -133,16 +133,16 @@ void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS]
|
|||
// close to a linear interpolation.
|
||||
bool did_reduce = false;
|
||||
float new_t = t + step;
|
||||
NOMORE(new_t, 1.0);
|
||||
NOMORE(new_t, 1);
|
||||
float new_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], new_t),
|
||||
new_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], new_t);
|
||||
for (;;) {
|
||||
if (new_t - t < (MIN_STEP)) break;
|
||||
const float candidate_t = 0.5 * (t + new_t),
|
||||
const float candidate_t = 0.5f * (t + new_t),
|
||||
candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t),
|
||||
candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t),
|
||||
interp_pos0 = 0.5 * (bez_target[X_AXIS] + new_pos0),
|
||||
interp_pos1 = 0.5 * (bez_target[Y_AXIS] + new_pos1);
|
||||
interp_pos0 = 0.5f * (bez_target[X_AXIS] + new_pos0),
|
||||
interp_pos1 = 0.5f * (bez_target[Y_AXIS] + new_pos1);
|
||||
if (dist1(candidate_pos0, candidate_pos1, interp_pos0, interp_pos1) <= (SIGMA)) break;
|
||||
new_t = candidate_t;
|
||||
new_pos0 = candidate_pos0;
|
||||
|
@ -153,12 +153,12 @@ void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS]
|
|||
// If we did not reduce the step, maybe we should enlarge it.
|
||||
if (!did_reduce) for (;;) {
|
||||
if (new_t - t > MAX_STEP) break;
|
||||
const float candidate_t = t + 2.0 * (new_t - t);
|
||||
if (candidate_t >= 1.0) break;
|
||||
const float candidate_t = t + 2 * (new_t - t);
|
||||
if (candidate_t >= 1) break;
|
||||
const float candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t),
|
||||
candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t),
|
||||
interp_pos0 = 0.5 * (bez_target[X_AXIS] + candidate_pos0),
|
||||
interp_pos1 = 0.5 * (bez_target[Y_AXIS] + candidate_pos1);
|
||||
interp_pos0 = 0.5f * (bez_target[X_AXIS] + candidate_pos0),
|
||||
interp_pos1 = 0.5f * (bez_target[Y_AXIS] + candidate_pos1);
|
||||
if (dist1(new_pos0, new_pos1, interp_pos0, interp_pos1) > (SIGMA)) break;
|
||||
new_t = candidate_t;
|
||||
new_pos0 = candidate_pos0;
|
||||
|
|
|
@ -60,7 +60,7 @@ millis_t PrintCounter::deltaDuration() {
|
|||
return lastDuration - tmp;
|
||||
}
|
||||
|
||||
void PrintCounter::incFilamentUsed(double const &amount) {
|
||||
void PrintCounter::incFilamentUsed(float const &amount) {
|
||||
#if ENABLED(DEBUG_PRINTCOUNTER)
|
||||
debug(PSTR("incFilamentUsed"));
|
||||
#endif
|
||||
|
|
|
@ -31,13 +31,13 @@
|
|||
#include "stopwatch.h"
|
||||
#include <avr/eeprom.h>
|
||||
|
||||
struct printStatistics { // 16 bytes (20 with real doubles)
|
||||
struct printStatistics { // 16 bytes
|
||||
//const uint8_t magic; // Magic header, it will always be 0x16
|
||||
uint16_t totalPrints; // Number of prints
|
||||
uint16_t finishedPrints; // Number of complete prints
|
||||
uint32_t printTime; // Accumulated printing time
|
||||
uint32_t longestPrint; // Longest successful print job
|
||||
double filamentUsed; // Accumulated filament consumed in mm
|
||||
float filamentUsed; // Accumulated filament consumed in mm
|
||||
};
|
||||
|
||||
class PrintCounter: public Stopwatch {
|
||||
|
@ -122,7 +122,7 @@ class PrintCounter: public Stopwatch {
|
|||
*
|
||||
* @param amount The amount of filament used in mm
|
||||
*/
|
||||
static void incFilamentUsed(double const &amount);
|
||||
static void incFilamentUsed(float const &amount);
|
||||
|
||||
/**
|
||||
* @brief Reset the Print Statistics
|
||||
|
|
|
@ -62,7 +62,7 @@ FORCE_INLINE void _draw_heater_status(const uint8_t x, const int8_t heater, cons
|
|||
|
||||
if (blink || !is_idle)
|
||||
#endif
|
||||
_draw_centered_temp(0.5 + (
|
||||
_draw_centered_temp(0.5f + (
|
||||
#if HAS_HEATED_BED
|
||||
isBed ? thermalManager.degTargetBed() :
|
||||
#endif
|
||||
|
@ -72,7 +72,7 @@ FORCE_INLINE void _draw_heater_status(const uint8_t x, const int8_t heater, cons
|
|||
}
|
||||
|
||||
if (PAGE_CONTAINS(21, 28)) {
|
||||
_draw_centered_temp(0.5 + (
|
||||
_draw_centered_temp(0.5f + (
|
||||
#if HAS_HEATED_BED
|
||||
isBed ? thermalManager.degBed() :
|
||||
#endif
|
||||
|
|
|
@ -91,8 +91,8 @@
|
|||
mcp4728_simpleCommand(UPDATE);
|
||||
}
|
||||
|
||||
static float dac_perc(int8_t n) { return 100.0 * mcp4728_getValue(dac_order[n]) * (1.0 / (DAC_STEPPER_MAX)); }
|
||||
static float dac_amps(int8_t n) { return mcp4728_getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * (1.0 / (DAC_STEPPER_SENSE)); }
|
||||
static float dac_perc(int8_t n) { return 100.0f * mcp4728_getValue(dac_order[n]) * (1.0f / (DAC_STEPPER_MAX)); }
|
||||
static float dac_amps(int8_t n) { return mcp4728_getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * (1.0f / (DAC_STEPPER_SENSE)); }
|
||||
|
||||
uint8_t dac_current_get_percent(const AxisEnum axis) { return mcp4728_getDrvPct(dac_order[axis]); }
|
||||
void dac_current_set_percents(const uint8_t pct[XYZE]) {
|
||||
|
|
|
@ -386,13 +386,13 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS];
|
|||
SERIAL_PROTOCOLPAIR(MSG_T_MIN, min);
|
||||
SERIAL_PROTOCOLPAIR(MSG_T_MAX, max);
|
||||
if (cycles > 2) {
|
||||
Ku = (4.0 * d) / (M_PI * (max - min) * 0.5);
|
||||
Tu = ((float)(t_low + t_high) * 0.001);
|
||||
Ku = (4.0f * d) / (M_PI * (max - min) * 0.5f);
|
||||
Tu = ((float)(t_low + t_high) * 0.001f);
|
||||
SERIAL_PROTOCOLPAIR(MSG_KU, Ku);
|
||||
SERIAL_PROTOCOLPAIR(MSG_TU, Tu);
|
||||
workKp = 0.6 * Ku;
|
||||
workKp = 0.6f * Ku;
|
||||
workKi = 2 * workKp / Tu;
|
||||
workKd = workKp * Tu * 0.125;
|
||||
workKd = workKp * Tu * 0.125f;
|
||||
SERIAL_PROTOCOLLNPGM("\n" MSG_CLASSIC_PID);
|
||||
SERIAL_PROTOCOLPAIR(MSG_KP, workKp);
|
||||
SERIAL_PROTOCOLPAIR(MSG_KI, workKi);
|
||||
|
@ -633,7 +633,7 @@ float Temperature::get_pid_output(const int8_t e) {
|
|||
#if ENABLED(PIDTEMP)
|
||||
#if DISABLED(PID_OPENLOOP)
|
||||
pid_error[HOTEND_INDEX] = target_temperature[HOTEND_INDEX] - current_temperature[HOTEND_INDEX];
|
||||
dTerm[HOTEND_INDEX] = PID_K2 * PID_PARAM(Kd, HOTEND_INDEX) * (current_temperature[HOTEND_INDEX] - temp_dState[HOTEND_INDEX]) + PID_K1 * dTerm[HOTEND_INDEX];
|
||||
dTerm[HOTEND_INDEX] = PID_K2 * PID_PARAM(Kd, HOTEND_INDEX) * (current_temperature[HOTEND_INDEX] - temp_dState[HOTEND_INDEX]) + float(PID_K1) * dTerm[HOTEND_INDEX];
|
||||
temp_dState[HOTEND_INDEX] = current_temperature[HOTEND_INDEX];
|
||||
#if HEATER_IDLE_HANDLER
|
||||
if (heater_idle_timeout_exceeded[HOTEND_INDEX]) {
|
||||
|
@ -1079,7 +1079,7 @@ void Temperature::updateTemperaturesFromRawValues() {
|
|||
|
||||
// Convert raw Filament Width to millimeters
|
||||
float Temperature::analog2widthFil() {
|
||||
return current_raw_filwidth * 5.0 * (1.0 / 16383.0);
|
||||
return current_raw_filwidth * 5.0f * (1.0f / 16383.0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1092,7 +1092,7 @@ void Temperature::updateTemperaturesFromRawValues() {
|
|||
*/
|
||||
int8_t Temperature::widthFil_to_size_ratio() {
|
||||
if (ABS(filament_width_nominal - filament_width_meas) <= FILWIDTH_ERROR_MARGIN)
|
||||
return int(100.0 * filament_width_nominal / filament_width_meas) - 100;
|
||||
return int(100.0f * filament_width_nominal / filament_width_meas) - 100;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,14 +107,14 @@ enum ADCSensorState : char {
|
|||
#define ACTUAL_ADC_SAMPLES MAX(int(MIN_ADC_ISR_LOOPS), int(SensorsReady))
|
||||
|
||||
#if HAS_PID_HEATING
|
||||
#define PID_K2 (1.0-PID_K1)
|
||||
#define PID_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / (F_CPU / 64.0 / 256.0))
|
||||
#define PID_K2 (1.0f-PID_K1)
|
||||
#define PID_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / (F_CPU / 64.0f / 256.0f))
|
||||
|
||||
// Apply the scale factors to the PID values
|
||||
#define scalePID_i(i) ( (i) * PID_dT )
|
||||
#define unscalePID_i(i) ( (i) / PID_dT )
|
||||
#define scalePID_d(d) ( (d) / PID_dT )
|
||||
#define unscalePID_d(d) ( (d) * PID_dT )
|
||||
#define scalePID_i(i) ( (i) * float(PID_dT) )
|
||||
#define unscalePID_i(i) ( (i) / float(PID_dT) )
|
||||
#define scalePID_d(d) ( (d) / float(PID_dT) )
|
||||
#define unscalePID_d(d) ( (d) * float(PID_dT) )
|
||||
#endif
|
||||
|
||||
class Temperature {
|
||||
|
|
|
@ -161,14 +161,14 @@ class unified_bed_leveling {
|
|||
FORCE_INLINE static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
|
||||
|
||||
static int8_t get_cell_index_x(const float &x) {
|
||||
const int8_t cx = (x - (MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
|
||||
const int8_t cx = (x - (MESH_MIN_X)) * (1.0f / (MESH_X_DIST));
|
||||
return constrain(cx, 0, (GRID_MAX_POINTS_X) - 1); // -1 is appropriate if we want all movement to the X_MAX
|
||||
} // position. But with this defined this way, it is possible
|
||||
// to extrapolate off of this point even further out. Probably
|
||||
// that is OK because something else should be keeping that from
|
||||
// happening and should not be worried about at this level.
|
||||
static int8_t get_cell_index_y(const float &y) {
|
||||
const int8_t cy = (y - (MESH_MIN_Y)) * (1.0 / (MESH_Y_DIST));
|
||||
const int8_t cy = (y - (MESH_MIN_Y)) * (1.0f / (MESH_Y_DIST));
|
||||
return constrain(cy, 0, (GRID_MAX_POINTS_Y) - 1); // -1 is appropriate if we want all movement to the Y_MAX
|
||||
} // position. But with this defined this way, it is possible
|
||||
// to extrapolate off of this point even further out. Probably
|
||||
|
@ -176,12 +176,12 @@ class unified_bed_leveling {
|
|||
// happening and should not be worried about at this level.
|
||||
|
||||
static int8_t find_closest_x_index(const float &x) {
|
||||
const int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) * (1.0 / (MESH_X_DIST));
|
||||
const int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5f) * (1.0f / (MESH_X_DIST));
|
||||
return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
|
||||
}
|
||||
|
||||
static int8_t find_closest_y_index(const float &y) {
|
||||
const int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * (1.0 / (MESH_Y_DIST));
|
||||
const int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5f) * (1.0f / (MESH_Y_DIST));
|
||||
return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@
|
|||
unified_bed_leveling::g29_y_flag;
|
||||
float unified_bed_leveling::g29_x_pos,
|
||||
unified_bed_leveling::g29_y_pos,
|
||||
unified_bed_leveling::g29_card_thickness = 0.0,
|
||||
unified_bed_leveling::g29_constant = 0.0;
|
||||
unified_bed_leveling::g29_card_thickness = 0,
|
||||
unified_bed_leveling::g29_constant = 0;
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
int unified_bed_leveling::g29_grid_size;
|
||||
|
@ -343,23 +343,23 @@
|
|||
case 0:
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a bowl shape - similar to
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { // a poorly calibrated Delta.
|
||||
const float p1 = 0.5 * (GRID_MAX_POINTS_X) - x,
|
||||
p2 = 0.5 * (GRID_MAX_POINTS_Y) - y;
|
||||
z_values[x][y] += 2.0 * HYPOT(p1, p2);
|
||||
const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x,
|
||||
p2 = 0.5f * (GRID_MAX_POINTS_Y) - y;
|
||||
z_values[x][y] += 2.0f * HYPOT(p1, p2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a diagonal line several Mesh cells thick that is raised
|
||||
z_values[x][x] += 9.999;
|
||||
z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1] += 9.999; // We want the altered line several mesh points thick
|
||||
z_values[x][x] += 9.999f;
|
||||
z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// Allow the user to specify the height because 10mm is a little extreme in some cases.
|
||||
for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++) // Create a rectangular raised area in
|
||||
for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) // the center of the bed
|
||||
z_values[x][y] += parser.seen('C') ? g29_constant : 9.99;
|
||||
z_values[x][y] += parser.seen('C') ? g29_constant : 9.99f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -378,7 +378,7 @@
|
|||
tilt_mesh_based_on_probed_grid(true /* true says to do 3-Point leveling */ );
|
||||
restore_ubl_active_state_and_leave();
|
||||
}
|
||||
do_blocking_move_to_xy(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)));
|
||||
do_blocking_move_to_xy(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)));
|
||||
report_current_position();
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@
|
|||
|
||||
if (parser.seen('B')) {
|
||||
g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness((float) Z_CLEARANCE_BETWEEN_PROBES);
|
||||
if (ABS(g29_card_thickness) > 1.5) {
|
||||
if (ABS(g29_card_thickness) > 1.5f) {
|
||||
SERIAL_PROTOCOLLNPGM("?Error in Business Card measurement.");
|
||||
return;
|
||||
}
|
||||
|
@ -506,7 +506,7 @@
|
|||
}
|
||||
else {
|
||||
const float cvf = parser.value_float();
|
||||
switch ((int)truncf(cvf * 10.0) - 30) { // 3.1 -> 1
|
||||
switch ((int)truncf(cvf * 10.0f) - 30) { // 3.1 -> 1
|
||||
#if ENABLED(UBL_G29_P31)
|
||||
case 1: {
|
||||
|
||||
|
@ -516,8 +516,8 @@
|
|||
// P3.12 100X distance weighting
|
||||
// P3.13 1000X distance weighting, approaches simple average of nearest points
|
||||
|
||||
const float weight_power = (cvf - 3.10) * 100.0, // 3.12345 -> 2.345
|
||||
weight_factor = weight_power ? POW(10.0, weight_power) : 0;
|
||||
const float weight_power = (cvf - 3.10f) * 100.0f, // 3.12345 -> 2.345
|
||||
weight_factor = weight_power ? POW(10.0f, weight_power) : 0;
|
||||
smart_fill_wlsf(weight_factor);
|
||||
}
|
||||
break;
|
||||
|
@ -631,7 +631,7 @@
|
|||
}
|
||||
|
||||
void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float value) {
|
||||
float sum = 0.0;
|
||||
float sum = 0;
|
||||
int n = 0;
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
|
@ -645,7 +645,7 @@
|
|||
//
|
||||
// Sum the squares of difference from mean
|
||||
//
|
||||
float sum_of_diff_squared = 0.0;
|
||||
float sum_of_diff_squared = 0;
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
if (!isnan(z_values[x][y]))
|
||||
|
@ -783,7 +783,7 @@
|
|||
|
||||
float unified_bed_leveling::measure_point_with_encoder() {
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
move_z_with_encoder(0.01);
|
||||
move_z_with_encoder(0.01f);
|
||||
KEEPALIVE_STATE(IN_HANDLER);
|
||||
return current_position[Z_AXIS];
|
||||
}
|
||||
|
@ -794,8 +794,8 @@
|
|||
lcd_external_control = true;
|
||||
save_ubl_active_state_and_disable(); // Disable bed level correction for probing
|
||||
|
||||
do_blocking_move_to(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
|
||||
//, MIN(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) / 2.0);
|
||||
do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
|
||||
//, MIN(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) * 0.5f);
|
||||
planner.synchronize();
|
||||
|
||||
SERIAL_PROTOCOLPGM("Place shim under nozzle");
|
||||
|
@ -871,8 +871,8 @@
|
|||
|
||||
serialprintPGM(parser.seen('B') ? PSTR(MSG_UBL_BC_INSERT) : PSTR(MSG_UBL_BC_INSERT2));
|
||||
|
||||
const float z_step = 0.01; // existing behavior: 0.01mm per click, occasionally step
|
||||
//const float z_step = 1.0 / planner.axis_steps_per_mm[Z_AXIS]; // approx one step each click
|
||||
const float z_step = 0.01f; // existing behavior: 0.01mm per click, occasionally step
|
||||
//const float z_step = planner.steps_to_mm[Z_AXIS]; // approx one step each click
|
||||
|
||||
move_z_with_encoder(z_step);
|
||||
|
||||
|
@ -910,7 +910,7 @@
|
|||
lcd_quick_feedback(true);
|
||||
#endif
|
||||
|
||||
g29_constant = 0.0;
|
||||
g29_constant = 0;
|
||||
g29_repetition_cnt = 0;
|
||||
|
||||
g29_x_flag = parser.seenval('X');
|
||||
|
@ -1001,7 +1001,7 @@
|
|||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
if (parser.seenval('F')) {
|
||||
const float fh = parser.value_float();
|
||||
if (!WITHIN(fh, 0.0, 100.0)) {
|
||||
if (!WITHIN(fh, 0, 100)) {
|
||||
SERIAL_PROTOCOLLNPGM("?(F)ade height for Bed Level Correction not plausible.\n");
|
||||
return UBL_ERR;
|
||||
}
|
||||
|
@ -1223,7 +1223,7 @@
|
|||
|
||||
mesh_index_pair out_mesh;
|
||||
out_mesh.x_index = out_mesh.y_index = -1;
|
||||
out_mesh.distance = -99999.99;
|
||||
out_mesh.distance = -99999.99f;
|
||||
|
||||
for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
||||
for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
||||
|
@ -1239,7 +1239,7 @@
|
|||
found_a_NAN = true;
|
||||
|
||||
int8_t closest_x = -1, closest_y = -1;
|
||||
float d1, d2 = 99999.9;
|
||||
float d1, d2 = 99999.9f;
|
||||
for (int8_t k = 0; k < GRID_MAX_POINTS_X; k++) {
|
||||
for (int8_t l = 0; l < GRID_MAX_POINTS_Y; l++) {
|
||||
if (!isnan(z_values[k][l])) {
|
||||
|
@ -1249,7 +1249,7 @@
|
|||
// last half of the mesh (when every unprobed mesh point is one index
|
||||
// from a probed location).
|
||||
|
||||
d1 = HYPOT(i - k, j - l) + (1.0 / ((millis() % 47) + 13));
|
||||
d1 = HYPOT(i - k, j - l) + (1.0f / ((millis() % 47) + 13));
|
||||
|
||||
if (d1 < d2) { // found a closer distance from invalid mesh point at (i,j) to defined mesh point at (k,l)
|
||||
d2 = d1; // found a closer location with
|
||||
|
@ -1276,7 +1276,7 @@
|
|||
if (!found_a_real && found_a_NAN) { // if the mesh is totally unpopulated, start the probing
|
||||
out_mesh.x_index = GRID_MAX_POINTS_X / 2;
|
||||
out_mesh.y_index = GRID_MAX_POINTS_Y / 2;
|
||||
out_mesh.distance = 1.0;
|
||||
out_mesh.distance = 1;
|
||||
}
|
||||
return out_mesh;
|
||||
}
|
||||
|
@ -1284,13 +1284,13 @@
|
|||
mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const MeshPointType type, const float &rx, const float &ry, const bool probe_as_reference, uint16_t bits[16]) {
|
||||
mesh_index_pair out_mesh;
|
||||
out_mesh.x_index = out_mesh.y_index = -1;
|
||||
out_mesh.distance = -99999.9;
|
||||
out_mesh.distance = -99999.9f;
|
||||
|
||||
// Get our reference position. Either the nozzle or probe location.
|
||||
const float px = rx - (probe_as_reference == USE_PROBE_AS_REFERENCE ? X_PROBE_OFFSET_FROM_EXTRUDER : 0),
|
||||
py = ry - (probe_as_reference == USE_PROBE_AS_REFERENCE ? Y_PROBE_OFFSET_FROM_EXTRUDER : 0);
|
||||
|
||||
float best_so_far = 99999.99;
|
||||
float best_so_far = 99999.99f;
|
||||
|
||||
for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
||||
for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
||||
|
@ -1317,7 +1317,7 @@
|
|||
|
||||
// factor in the distance from the current location for the normal case
|
||||
// so the nozzle isn't running all over the bed.
|
||||
distance += HYPOT(current_position[X_AXIS] - mx, current_position[Y_AXIS] - my) * 0.1;
|
||||
distance += HYPOT(current_position[X_AXIS] - mx, current_position[Y_AXIS] - my) * 0.1f;
|
||||
if (distance < best_so_far) {
|
||||
best_so_far = distance; // We found a closer location with
|
||||
out_mesh.x_index = i; // the specified type of mesh value.
|
||||
|
@ -1398,8 +1398,8 @@
|
|||
lcd_refresh();
|
||||
|
||||
float new_z = z_values[location.x_index][location.y_index];
|
||||
if (isnan(new_z)) new_z = 0.0; // Invalid points begin at 0
|
||||
new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
|
||||
if (isnan(new_z)) new_z = 0; // Invalid points begin at 0
|
||||
new_z = FLOOR(new_z * 1000) * 0.001f; // Chop off digits after the 1000ths place
|
||||
|
||||
lcd_mesh_edit_setup(new_z);
|
||||
|
||||
|
@ -1458,7 +1458,7 @@
|
|||
if (z_values[x1][y1] < z_values[x2][y2]) // Angled downward?
|
||||
z_values[x][y] = z_values[x1][y1]; // Use nearest (maybe a little too high.)
|
||||
else
|
||||
z_values[x][y] = 2.0 * z_values[x1][y1] - z_values[x2][y2]; // Angled upward...
|
||||
z_values[x][y] = 2.0f * z_values[x1][y1] - z_values[x2][y2]; // Angled upward...
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1507,8 +1507,8 @@
|
|||
|
||||
float measured_z;
|
||||
|
||||
const float dx = float(x_max - x_min) / (g29_grid_size - 1.0),
|
||||
dy = float(y_max - y_min) / (g29_grid_size - 1.0);
|
||||
const float dx = float(x_max - x_min) / (g29_grid_size - 1),
|
||||
dy = float(y_max - y_min) / (g29_grid_size - 1);
|
||||
|
||||
struct linear_fit_data lsf_results;
|
||||
|
||||
|
@ -1559,10 +1559,12 @@
|
|||
incremental_LSF(&lsf_results, PROBE_PT_3_X, PROBE_PT_3_Y, measured_z);
|
||||
}
|
||||
}
|
||||
|
||||
STOW_PROBE();
|
||||
#ifdef Z_AFTER_PROBING
|
||||
move_z_after_probing();
|
||||
#endif
|
||||
|
||||
if (abort_flag) {
|
||||
SERIAL_ECHOPGM("?Error probing point. Aborting operation.\n");
|
||||
return;
|
||||
|
@ -1629,7 +1631,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
vector_3 normal = vector_3(lsf_results.A, lsf_results.B, 1.0000).get_normal();
|
||||
vector_3 normal = vector_3(lsf_results.A, lsf_results.B, 1).get_normal();
|
||||
|
||||
if (g29_verbose_level > 2) {
|
||||
SERIAL_ECHOPGM("bed plane normal = [");
|
||||
|
@ -1708,7 +1710,7 @@
|
|||
* The only difference is just 3 points are used in the calculations. That fact guarantees
|
||||
* each probed point should have an exact match when a get_z_correction() for that location
|
||||
* is calculated. The Z error between the probed point locations and the get_z_correction()
|
||||
* numbers for those locations should be 0.000
|
||||
* numbers for those locations should be 0.
|
||||
*/
|
||||
#if 0
|
||||
float t, t1, d;
|
||||
|
@ -1738,13 +1740,13 @@
|
|||
SERIAL_EOL();
|
||||
|
||||
t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
|
||||
d = t + normal.z * 0.000;
|
||||
d = t + normal.z * 0;
|
||||
SERIAL_ECHOPGM("D from home location with Z=0 : ");
|
||||
SERIAL_ECHO_F(d, 6);
|
||||
SERIAL_EOL();
|
||||
|
||||
t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
|
||||
d = t + get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT); // normal.z * 0.000;
|
||||
d = t + get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT); // normal.z * 0;
|
||||
SERIAL_ECHOPGM("D from home location using mesh value for Z: ");
|
||||
SERIAL_ECHO_F(d, 6);
|
||||
|
||||
|
@ -1795,7 +1797,7 @@
|
|||
if (TEST(bitmap[jx], jy)) {
|
||||
const float ry = mesh_index_to_ypos(jy),
|
||||
rz = z_values[jx][jy],
|
||||
w = 1.0 + weight_scaled / HYPOT((rx - px), (ry - py));
|
||||
w = 1 + weight_scaled / HYPOT((rx - px), (ry - py));
|
||||
incremental_WLSF(&lsf_results, rx, ry, rz, w);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
FINAL_MOVE:
|
||||
|
||||
// The distance is always MESH_X_DIST so multiply by the constant reciprocal.
|
||||
const float xratio = (end[X_AXIS] - mesh_index_to_xpos(cell_dest_xi)) * (1.0 / (MESH_X_DIST));
|
||||
const float xratio = (end[X_AXIS] - mesh_index_to_xpos(cell_dest_xi)) * (1.0f / (MESH_X_DIST));
|
||||
|
||||
float z1 = z_values[cell_dest_xi ][cell_dest_yi ] + xratio *
|
||||
(z_values[cell_dest_xi + 1][cell_dest_yi ] - z_values[cell_dest_xi][cell_dest_yi ]),
|
||||
|
@ -107,7 +107,7 @@
|
|||
if (cell_dest_xi >= GRID_MAX_POINTS_X - 1) z1 = z2 = 0.0;
|
||||
|
||||
// X cell-fraction done. Interpolate the two Z offsets with the Y fraction for the final Z offset.
|
||||
const float yratio = (end[Y_AXIS] - mesh_index_to_ypos(cell_dest_yi)) * (1.0 / (MESH_Y_DIST)),
|
||||
const float yratio = (end[Y_AXIS] - mesh_index_to_ypos(cell_dest_yi)) * (1.0f / (MESH_Y_DIST)),
|
||||
z0 = cell_dest_yi < GRID_MAX_POINTS_Y - 1 ? (z1 + (z2 - z1) * yratio) * planner.fade_scaling_factor_for_z(end[Z_AXIS]) : 0.0;
|
||||
|
||||
// Undefined parts of the Mesh in z_values[][] are NAN.
|
||||
|
@ -435,14 +435,14 @@
|
|||
#if IS_KINEMATIC
|
||||
const float seconds = cartesian_xy_mm / feedrate; // seconds to move xy distance at requested rate
|
||||
uint16_t segments = lroundf(delta_segments_per_second * seconds), // preferred number of segments for distance @ feedrate
|
||||
seglimit = lroundf(cartesian_xy_mm * (1.0 / (DELTA_SEGMENT_MIN_LENGTH))); // number of segments at minimum segment length
|
||||
seglimit = lroundf(cartesian_xy_mm * (1.0f / (DELTA_SEGMENT_MIN_LENGTH))); // number of segments at minimum segment length
|
||||
NOMORE(segments, seglimit); // limit to minimum segment length (fewer segments)
|
||||
#else
|
||||
uint16_t segments = lroundf(cartesian_xy_mm * (1.0 / (DELTA_SEGMENT_MIN_LENGTH))); // cartesian fixed segment length
|
||||
uint16_t segments = lroundf(cartesian_xy_mm * (1.0f / (DELTA_SEGMENT_MIN_LENGTH))); // cartesian fixed segment length
|
||||
#endif
|
||||
|
||||
NOLESS(segments, 1U); // must have at least one segment
|
||||
const float inv_segments = 1.0 / segments; // divide once, multiply thereafter
|
||||
const float inv_segments = 1.0f / segments; // divide once, multiply thereafter
|
||||
|
||||
#if IS_SCARA // scale the feed rate from mm/s to degrees/s
|
||||
scara_feed_factor = cartesian_xy_mm * inv_segments * feedrate;
|
||||
|
@ -495,8 +495,8 @@
|
|||
// in top of loop and again re-find same adjacent cell and use it, just less efficient
|
||||
// for mesh inset area.
|
||||
|
||||
int8_t cell_xi = (raw[X_AXIS] - (MESH_MIN_X)) * (1.0 / (MESH_X_DIST)),
|
||||
cell_yi = (raw[Y_AXIS] - (MESH_MIN_Y)) * (1.0 / (MESH_Y_DIST));
|
||||
int8_t cell_xi = (raw[X_AXIS] - (MESH_MIN_X)) * (1.0f / (MESH_X_DIST)),
|
||||
cell_yi = (raw[Y_AXIS] - (MESH_MIN_Y)) * (1.0f / (MESH_Y_DIST));
|
||||
|
||||
cell_xi = constrain(cell_xi, 0, (GRID_MAX_POINTS_X) - 1);
|
||||
cell_yi = constrain(cell_yi, 0, (GRID_MAX_POINTS_Y) - 1);
|
||||
|
@ -517,15 +517,15 @@
|
|||
float cx = raw[X_AXIS] - x0, // cell-relative x and y
|
||||
cy = raw[Y_AXIS] - y0;
|
||||
|
||||
const float z_xmy0 = (z_x1y0 - z_x0y0) * (1.0 / (MESH_X_DIST)), // z slope per x along y0 (lower left to lower right)
|
||||
z_xmy1 = (z_x1y1 - z_x0y1) * (1.0 / (MESH_X_DIST)); // z slope per x along y1 (upper left to upper right)
|
||||
const float z_xmy0 = (z_x1y0 - z_x0y0) * (1.0f / (MESH_X_DIST)), // z slope per x along y0 (lower left to lower right)
|
||||
z_xmy1 = (z_x1y1 - z_x0y1) * (1.0f / (MESH_X_DIST)); // z slope per x along y1 (upper left to upper right)
|
||||
|
||||
float z_cxy0 = z_x0y0 + z_xmy0 * cx; // z height along y0 at cx (changes for each cx in cell)
|
||||
|
||||
const float z_cxy1 = z_x0y1 + z_xmy1 * cx, // z height along y1 at cx
|
||||
z_cxyd = z_cxy1 - z_cxy0; // z height difference along cx from y0 to y1
|
||||
|
||||
float z_cxym = z_cxyd * (1.0 / (MESH_Y_DIST)); // z slope per y along cx from y0 to y1 (changes for each cx in cell)
|
||||
float z_cxym = z_cxyd * (1.0f / (MESH_Y_DIST)); // z slope per y along cx from y0 to y1 (changes for each cx in cell)
|
||||
|
||||
// float z_cxcy = z_cxy0 + z_cxym * cy; // interpolated mesh z height along cx at cy (do inside the segment loop)
|
||||
|
||||
|
@ -534,7 +534,7 @@
|
|||
// each change by a constant for fixed segment lengths.
|
||||
|
||||
const float z_sxy0 = z_xmy0 * diff[X_AXIS], // per-segment adjustment to z_cxy0
|
||||
z_sxym = (z_xmy1 - z_xmy0) * (1.0 / (MESH_Y_DIST)) * diff[X_AXIS]; // per-segment adjustment to z_cxym
|
||||
z_sxym = (z_xmy1 - z_xmy0) * (1.0f / (MESH_Y_DIST)) * diff[X_AXIS]; // per-segment adjustment to z_cxym
|
||||
|
||||
for (;;) { // for all segments within this mesh cell
|
||||
|
||||
|
|
|
@ -467,7 +467,7 @@ uint16_t max_display_update_time = 0;
|
|||
|
||||
#if IS_KINEMATIC
|
||||
bool processing_manual_move = false;
|
||||
float manual_move_offset = 0.0;
|
||||
float manual_move_offset = 0;
|
||||
#else
|
||||
constexpr bool processing_manual_move = false;
|
||||
#endif
|
||||
|
@ -1275,13 +1275,13 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
ubl_encoderPosition = (ubl.encoder_diff > 0) ? 1 : -1;
|
||||
ubl.encoder_diff = 0;
|
||||
|
||||
mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005 / 2.0;
|
||||
mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005f / 2.0f;
|
||||
mesh_edit_value = mesh_edit_accumulator;
|
||||
encoderPosition = 0;
|
||||
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
|
||||
|
||||
const int32_t rounded = (int32_t)(mesh_edit_value * 1000.0);
|
||||
mesh_edit_value = float(rounded - (rounded % 5L)) / 1000.0;
|
||||
const int32_t rounded = (int32_t)(mesh_edit_value * 1000);
|
||||
mesh_edit_value = float(rounded - (rounded % 5L)) / 1000;
|
||||
}
|
||||
|
||||
if (lcdDrawUpdate) {
|
||||
|
@ -1409,7 +1409,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
// Leveling Fade Height
|
||||
//
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) && DISABLED(SLIM_LCD_MENUS)
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0, 100, _lcd_set_z_fade_height);
|
||||
#endif
|
||||
|
||||
//
|
||||
|
@ -1968,7 +1968,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
//
|
||||
if (encoderPosition) {
|
||||
const float z = current_position[Z_AXIS] + float((int32_t)encoderPosition) * (MBL_Z_STEP);
|
||||
line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5, (LCD_PROBE_Z_RANGE) * 0.5));
|
||||
line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5f, (LCD_PROBE_Z_RANGE) * 0.5f));
|
||||
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
|
||||
encoderPosition = 0;
|
||||
}
|
||||
|
@ -1978,7 +1978,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
//
|
||||
if (lcdDrawUpdate) {
|
||||
const float v = current_position[Z_AXIS];
|
||||
lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001 : 0.0001), '+'));
|
||||
lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2560,7 +2560,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
MENU_ITEM(submenu, MSG_UBL_TOOLS, _lcd_ubl_tools_menu);
|
||||
MENU_ITEM(gcode, MSG_UBL_INFO_UBL, PSTR("G29 W"));
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0, 100, _lcd_set_z_fade_height);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
@ -2616,7 +2616,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
|
||||
// Z Fade Height
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0, 100, _lcd_set_z_fade_height);
|
||||
#endif
|
||||
|
||||
//
|
||||
|
@ -2702,7 +2702,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
|
||||
}
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0, 100, _lcd_set_z_fade_height);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -2866,15 +2866,15 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
void lcd_delta_settings() {
|
||||
START_MENU();
|
||||
MENU_BACK(MSG_DELTA_CALIBRATE);
|
||||
MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10.0, delta_height + 10.0, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, "Ex", &delta_endstop_adj[A_AXIS], -5.0, 5.0, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, "Ey", &delta_endstop_adj[B_AXIS], -5.0, 5.0, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, "Ez", &delta_endstop_adj[C_AXIS], -5.0, 5.0, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_RADIUS, &delta_radius, delta_radius - 5.0, delta_radius + 5.0, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, "Tx", &delta_tower_angle_trim[A_AXIS], -5.0, 5.0, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, "Ty", &delta_tower_angle_trim[B_AXIS], -5.0, 5.0, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, "Tz", &delta_tower_angle_trim[C_AXIS], -5.0, 5.0, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_DIAG_ROD, &delta_diagonal_rod, delta_diagonal_rod - 5.0, delta_diagonal_rod + 5.0, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10, delta_height + 10, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, "Ex", &delta_endstop_adj[A_AXIS], -5, 5, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, "Ey", &delta_endstop_adj[B_AXIS], -5, 5, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, "Ez", &delta_endstop_adj[C_AXIS], -5, 5, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_RADIUS, &delta_radius, delta_radius - 5, delta_radius + 5, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, "Tx", &delta_tower_angle_trim[A_AXIS], -5, 5, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, "Ty", &delta_tower_angle_trim[B_AXIS], -5, 5, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, "Tz", &delta_tower_angle_trim[C_AXIS], -5, 5, _recalc_delta_settings);
|
||||
MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_DIAG_ROD, &delta_diagonal_rod, delta_diagonal_rod - 5, delta_diagonal_rod + 5, _recalc_delta_settings);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
|
@ -2930,7 +2930,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
destination[manual_move_axis] += manual_move_offset;
|
||||
|
||||
// Reset for the next move
|
||||
manual_move_offset = 0.0;
|
||||
manual_move_offset = 0;
|
||||
manual_move_axis = (int8_t)NO_AXIS;
|
||||
|
||||
// DELTA and SCARA machines use segmented moves, which could fill the planner during the call to
|
||||
|
@ -2970,7 +2970,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
#endif
|
||||
manual_move_e_index = eindex >= 0 ? eindex : active_extruder;
|
||||
#endif
|
||||
manual_move_start_time = millis() + (move_menu_scale < 0.99 ? 0UL : 250UL); // delay for bigger moves
|
||||
manual_move_start_time = millis() + (move_menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
|
||||
manual_move_axis = (int8_t)axis;
|
||||
}
|
||||
|
||||
|
@ -3054,7 +3054,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
+ manual_move_offset
|
||||
#endif
|
||||
, axis);
|
||||
lcd_implementation_drawedit(name, move_menu_scale >= 0.1 ? ftostr41sign(pos) : ftostr43sign(pos));
|
||||
lcd_implementation_drawedit(name, move_menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr43sign(pos));
|
||||
}
|
||||
}
|
||||
void lcd_move_x() { _lcd_move_xyz(PSTR(MSG_MOVE_X), X_AXIS); }
|
||||
|
@ -3139,9 +3139,9 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
move_menu_scale = scale;
|
||||
lcd_goto_screen(_manual_move_func_ptr);
|
||||
}
|
||||
void lcd_move_menu_10mm() { _goto_manual_move(10.0); }
|
||||
void lcd_move_menu_1mm() { _goto_manual_move( 1.0); }
|
||||
void lcd_move_menu_01mm() { _goto_manual_move( 0.1); }
|
||||
void lcd_move_menu_10mm() { _goto_manual_move(10); }
|
||||
void lcd_move_menu_1mm() { _goto_manual_move( 1); }
|
||||
void lcd_move_menu_01mm() { _goto_manual_move( 0.1f); }
|
||||
|
||||
void _lcd_move_distance_menu(const AxisEnum axis, const screenFunc_t func) {
|
||||
_manual_move_func_ptr = func;
|
||||
|
@ -3516,8 +3516,8 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
//
|
||||
#if ENABLED(AUTOTEMP) && HAS_TEMP_HOTEND
|
||||
MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &planner.autotemp_enabled);
|
||||
MENU_ITEM_EDIT(float3, MSG_MIN, &planner.autotemp_min, 0, HEATER_0_MAXTEMP - 15);
|
||||
MENU_ITEM_EDIT(float3, MSG_MAX, &planner.autotemp_max, 0, HEATER_0_MAXTEMP - 15);
|
||||
MENU_ITEM_EDIT(float3, MSG_MIN, &planner.autotemp_min, 0, float(HEATER_0_MAXTEMP) - 15);
|
||||
MENU_ITEM_EDIT(float3, MSG_MAX, &planner.autotemp_max, 0, float(HEATER_0_MAXTEMP) - 15);
|
||||
MENU_ITEM_EDIT(float52, MSG_FACTOR, &planner.autotemp_factor, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
|
@ -3535,7 +3535,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
raw_Ki = unscalePID_i(PID_PARAM(Ki, eindex)); \
|
||||
raw_Kd = unscalePID_d(PID_PARAM(Kd, eindex)); \
|
||||
MENU_ITEM_EDIT(float52sign, MSG_PID_P ELABEL, &PID_PARAM(Kp, eindex), 1, 9990); \
|
||||
MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_PID_I ELABEL, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_E ## eindex); \
|
||||
MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_PID_I ELABEL, &raw_Ki, 0.01f, 9990, copy_and_scalePID_i_E ## eindex); \
|
||||
MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_PID_D ELABEL, &raw_Kd, 1, 9990, copy_and_scalePID_d_E ## eindex)
|
||||
|
||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||
|
@ -3657,7 +3657,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
if (e == active_extruder)
|
||||
_planner_refresh_positioning();
|
||||
else
|
||||
planner.steps_to_mm[E_AXIS + e] = 1.0 / planner.axis_steps_per_mm[E_AXIS + e];
|
||||
planner.steps_to_mm[E_AXIS + e] = 1.0f / planner.axis_steps_per_mm[E_AXIS + e];
|
||||
}
|
||||
void _planner_refresh_e0_positioning() { _planner_refresh_e_positioning(0); }
|
||||
void _planner_refresh_e1_positioning() { _planner_refresh_e_positioning(1); }
|
||||
|
@ -3753,14 +3753,14 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
MENU_BACK(MSG_MOTION);
|
||||
|
||||
#if ENABLED(JUNCTION_DEVIATION)
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.01, 0.3, planner.recalculate_max_e_jerk);
|
||||
MENU_ITEM_EDIT_CALLBACK(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.01f, 0.3f, planner.recalculate_max_e_jerk);
|
||||
#else
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VA_JERK, &planner.max_jerk[A_AXIS], 1, 990);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VB_JERK, &planner.max_jerk[B_AXIS], 1, 990);
|
||||
#if ENABLED(DELTA)
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 1, 990);
|
||||
#else
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float52sign, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 0.1, 990);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float52sign, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 0.1f, 990);
|
||||
#endif
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VE_JERK, &planner.max_jerk[E_AXIS], 1, 990);
|
||||
#endif
|
||||
|
@ -3858,17 +3858,17 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
|
||||
if (parser.volumetric_enabled) {
|
||||
#if EXTRUDERS == 1
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &planner.filament_size[0], 1.5, 3.25, planner.calculate_volumetric_multipliers);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &planner.filament_size[0], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
||||
#else // EXTRUDERS > 1
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5, 3.25, planner.calculate_volumetric_multipliers);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E1, &planner.filament_size[0], 1.5, 3.25, planner.calculate_volumetric_multipliers);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E2, &planner.filament_size[1], 1.5, 3.25, planner.calculate_volumetric_multipliers);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E1, &planner.filament_size[0], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E2, &planner.filament_size[1], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
||||
#if EXTRUDERS > 2
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E3, &planner.filament_size[2], 1.5, 3.25, planner.calculate_volumetric_multipliers);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E3, &planner.filament_size[2], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
||||
#if EXTRUDERS > 3
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E4, &planner.filament_size[3], 1.5, 3.25, planner.calculate_volumetric_multipliers);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E4, &planner.filament_size[3], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
||||
#if EXTRUDERS > 4
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E5, &planner.filament_size[4], 1.5, 3.25, planner.calculate_volumetric_multipliers);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E5, &planner.filament_size[4], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
||||
#endif // EXTRUDERS > 4
|
||||
#endif // EXTRUDERS > 3
|
||||
#endif // EXTRUDERS > 2
|
||||
|
@ -3881,39 +3881,39 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
|
||||
EXTRUDE_MAXLENGTH
|
||||
#else
|
||||
999.0f
|
||||
999
|
||||
#endif
|
||||
;
|
||||
|
||||
#if EXTRUDERS == 1
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD, &filament_change_unload_length[0], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD, &filament_change_unload_length[0], 0, extrude_maxlength);
|
||||
#else // EXTRUDERS > 1
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD, &filament_change_unload_length[active_extruder], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E1, &filament_change_unload_length[0], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E2, &filament_change_unload_length[1], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD, &filament_change_unload_length[active_extruder], 0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E1, &filament_change_unload_length[0], 0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E2, &filament_change_unload_length[1], 0, extrude_maxlength);
|
||||
#if EXTRUDERS > 2
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E3, &filament_change_unload_length[2], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E3, &filament_change_unload_length[2], 0, extrude_maxlength);
|
||||
#if EXTRUDERS > 3
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E4, &filament_change_unload_length[3], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E4, &filament_change_unload_length[3], 0, extrude_maxlength);
|
||||
#if EXTRUDERS > 4
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E5, &filament_change_unload_length[4], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E5, &filament_change_unload_length[4], 0, extrude_maxlength);
|
||||
#endif // EXTRUDERS > 4
|
||||
#endif // EXTRUDERS > 3
|
||||
#endif // EXTRUDERS > 2
|
||||
#endif // EXTRUDERS > 1
|
||||
|
||||
#if EXTRUDERS == 1
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD, &filament_change_load_length[0], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD, &filament_change_load_length[0], 0, extrude_maxlength);
|
||||
#else // EXTRUDERS > 1
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD, &filament_change_load_length[active_extruder], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E1, &filament_change_load_length[0], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E2, &filament_change_load_length[1], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD, &filament_change_load_length[active_extruder], 0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E1, &filament_change_load_length[0], 0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E2, &filament_change_load_length[1], 0, extrude_maxlength);
|
||||
#if EXTRUDERS > 2
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E3, &filament_change_load_length[2], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E3, &filament_change_load_length[2], 0, extrude_maxlength);
|
||||
#if EXTRUDERS > 3
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E4, &filament_change_load_length[3], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E4, &filament_change_load_length[3], 0, extrude_maxlength);
|
||||
#if EXTRUDERS > 4
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E5, &filament_change_load_length[4], 0.0, extrude_maxlength);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E5, &filament_change_load_length[4], 0, extrude_maxlength);
|
||||
#endif // EXTRUDERS > 4
|
||||
#endif // EXTRUDERS > 3
|
||||
#endif // EXTRUDERS > 2
|
||||
|
@ -4813,9 +4813,9 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
if ((int32_t)encoderPosition < 0) encoderPosition = 0; \
|
||||
if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
|
||||
if (lcdDrawUpdate) \
|
||||
lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) * (1.0 / _scale))); \
|
||||
lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) * (1.0f / _scale))); \
|
||||
if (lcd_clicked || (liveEdit && lcdDrawUpdate)) { \
|
||||
_type value = ((_type)((int32_t)encoderPosition + minEditValue)) * (1.0 / _scale); \
|
||||
_type value = ((_type)((int32_t)encoderPosition + minEditValue)) * (1.0f / _scale); \
|
||||
if (editValue != NULL) *((_type*)editValue) = value; \
|
||||
if (callbackFunc && (liveEdit || lcd_clicked)) (*callbackFunc)(); \
|
||||
if (lcd_clicked) lcd_goto_previous_menu(); \
|
||||
|
@ -4846,14 +4846,14 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
|||
|
||||
DEFINE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1);
|
||||
DEFINE_MENU_EDIT_TYPE(uint8_t, int8, i8tostr3, 1);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float3, ftostr3, 1.0);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float52, ftostr52, 100.0);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000.0);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float5, ftostr5rj, 0.01);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float51, ftostr51sign, 10.0);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float52sign, ftostr52sign, 100.0);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float62, ftostr62rj, 100.0);
|
||||
DEFINE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float3, ftostr3, 1.0f);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float52, ftostr52, 100.0f);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000.0f);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float5, ftostr5rj, 0.01f);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float51, ftostr51sign, 10.0f);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float52sign, ftostr52sign, 100.0f);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float62, ftostr62rj, 100.0f);
|
||||
DEFINE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01f);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -5235,7 +5235,7 @@ void lcd_update() {
|
|||
if (lastEncoderMovementMillis) {
|
||||
// Note that the rate is always calculated between two passes through the
|
||||
// loop and that the abs of the encoderDiff value is tracked.
|
||||
float encoderStepRate = float(encoderMovementSteps) / float(ms - lastEncoderMovementMillis) * 1000.0;
|
||||
float encoderStepRate = float(encoderMovementSteps) / float(ms - lastEncoderMovementMillis) * 1000;
|
||||
|
||||
if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100;
|
||||
else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10;
|
||||
|
|
|
@ -73,14 +73,14 @@ void safe_delay(millis_t ms);
|
|||
char* ftostr62rj(const float &x);
|
||||
|
||||
// Convert float to rj string with 123 or -12 format
|
||||
FORCE_INLINE char* ftostr3(const float &x) { return itostr3(int(x + (x < 0 ? -0.5 : 0.5))); }
|
||||
FORCE_INLINE char* ftostr3(const float &x) { return itostr3(int(x + (x < 0 ? -0.5f : 0.5f))); }
|
||||
|
||||
#if ENABLED(LCD_DECIMAL_SMALL_XY)
|
||||
// Convert float to rj string with 1234, _123, 12.3, _1.2, -123, _-12, or -1.2 format
|
||||
char* ftostr4sign(const float &fx);
|
||||
#else
|
||||
// Convert float to rj string with 1234, _123, -123, __12, _-12, ___1, or __-1 format
|
||||
FORCE_INLINE char* ftostr4sign(const float &x) { return itostr4sign(int(x + (x < 0 ? -0.5 : 0.5))); }
|
||||
FORCE_INLINE char* ftostr4sign(const float &x) { return itostr4sign(int(x + (x < 0 ? -0.5f : 0.5f))); }
|
||||
#endif
|
||||
|
||||
#endif // ULTRA_LCD || (DEBUG_LEVELING_FEATURE && (MESH_BED_LEVELING || (HAS_ABL && !ABL_PLANAR)))
|
||||
|
|
|
@ -69,7 +69,7 @@ vector_3 vector_3::get_normal() {
|
|||
float vector_3::get_length() { return SQRT(sq(x) + sq(y) + sq(z)); }
|
||||
|
||||
void vector_3::normalize() {
|
||||
const float inv_length = 1.0 / get_length();
|
||||
const float inv_length = RSQRT(sq(x) + sq(y) + sq(z));
|
||||
x *= inv_length;
|
||||
y *= inv_length;
|
||||
z *= inv_length;
|
||||
|
|
Loading…
Reference in a new issue