Use bit flags for homed/known

This commit is contained in:
Scott Lahteine
2018-06-11 21:29:31 -05:00
parent 4832be52d7
commit f2c3b0d476
13 changed files with 50 additions and 49 deletions

View File

@ -73,7 +73,7 @@ void recalc_delta_settings() {
delta_diagonal_rod_2_tower[B_AXIS] = sq(delta_diagonal_rod + drt[B_AXIS]);
delta_diagonal_rod_2_tower[C_AXIS] = sq(delta_diagonal_rod + drt[C_AXIS]);
update_software_endstops(Z_AXIS);
axis_homed[X_AXIS] = axis_homed[Y_AXIS] = axis_homed[Z_AXIS] = false;
axis_homed = 0;
}
/**

View File

@ -957,13 +957,13 @@ void prepare_move_to_destination() {
bool axis_unhomed_error(const bool x/*=true*/, const bool y/*=true*/, const bool z/*=true*/) {
#if ENABLED(HOME_AFTER_DEACTIVATE)
const bool xx = x && !axis_known_position[X_AXIS],
yy = y && !axis_known_position[Y_AXIS],
zz = z && !axis_known_position[Z_AXIS];
const bool xx = x && !TEST(axis_known_position, X_AXIS),
yy = y && !TEST(axis_known_position, Y_AXIS),
zz = z && !TEST(axis_known_position, Z_AXIS);
#else
const bool xx = x && !axis_homed[X_AXIS],
yy = y && !axis_homed[Y_AXIS],
zz = z && !axis_homed[Z_AXIS];
const bool xx = x && !TEST(axis_homed, X_AXIS),
yy = y && !TEST(axis_homed, Y_AXIS),
zz = z && !TEST(axis_homed, Z_AXIS);
#endif
if (xx || yy || zz) {
SERIAL_ECHO_START();
@ -1173,7 +1173,8 @@ void set_axis_is_at_home(const AxisEnum axis) {
}
#endif
axis_known_position[axis] = axis_homed[axis] = true;
SBI(axis_known_position, axis);
SBI(axis_homed, axis);
#if HAS_POSITION_SHIFT
position_shift[axis] = 0;

View File

@ -386,7 +386,7 @@ bool set_probe_deployed(const bool deploy) {
// For beds that fall when Z is powered off only raise for trusted Z
#if ENABLED(UNKNOWN_Z_NO_RAISE)
const bool unknown_condition = axis_known_position[Z_AXIS];
const bool unknown_condition = TEST(axis_known_position, Z_AXIS);
#else
constexpr float unknown_condition = true;
#endif
@ -562,7 +562,7 @@ static float run_z_probe() {
// Stop the probe before it goes too low to prevent damage.
// If Z isn't known then probe to -10mm.
const float z_probe_low_point = axis_known_position[Z_AXIS] ? -zprobe_zoffset + Z_PROBE_LOW_POINT : -10.0;
const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -zprobe_zoffset + Z_PROBE_LOW_POINT : -10.0;
// Double-probing does a fast probe followed by a slow probe
#if MULTIPLE_PROBING == 2

View File

@ -31,7 +31,7 @@
#include "../inc/MarlinConfig.h"
#if ENABLED(BABYSTEPPING)
extern bool axis_known_position[XYZ];
extern uint8_t axis_known_position;
#endif
#if ENABLED(AUTO_POWER_CONTROL)
@ -504,7 +504,7 @@ class Temperature {
#if ENABLED(BABYSTEPPING)
static void babystep_axis(const AxisEnum axis, const int16_t distance) {
if (axis_known_position[axis]) {
if (TEST(axis_known_position, axis)) {
#if IS_CORE
#if ENABLED(BABYSTEP_XY)
switch (axis) {

View File

@ -80,7 +80,7 @@
}
}
#endif // SWITCHING_EXTRUDER
#endif // DO_SWITCH_EXTRUDER
#if ENABLED(SWITCHING_NOZZLE)