♻️ Refactor axis counts and loops
This commit is contained in:
committed by
Scott Lahteine
parent
f7d28ce1d6
commit
26a244325b
@ -104,7 +104,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
|
||||
|
||||
const float f_corr = float(correction) / 255.0f;
|
||||
|
||||
LOOP_XYZ(axis) {
|
||||
LOOP_LINEAR_AXES(axis) {
|
||||
if (distance_mm[axis]) {
|
||||
const bool reversing = TEST(dm,axis);
|
||||
|
||||
|
@ -73,7 +73,7 @@ uint8_t MCP4728::analogWrite(const uint8_t channel, const uint16_t value) {
|
||||
uint8_t MCP4728::eepromWrite() {
|
||||
Wire.beginTransmission(I2C_ADDRESS(DAC_DEV_ADDRESS));
|
||||
Wire.write(SEQWRITE);
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
Wire.write(DAC_STEPPER_VREF << 7 | DAC_STEPPER_GAIN << 4 | highByte(dac_values[i]));
|
||||
Wire.write(lowByte(dac_values[i]));
|
||||
}
|
||||
@ -135,7 +135,7 @@ void MCP4728::setDrvPct(xyze_uint_t &pct) {
|
||||
*/
|
||||
uint8_t MCP4728::fastWrite() {
|
||||
Wire.beginTransmission(I2C_ADDRESS(DAC_DEV_ADDRESS));
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
Wire.write(highByte(dac_values[i]));
|
||||
Wire.write(lowByte(dac_values[i]));
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ static float dac_amps(int8_t n) { return mcp4728.getValue(dac_order[n]) * 0.125
|
||||
|
||||
uint8_t StepperDAC::get_current_percent(const AxisEnum axis) { return mcp4728.getDrvPct(dac_order[axis]); }
|
||||
void StepperDAC::set_current_percents(xyze_uint8_t &pct) {
|
||||
LOOP_XYZE(i) dac_channel_pct[i] = pct[dac_order[i]];
|
||||
LOOP_LOGICAL_AXES(i) dac_channel_pct[i] = pct[dac_order[i]];
|
||||
mcp4728.setDrvPct(dac_channel_pct);
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ bool I2CPositionEncoder::test_axis() {
|
||||
ec = false;
|
||||
|
||||
xyze_pos_t startCoord, endCoord;
|
||||
LOOP_XYZ(a) {
|
||||
LOOP_LINEAR_AXES(a) {
|
||||
startCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
|
||||
endCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
|
||||
}
|
||||
@ -392,7 +392,7 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) {
|
||||
travelDistance = endDistance - startDistance;
|
||||
|
||||
xyze_pos_t startCoord, endCoord;
|
||||
LOOP_XYZ(a) {
|
||||
LOOP_LINEAR_AXES(a) {
|
||||
startCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
|
||||
endCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
|
||||
}
|
||||
@ -822,7 +822,7 @@ void I2CPositionEncodersMgr::M860() {
|
||||
const bool hasU = parser.seen_test('U'), hasO = parser.seen_test('O');
|
||||
|
||||
if (I2CPE_idx == 0xFF) {
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
if (!I2CPE_anyaxis || parser.seen_test(axis_codes[i])) {
|
||||
const uint8_t idx = idx_from_axis(AxisEnum(i));
|
||||
if ((int8_t)idx >= 0) report_position(idx, hasU, hasO);
|
||||
@ -849,7 +849,7 @@ void I2CPositionEncodersMgr::M861() {
|
||||
if (parse()) return;
|
||||
|
||||
if (I2CPE_idx == 0xFF) {
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
|
||||
const uint8_t idx = idx_from_axis(AxisEnum(i));
|
||||
if ((int8_t)idx >= 0) report_status(idx);
|
||||
@ -877,7 +877,7 @@ void I2CPositionEncodersMgr::M862() {
|
||||
if (parse()) return;
|
||||
|
||||
if (I2CPE_idx == 0xFF) {
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
|
||||
const uint8_t idx = idx_from_axis(AxisEnum(i));
|
||||
if ((int8_t)idx >= 0) test_axis(idx);
|
||||
@ -908,7 +908,7 @@ void I2CPositionEncodersMgr::M863() {
|
||||
const uint8_t iterations = constrain(parser.byteval('P', 1), 1, 10);
|
||||
|
||||
if (I2CPE_idx == 0xFF) {
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
|
||||
const uint8_t idx = idx_from_axis(AxisEnum(i));
|
||||
if ((int8_t)idx >= 0) calibrate_steps_mm(idx, iterations);
|
||||
@ -984,7 +984,7 @@ void I2CPositionEncodersMgr::M865() {
|
||||
if (parse()) return;
|
||||
|
||||
if (!I2CPE_addr) {
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
|
||||
const uint8_t idx = idx_from_axis(AxisEnum(i));
|
||||
if ((int8_t)idx >= 0) report_module_firmware(encoders[idx].get_address());
|
||||
@ -1015,7 +1015,7 @@ void I2CPositionEncodersMgr::M866() {
|
||||
const bool hasR = parser.seen_test('R');
|
||||
|
||||
if (I2CPE_idx == 0xFF) {
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
|
||||
const uint8_t idx = idx_from_axis(AxisEnum(i));
|
||||
if ((int8_t)idx >= 0) {
|
||||
@ -1053,7 +1053,7 @@ void I2CPositionEncodersMgr::M867() {
|
||||
const int8_t onoff = parser.seenval('S') ? parser.value_int() : -1;
|
||||
|
||||
if (I2CPE_idx == 0xFF) {
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
|
||||
const uint8_t idx = idx_from_axis(AxisEnum(i));
|
||||
if ((int8_t)idx >= 0) {
|
||||
@ -1089,7 +1089,7 @@ void I2CPositionEncodersMgr::M868() {
|
||||
const float newThreshold = parser.seenval('T') ? parser.value_float() : -9999;
|
||||
|
||||
if (I2CPE_idx == 0xFF) {
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
|
||||
const uint8_t idx = idx_from_axis(AxisEnum(i));
|
||||
if ((int8_t)idx >= 0) {
|
||||
@ -1123,7 +1123,7 @@ void I2CPositionEncodersMgr::M869() {
|
||||
if (parse()) return;
|
||||
|
||||
if (I2CPE_idx == 0xFF) {
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
|
||||
const uint8_t idx = idx_from_axis(AxisEnum(i));
|
||||
if ((int8_t)idx >= 0) report_error(idx);
|
||||
|
@ -163,7 +163,7 @@ Joystick joystick;
|
||||
// norm_jog values of [-1 .. 1] maps linearly to [-feedrate .. feedrate]
|
||||
xyz_float_t move_dist{0};
|
||||
float hypot2 = 0;
|
||||
LOOP_XYZ(i) if (norm_jog[i]) {
|
||||
LOOP_LINEAR_AXES(i) if (norm_jog[i]) {
|
||||
move_dist[i] = seg_time * norm_jog[i] * TERN(EXTENSIBLE_UI, manual_feedrate_mm_s, planner.settings.max_feedrate_mm_s)[i];
|
||||
hypot2 += sq(move_dist[i]);
|
||||
}
|
||||
|
@ -549,7 +549,7 @@ void PrintJobRecovery::resume() {
|
||||
TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset);
|
||||
TERN_(HAS_POSITION_SHIFT, position_shift = info.position_shift);
|
||||
#if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
|
||||
LOOP_XYZ(i) update_workspace_offset((AxisEnum)i);
|
||||
LOOP_LINEAR_AXES(i) update_workspace_offset((AxisEnum)i);
|
||||
#endif
|
||||
|
||||
// Relative axis modes
|
||||
@ -581,7 +581,7 @@ void PrintJobRecovery::resume() {
|
||||
if (info.valid_head) {
|
||||
if (info.valid_head == info.valid_foot) {
|
||||
DEBUG_ECHOPGM("current_position: ");
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
if (i) DEBUG_CHAR(',');
|
||||
DEBUG_DECIMAL(info.current_position[i]);
|
||||
}
|
||||
@ -599,7 +599,7 @@ void PrintJobRecovery::resume() {
|
||||
|
||||
#if HAS_HOME_OFFSET
|
||||
DEBUG_ECHOPGM("home_offset: ");
|
||||
LOOP_XYZ(i) {
|
||||
LOOP_LINEAR_AXES(i) {
|
||||
if (i) DEBUG_CHAR(',');
|
||||
DEBUG_DECIMAL(info.home_offset[i]);
|
||||
}
|
||||
@ -608,7 +608,7 @@ void PrintJobRecovery::resume() {
|
||||
|
||||
#if HAS_POSITION_SHIFT
|
||||
DEBUG_ECHOPGM("position_shift: ");
|
||||
LOOP_XYZ(i) {
|
||||
LOOP_LINEAR_AXES(i) {
|
||||
if (i) DEBUG_CHAR(',');
|
||||
DEBUG_DECIMAL(info.position_shift[i]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user