1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-30 09:39:49 +02:00

Renamed bit macros

This commit is contained in:
Mitch Bradley
2021-07-25 07:14:28 -10:00
parent e685c9180c
commit b7107661c5
15 changed files with 91 additions and 91 deletions

View File

@@ -112,7 +112,7 @@ bool user_defined_homing(AxisMask cycle_mask) {
mask = cycle_mask ? cycle_mask : homing_cycle[cycle]->get();
// If not X or Y do a normal home
if (!(bitnum_istrue(mask, X_AXIS) || bitnum_istrue(mask, Y_AXIS))) {
if (!(bitnum_is_true(mask, X_AXIS) || bitnum_is_true(mask, Y_AXIS))) {
limits_go_home(mask); // Homing cycle 0
continue; // continue to next item in for loop
}
@@ -137,7 +137,7 @@ bool user_defined_homing(AxisMask cycle_mask) {
target[idx] = 0.0;
}
if (bit_istrue(homing_dir_mask->get(), bit(axis))) {
if (bits_are_true(homing_dir_mask->get(), bit(axis))) {
approach ? target[axis] = -max_travel : target[axis] = max_travel;
} else {
approach ? target[axis] = max_travel : target[axis] = -max_travel;
@@ -221,7 +221,7 @@ bool user_defined_homing(AxisMask cycle_mask) {
// set the cartesian axis position
for (axis = X_AXIS; axis <= Y_AXIS; axis++) {
if (bitnum_istrue(homing_dir_mask->get(), axis)) {
if (bitnum_is_true(homing_dir_mask->get(), axis)) {
target[axis] = limitsMinPosition(axis) + config->_homing->_pulloff;
} else {
target[axis] = limitsMaxPosition(axis) - config->_homing->_pulloff;

View File

@@ -142,7 +142,7 @@ void displayDRO() {
display.setTextAlignment(TEXT_ALIGN_RIGHT);
float* print_position = system_get_mpos();
if (bit_istrue(status_mask->get(), RtStatus::Position)) {
if (bits_are_true(status_mask->get(), RtStatus::Position)) {
display.drawString(60, 14, "M Pos");
} else {
display.drawString(60, 14, "W Pos");
@@ -161,7 +161,7 @@ void displayDRO() {
snprintf(axisVal, 20 - 1, "%.3f", print_position[axis]);
display.drawString(60, oled_y_pos, axisVal);
if (bitnum_istrue(limitAxes, axis)) { // only draw the box if a switch has been defined
if (bitnum_is_true(limitAxes, axis)) { // only draw the box if a switch has been defined
draw_checkbox(80, 27 + (axis * 10), 7, 7, limits_check(bit(axis)));
}
}

View File

@@ -458,7 +458,7 @@ Error gc_execute_line(char* line, uint8_t client) {
// Check for more than one command per modal group violations in the current block
// NOTE: Variable 'mg_word_bit' is always assigned, if the command is valid.
bitmask = bit(mg_word_bit);
if (bit_istrue(command_words, bitmask)) {
if (bits_are_true(command_words, bitmask)) {
FAIL(Error::GcodeModalGroupViolation);
}
command_words |= bitmask;
@@ -571,7 +571,7 @@ Error gc_execute_line(char* line, uint8_t client) {
// Check for more than one command per modal group violations in the current block
// NOTE: Variable 'mg_word_bit' is always assigned, if the command is valid.
bitmask = bit(mg_word_bit);
if (bit_istrue(command_words, bitmask)) {
if (bits_are_true(command_words, bitmask)) {
FAIL(Error::GcodeModalGroupViolation);
}
command_words |= bitmask;
@@ -702,7 +702,7 @@ Error gc_execute_line(char* line, uint8_t client) {
}
// NOTE: Variable 'axis_word_bit' is always assigned, if the non-command letter is valid.
uint32_t bitmask = bit(axis_word_bit);
if (bit_istrue(value_words, bitmask)) {
if (bits_are_true(value_words, bitmask)) {
FAIL(Error::GcodeWordRepeated); // [Word repeated]
}
// Check for invalid negative values for words F, N, P, T, and S.
@@ -749,13 +749,13 @@ Error gc_execute_line(char* line, uint8_t client) {
}
}
// Check for valid line number N value.
if (bit_istrue(value_words, bit(GCodeWord::N))) {
if (bits_are_true(value_words, bit(GCodeWord::N))) {
// Line number value cannot be less than zero (done) or greater than max line number.
if (gc_block.values.n > MaxLineNumber) {
FAIL(Error::GcodeInvalidLineNumber); // [Exceeds max line number]
}
}
// bit_false(value_words,bit(GCodeWord::N)); // NOTE: Single-meaning value word. Set at end of error-checking.
// clear_bits(value_words,bit(GCodeWord::N)); // NOTE: Single-meaning value word. Set at end of error-checking.
// Track for unused words at the end of error-checking.
// NOTE: Single-meaning value words are removed all at once at the end of error-checking, because
// they are always used when present. This was done to save a few bytes of flash. For clarity, the
@@ -767,7 +767,7 @@ Error gc_execute_line(char* line, uint8_t client) {
// is not defined after switching to G94 from G93.
// NOTE: For jogging, ignore prior feed rate mode. Enforce G94 and check for required F word.
if (gc_parser_flags & GCParserJogMotion) {
if (bit_isfalse(value_words, bit(GCodeWord::F))) {
if (bits_are_false(value_words, bit(GCodeWord::F))) {
FAIL(Error::GcodeUndefinedFeedRate);
}
if (gc_block.modal.units == Units::Inches) {
@@ -778,7 +778,7 @@ Error gc_execute_line(char* line, uint8_t client) {
// NOTE: G38 can also operate in inverse time, but is undefined as an error. Missing F word check added here.
if (axis_command == AxisCommand::MotionMode) {
if ((gc_block.modal.motion != Motion::None) || (gc_block.modal.motion != Motion::Seek)) {
if (bit_isfalse(value_words, bit(GCodeWord::F))) {
if (bits_are_false(value_words, bit(GCodeWord::F))) {
FAIL(Error::GcodeUndefinedFeedRate); // [F word missing]
}
}
@@ -797,7 +797,7 @@ Error gc_execute_line(char* line, uint8_t client) {
} else { // = G94
// - In units per mm mode: If F word passed, ensure value is in mm/min, otherwise push last state value.
if (gc_state.modal.feed_rate == FeedRate::UnitsPerMin) { // Last state is also G94
if (bit_istrue(value_words, bit(GCodeWord::F))) {
if (bits_are_true(value_words, bit(GCodeWord::F))) {
if (gc_block.modal.units == Units::Inches) {
gc_block.values.f *= MM_PER_INCH;
}
@@ -807,13 +807,13 @@ Error gc_execute_line(char* line, uint8_t client) {
} // Else, switching to G94 from G93, so don't push last state feed rate. Its undefined or the passed F word value.
}
}
// bit_false(value_words,bit(GCodeWord::F)); // NOTE: Single-meaning value word. Set at end of error-checking.
// clear_bits(value_words,bit(GCodeWord::F)); // NOTE: Single-meaning value word. Set at end of error-checking.
// [4. Set spindle speed ]: S is negative (done.)
if (bit_isfalse(value_words, bit(GCodeWord::S))) {
if (bits_are_false(value_words, bit(GCodeWord::S))) {
gc_block.values.s = gc_state.spindle_speed;
// bit_false(value_words,bit(GCodeWord::S)); // NOTE: Single-meaning value word. Set at end of error-checking.
// clear_bits(value_words,bit(GCodeWord::S)); // NOTE: Single-meaning value word. Set at end of error-checking.
// [5. Select tool ]: NOT SUPPORTED. Only tracks value. T is negative (done.) Not an integer. Greater than max tool value.
// bit_false(value_words,bit(GCodeWord::T)); // NOTE: Single-meaning value word. Set at end of error-checking.
// clear_bits(value_words,bit(GCodeWord::T)); // NOTE: Single-meaning value word. Set at end of error-checking.
// [6. Change tool ]: N/A
// [7. Spindle control ]: N/A
// [8. Coolant control ]: N/A
@@ -821,35 +821,35 @@ Error gc_execute_line(char* line, uint8_t client) {
}
if (config->_enableParkingOverrideControl) {
if (bit_istrue(command_words, bit(ModalGroup::MM9))) { // Already set as enabled in parser.
if (bit_istrue(value_words, bit(GCodeWord::P))) {
if (bits_are_true(command_words, bit(ModalGroup::MM9))) { // Already set as enabled in parser.
if (bits_are_true(value_words, bit(GCodeWord::P))) {
if (gc_block.values.p == 0.0) {
gc_block.modal.override = Override::Disabled;
}
bit_false(value_words, bit(GCodeWord::P));
clear_bits(value_words, bit(GCodeWord::P));
}
}
}
// [10. Dwell ]: P value missing. P is negative (done.) NOTE: See below.
if (gc_block.non_modal_command == NonModal::Dwell) {
if (bit_isfalse(value_words, bit(GCodeWord::P))) {
if (bits_are_false(value_words, bit(GCodeWord::P))) {
FAIL(Error::GcodeValueWordMissing); // [P word missing]
}
bit_false(value_words, bit(GCodeWord::P));
clear_bits(value_words, bit(GCodeWord::P));
}
if ((gc_block.modal.io_control == IoControl::DigitalOnSync) || (gc_block.modal.io_control == IoControl::DigitalOffSync) ||
(gc_block.modal.io_control == IoControl::DigitalOnImmediate) || (gc_block.modal.io_control == IoControl::DigitalOffImmediate)) {
if (bit_isfalse(value_words, bit(GCodeWord::P))) {
if (bits_are_false(value_words, bit(GCodeWord::P))) {
FAIL(Error::GcodeValueWordMissing); // [P word missing]
}
bit_false(value_words, bit(GCodeWord::P));
clear_bits(value_words, bit(GCodeWord::P));
}
if ((gc_block.modal.io_control == IoControl::SetAnalogSync) || (gc_block.modal.io_control == IoControl::SetAnalogImmediate)) {
if (bit_isfalse(value_words, bit(GCodeWord::E)) || bit_isfalse(value_words, bit(GCodeWord::Q))) {
if (bits_are_false(value_words, bit(GCodeWord::E)) || bits_are_false(value_words, bit(GCodeWord::Q))) {
FAIL(Error::GcodeValueWordMissing);
}
bit_false(value_words, bit(GCodeWord::E));
bit_false(value_words, bit(GCodeWord::Q));
clear_bits(value_words, bit(GCodeWord::E));
clear_bits(value_words, bit(GCodeWord::Q));
}
// [11. Set active plane ]: N/A
switch (gc_block.modal.plane_select) {
@@ -874,7 +874,7 @@ Error gc_execute_line(char* line, uint8_t client) {
uint8_t idx;
if (gc_block.modal.units == Units::Inches) {
for (idx = 0; idx < n_axis; idx++) { // Axes indices are consistent, so loop may be used.
if (bit_istrue(axis_words, bit(idx))) {
if (bits_are_true(axis_words, bit(idx))) {
gc_block.values.xyz[idx] *= MM_PER_INCH;
}
}
@@ -903,7 +903,7 @@ Error gc_execute_line(char* line, uint8_t client) {
// in memory and written to non-volatile storage only when there is not a cycle active.
float block_coord_system[MAX_N_AXIS];
memcpy(block_coord_system, gc_state.coord_system, sizeof(gc_state.coord_system));
if (bit_istrue(command_words, bit(ModalGroup::MG12))) { // Check if called in block
if (bits_are_true(command_words, bit(ModalGroup::MG12))) { // Check if called in block
// This error probably cannot happen because preceding code sets
// gc_block.modal.coord_select only to specific supported values
if (gc_block.modal.coord_select >= CoordIndex::NWCSystems) {
@@ -929,12 +929,12 @@ Error gc_execute_line(char* line, uint8_t client) {
if (!axis_words) {
FAIL(Error::GcodeNoAxisWords)
}; // [No axis words]
if (bit_isfalse(value_words, (bit(GCodeWord::P) | bit(GCodeWord::L)))) {
if (bits_are_false(value_words, (bit(GCodeWord::P) | bit(GCodeWord::L)))) {
FAIL(Error::GcodeValueWordMissing); // [P/L word missing]
}
if (gc_block.values.l != 20) {
if (gc_block.values.l == 2) {
if (bit_istrue(value_words, bit(GCodeWord::R))) {
if (bits_are_true(value_words, bit(GCodeWord::R))) {
FAIL(Error::GcodeUnsupportedCommand); // [G10 L2 R not supported]
}
} else {
@@ -953,13 +953,13 @@ Error gc_execute_line(char* line, uint8_t client) {
if (coord_select >= CoordIndex::NWCSystems) {
FAIL(Error::GcodeUnsupportedCoordSys); // [Greater than N sys]
}
bit_false(value_words, (bit(GCodeWord::L) | bit(GCodeWord::P)));
clear_bits(value_words, (bit(GCodeWord::L) | bit(GCodeWord::P)));
coords[coord_select]->get(coord_data);
// Pre-calculate the coordinate data changes.
for (idx = 0; idx < n_axis; idx++) { // Axes indices are consistent, so loop may be used.
// Update axes defined only in block. Always in machine coordinates. Can change non-active system.
if (bit_istrue(axis_words, bit(idx))) {
if (bits_are_true(axis_words, bit(idx))) {
if (gc_block.values.l == 20) {
// L20: Update coordinate system axis at current position (with modifiers) with programmed value
// WPos = MPos - WCS - G92 - TLO -> WCS = MPos - G92 - TLO - WPos
@@ -982,7 +982,7 @@ Error gc_execute_line(char* line, uint8_t client) {
// Update axes defined only in block. Offsets current system to defined value. Does not update when
// active coordinate system is selected, but is still active unless G92.1 disables it.
for (idx = 0; idx < n_axis; idx++) { // Axes indices are consistent, so loop may be used.
if (bit_istrue(axis_words, bit(idx))) {
if (bits_are_true(axis_words, bit(idx))) {
// WPos = MPos - WCS - G92 - TLO -> G92 = MPos - WCS - TLO - WPos
gc_block.values.xyz[idx] = gc_state.position[idx] - block_coord_system[idx] - gc_block.values.xyz[idx];
if (idx == TOOL_LENGTH_OFFSET_AXIS) {
@@ -1001,7 +1001,7 @@ Error gc_execute_line(char* line, uint8_t client) {
if (axis_command != AxisCommand::ToolLengthOffset) { // TLO block any axis command.
if (axis_words) {
for (idx = 0; idx < n_axis; idx++) { // Axes indices are consistent, so loop may be used to save flash space.
if (bit_isfalse(axis_words, bit(idx))) {
if (bits_are_false(axis_words, bit(idx))) {
gc_block.values.xyz[idx] = gc_state.position[idx]; // No axis word in block. Keep same axis position.
} else {
// Update specified value according to distance mode or ignore if absolute override is active.
@@ -1117,7 +1117,7 @@ Error gc_execute_line(char* line, uint8_t client) {
x = gc_block.values.xyz[axis_0] - gc_state.position[axis_0]; // Delta x between current position and target
y = gc_block.values.xyz[axis_1] - gc_state.position[axis_1]; // Delta y between current position and target
if (value_words & bit(GCodeWord::R)) { // Arc Radius Mode
bit_false(value_words, bit(GCodeWord::R));
clear_bits(value_words, bit(GCodeWord::R));
if (isequal_position_vector(gc_state.position, gc_block.values.xyz)) {
FAIL(Error::GcodeInvalidTarget); // [Invalid target]
}
@@ -1214,7 +1214,7 @@ Error gc_execute_line(char* line, uint8_t client) {
if (!(ijk_words & (bit(axis_0) | bit(axis_1)))) {
FAIL(Error::GcodeNoOffsetsInPlane); // [No offsets in plane]
}
bit_false(value_words, (bit(GCodeWord::I) | bit(GCodeWord::J) | bit(GCodeWord::K)));
clear_bits(value_words, (bit(GCodeWord::I) | bit(GCodeWord::J) | bit(GCodeWord::K)));
// Convert IJK values to proper units.
if (gc_block.modal.units == Units::Inches) {
for (idx = 0; idx < n_axis; idx++) { // Axes indices are consistent, so loop may be used to save flash space.
@@ -1268,15 +1268,15 @@ Error gc_execute_line(char* line, uint8_t client) {
// radius mode, or axis words that aren't used in the block.
if (gc_parser_flags & GCParserJogMotion) {
// Jogging only uses the F feed rate and XYZ value words. N is valid, but S and T are invalid.
bit_false(value_words, (bit(GCodeWord::N) | bit(GCodeWord::F)));
clear_bits(value_words, (bit(GCodeWord::N) | bit(GCodeWord::F)));
} else {
bit_false(value_words,
(bit(GCodeWord::N) | bit(GCodeWord::F) | bit(GCodeWord::S) | bit(GCodeWord::T))); // Remove single-meaning value words.
clear_bits(value_words,
(bit(GCodeWord::N) | bit(GCodeWord::F) | bit(GCodeWord::S) | bit(GCodeWord::T))); // Remove single-meaning value words.
}
if (axis_command != AxisCommand::None) {
bit_false(value_words,
(bit(GCodeWord::X) | bit(GCodeWord::Y) | bit(GCodeWord::Z) | bit(GCodeWord::A) | bit(GCodeWord::B) |
bit(GCodeWord::C))); // Remove axis words.
clear_bits(value_words,
(bit(GCodeWord::X) | bit(GCodeWord::Y) | bit(GCodeWord::Z) | bit(GCodeWord::A) | bit(GCodeWord::B) |
bit(GCodeWord::C))); // Remove axis words.
}
if (value_words) {
FAIL(Error::GcodeUnusedWords); // [Unused words]
@@ -1332,12 +1332,12 @@ Error gc_execute_line(char* line, uint8_t client) {
if (gc_state.modal.spindle == SpindleState::Cw) {
if ((gc_state.modal.motion == Motion::Linear) || (gc_state.modal.motion == Motion::CwArc) ||
(gc_state.modal.motion == Motion::CcwArc)) {
if (bit_istrue(gc_parser_flags, GCParserLaserDisable)) {
if (bits_are_true(gc_parser_flags, GCParserLaserDisable)) {
gc_parser_flags |= GCParserLaserForceSync; // Change from G1/2/3 motion mode.
}
} else {
// When changing to a G1 motion mode without axis words from a non-G1/2/3 motion mode.
if (bit_isfalse(gc_parser_flags, GCParserLaserDisable)) {
if (bits_are_false(gc_parser_flags, GCParserLaserDisable)) {
gc_parser_flags |= GCParserLaserForceSync;
}
}
@@ -1359,12 +1359,12 @@ Error gc_execute_line(char* line, uint8_t client) {
gc_state.feed_rate = gc_block.values.f; // Always copy this value. See feed rate error-checking.
pl_data->feed_rate = gc_state.feed_rate; // Record data for planner use.
// [4. Set spindle speed ]:
if ((gc_state.spindle_speed != gc_block.values.s) || bit_istrue(gc_parser_flags, GCParserLaserForceSync)) {
if ((gc_state.spindle_speed != gc_block.values.s) || bits_are_true(gc_parser_flags, GCParserLaserForceSync)) {
if (gc_state.modal.spindle != SpindleState::Disable) {
if (bit_isfalse(gc_parser_flags, GCParserLaserIsMotion)) {
if (bits_are_false(gc_parser_flags, GCParserLaserIsMotion)) {
if (sys.state != State::CheckMode) {
protocol_buffer_synchronize();
if (bit_istrue(gc_parser_flags, GCParserLaserDisable)) {
if (bits_are_true(gc_parser_flags, GCParserLaserDisable)) {
spindle->setState(gc_state.modal.spindle, 0);
} else {
spindle->setState(gc_state.modal.spindle, (uint32_t)gc_block.values.s);
@@ -1375,7 +1375,7 @@ Error gc_execute_line(char* line, uint8_t client) {
gc_state.spindle_speed = gc_block.values.s; // Update spindle speed state.
}
// NOTE: Pass zero spindle speed for all restricted laser motions.
if (bit_isfalse(gc_parser_flags, GCParserLaserDisable)) {
if (bits_are_false(gc_parser_flags, GCParserLaserDisable)) {
pl_data->spindle_speed = gc_state.spindle_speed; // Record data for planner use.
} // else { pl_data->spindle_speed = 0.0; } // Initialized as zero already.
// [5. Select tool ]: NOT SUPPORTED. Only tracks tool value.
@@ -1551,7 +1551,7 @@ Error gc_execute_line(char* line, uint8_t client) {
axis_0,
axis_1,
axis_linear,
bit_istrue(gc_parser_flags, GCParserArcIsClockwise));
bits_are_true(gc_parser_flags, GCParserArcIsClockwise));
} else {
// NOTE: gc_block.values.xyz is returned from mc_probe_cycle with the updated position value. So
// upon a successful probing cycle, the machine position and the returned value should be the same.

View File

@@ -30,7 +30,7 @@
#include "Machine/MachineConfig.h"
#include "Planner.h"
#include "MotionControl.h" // HOMING_CYCLE_LINE_NUMBER
#include "NutsBolts.h" // bitnum_true, etc
#include "NutsBolts.h" // set_bitnum, etc
#include "System.h" // sys.*
#include "Stepper.h" // st_wake
#include "Report.h" // CLIENT_
@@ -83,7 +83,7 @@ static uint32_t limits_plan_move(AxisMask axesMask, bool approach, bool seek) {
// Find the axis that will take the longest
for (int axis = 0; axis < n_axis; axis++) {
if (bitnum_isfalse(axesMask, axis)) {
if (bitnum_is_false(axesMask, axis)) {
continue;
}
// Set target location for active axes and setup computation for homing rate.
@@ -117,7 +117,7 @@ static uint32_t limits_plan_move(AxisMask axesMask, bool approach, bool seek) {
// When approaching a small fudge factor to ensure that the limit is reached -
// but no fudge factor when pulling off.
for (int axis = 0; axis < n_axis; axis++) {
if (bitnum_istrue(axesMask, axis)) {
if (bitnum_is_true(axesMask, axis)) {
auto homing = config->_axes->_axis[axis]->_homing;
auto scaler = approach ? (seek ? homing->_seek_scaler : homing->_feed_scaler) : 1.0;
target[axis] *= limitingRate * scaler;
@@ -252,7 +252,7 @@ static void limits_go_home(uint8_t cycle_mask, uint32_t n_locate_cycles) {
uint32_t limitedAxes = Machine::Axes::posLimitMask | Machine::Axes::negLimitMask;
config->_axes->stop_motors(limitedAxes);
bit_false(remainingMotors, limitedAxes);
clear_bits(remainingMotors, limitedAxes);
}
Stepper::prep_buffer(); // Check and prep segment buffer.
@@ -303,7 +303,7 @@ static void limits_go_home(uint8_t cycle_mask, uint32_t n_locate_cycles) {
for (int axis = 0; axis < n_axis; axis++) {
Machine::Axis* axisConf = config->_axes->_axis[axis];
auto homing = axisConf->_homing;
if (bitnum_istrue(cycle_mask, axis)) {
if (bitnum_is_true(cycle_mask, axis)) {
auto mpos = homing->_mpos;
auto pulloff = homing->_pulloff;
auto steps = axisConf->_stepsPerMm;
@@ -339,7 +339,7 @@ static AxisMask squaredAxes() {
for (int axis = 0; axis < n_axis; axis++) {
auto homing = axes->_axis[axis]->_homing;
if (homing && homing->_square) {
bitnum_true(mask, axis);
set_bitnum(mask, axis);
}
}
return mask;
@@ -405,7 +405,7 @@ void limits_run_homing_cycles(AxisMask axis_mask) {
auto axisConfig = config->_axes->_axis[axis];
auto homing = axisConfig->_homing;
if (homing && homing->_cycle == cycle) {
bitnum_true(axis_mask, axis);
set_bitnum(axis_mask, axis);
}
}

View File

@@ -85,13 +85,13 @@ namespace Machine {
uint8_t can_home = 0;
for (uint8_t axis = X_AXIS; axis < _numberAxis; axis++) {
if (bitnum_istrue(homing_mask, axis)) {
if (bitnum_is_true(homing_mask, axis)) {
auto a = _axis[axis];
if (a != nullptr) {
auto motor = a->_gangs[0]->_motor;
if (motor->set_homing_mode(isHoming)) {
bitnum_true(can_home, axis);
set_bitnum(can_home, axis);
}
for (uint8_t gang_index = 1; gang_index < Axis::MAX_NUMBER_GANGED; gang_index++) {
@@ -106,7 +106,7 @@ namespace Machine {
}
void Axes::release_all_motors() { _motorLockoutMask = 0xffffffff; }
void Axes::stop_motors(uint32_t mask) { bit_false(_motorLockoutMask, mask); }
void Axes::stop_motors(uint32_t mask) { clear_bits(_motorLockoutMask, mask); }
void IRAM_ATTR Axes::step(uint8_t step_mask, uint8_t dir_mask) {
auto n_axis = _numberAxis;
@@ -119,7 +119,7 @@ namespace Machine {
previous_dir = dir_mask;
for (int axis = X_AXIS; axis < n_axis; axis++) {
bool thisDir = bitnum_istrue(dir_mask, axis);
bool thisDir = bitnum_is_true(dir_mask, axis);
for (uint8_t gang_index = 0; gang_index < Axis::MAX_NUMBER_GANGED; gang_index++) {
auto a = _axis[axis]->_gangs[gang_index]->_motor;
@@ -136,13 +136,13 @@ namespace Machine {
// Turn on step pulses for motors that are supposed to step now
for (uint8_t axis = X_AXIS; axis < n_axis; axis++) {
if (bitnum_istrue(step_mask, axis)) {
if (bitnum_is_true(step_mask, axis)) {
auto a = _axis[axis];
if (bitnum_istrue(_motorLockoutMask, axis)) {
if (bitnum_is_true(_motorLockoutMask, axis)) {
a->_gangs[0]->_motor->step();
}
if (bitnum_istrue(_motorLockoutMask, axis + 16)) {
if (bitnum_is_true(_motorLockoutMask, axis + 16)) {
a->_gangs[1]->_motor->step();
}
}

View File

@@ -40,7 +40,7 @@ namespace Machine {
}
if (_homing) {
_homing->init();
bitnum_true(Axes::homingMask, _axis);
set_bitnum(Axes::homingMask, _axis);
}
if (_endstops) {
_endstops->init();

View File

@@ -37,7 +37,7 @@ namespace Machine {
void Gang::init() {
if (strcmp(_motor->name(), "null_motor") != 0) {
bitnum_true(Machine::Axes::motorMask, _axis + 16 * _gang);
set_bitnum(Machine::Axes::motorMask, _axis + 16 * _gang);
}
_motor->init();
if (_endstops) {

View File

@@ -2,7 +2,7 @@
#include "Axes.h"
#include "MachineConfig.h" // config
#include "../NutsBolts.h" // bitnum_true etc
#include "../NutsBolts.h" // set_bitnum etc
#include "../MotionControl.h" // mc_reset
#include "../Limits.h"
#include "../System.h" // sys_rt_exec_alarm
@@ -71,10 +71,10 @@ namespace Machine {
}
} else {
if (_posLimits != nullptr) {
bit_false(*_posLimits, _bitmask);
clear_bits(*_posLimits, _bitmask);
}
if (_negLimits != nullptr) {
bit_false(*_negLimits, _bitmask);
clear_bits(*_negLimits, _bitmask);
}
}
if (sys.state != State::Alarm && sys.state != State::ConfigAlarm && sys.state != State::Homing) {
@@ -100,7 +100,7 @@ namespace Machine {
if (_pin.undefined()) {
return;
}
bitnum_true(Axes::limitMask, _axis);
set_bitnum(Axes::limitMask, _axis);
_pin.report(_legend.c_str());
auto attr = Pin::Attr::Input | Pin::Attr::ISR;
if (_pin.capabilities().has(Pins::PinCapabilities::PullUp)) {

View File

@@ -332,8 +332,8 @@ GCUpdatePos mc_probe_cycle(float* target, plan_line_data_t* pl_data, uint8_t par
config->_stepping->beginLowLatency();
// Initialize probing control variables
bool is_probe_away = bit_istrue(parser_flags, GCParserProbeIsAway);
bool is_no_error = bit_istrue(parser_flags, GCParserProbeIsNoError);
bool is_probe_away = bits_are_true(parser_flags, GCParserProbeIsAway);
bool is_no_error = bits_are_true(parser_flags, GCParserProbeIsNoError);
sys.probe_succeeded = false; // Re-initialize probe history before beginning cycle.
config->_probe->set_direction(is_probe_away);
// After syncing, check if probe is already triggered. If so, halt and issue alarm.

View File

@@ -139,7 +139,7 @@ namespace Motors {
err = true;
}
if (report_short_to_ps(bit_istrue(status.sr, 12), bit_istrue(status.sr, 13))) {
if (report_short_to_ps(bits_are_true(status.sr, 12), bits_are_true(status.sr, 13))) {
err = true;
}
@@ -263,7 +263,7 @@ namespace Motors {
report_open_load(status.ola, status.olb);
report_short_to_ground(status.s2ga, status.s2gb);
report_over_temp(status.ot, status.otpw);
report_short_to_ps(bit_istrue(status.sr, 12), bit_istrue(status.sr, 13));
report_short_to_ps(bits_are_true(status.sr, 12), bits_are_true(status.sr, 13));
// log_info(axisName() << " Status Register " << String(status.sr, HEX) << " GSTAT " << String(tmcstepper->GSTAT(), HEX));
}

View File

@@ -127,7 +127,7 @@ namespace Motors {
err = true;
}
if (report_short_to_ps(bit_istrue(status.sr, 12), bit_istrue(status.sr, 13))) {
if (report_short_to_ps(bits_are_true(status.sr, 12), bits_are_true(status.sr, 13))) {
err = true;
}
@@ -248,7 +248,7 @@ namespace Motors {
report_open_load(status.ola, status.olb);
report_short_to_ground(status.s2ga, status.s2gb);
report_over_temp(status.ot, status.otpw);
report_short_to_ps(bit_istrue(status.sr, 12), bit_istrue(status.sr, 13));
report_short_to_ps(bits_are_true(status.sr, 12), bits_are_true(status.sr, 13));
// log_info(axisName()<<" Status Register "<<String(status.sr,HEX)<<" GSTAT " << String(tmcstepper->GSTAT(),HEX));
}

View File

@@ -81,14 +81,14 @@ const float INCH_PER_MM = (0.0393701f);
#endif
#define bit(n) (1 << static_cast<unsigned int>(n))
#define bit_true(x, mask) (x) |= (mask)
#define bit_false(x, mask) (x) &= ~(mask)
#define bit_istrue(x, mask) ((x & mask) != 0)
#define bit_isfalse(x, mask) ((x & mask) == 0)
#define bitnum_true(x, num) (x) |= bit(num)
#define bitnum_false(x, num) (x) &= ~bit(num)
#define bitnum_istrue(x, num) ((x & bit(num)) != 0)
#define bitnum_isfalse(x, num) ((x & bit(num)) == 0)
#define bit_true(target, mask) (target) |= (mask)
#define clear_bits(target, mask) (target) &= ~(mask)
#define bits_are_true(target, mask) ((target & mask) != 0)
#define bits_are_false(target, mask) ((target & mask) == 0)
#define set_bitnum(target, num) (target) |= bit(num)
#define clear_bitnum(target, num) (target) &= ~bit(num)
#define bitnum_is_true(target, num) ((target & bit(num)) != 0)
#define bitnum_is_false(target, num) ((target & bit(num)) == 0)
// Read a floating point value from a string. Line points to the input buffer, char_counter
// is the indexer pointing to the current character of the line, while float_ptr is

View File

@@ -311,11 +311,11 @@ Error home_c(const char* value, WebUI::AuthenticationLevel auth_level, WebUI::ES
void write_limit_set(uint32_t mask) {
const char* gang0AxisName = "xyzabc";
for (int i = 0; i < MAX_N_AXIS; i++) {
Uart0.write(bitnum_istrue(mask, i) ? uint8_t(gang0AxisName[i]) : ' ');
Uart0.write(bitnum_is_true(mask, i) ? uint8_t(gang0AxisName[i]) : ' ');
}
const char* gang1AxisName = "XYZABC";
for (int i = 0; i < MAX_N_AXIS; i++) {
Uart0.write(bitnum_istrue(mask, i + 16) ? uint8_t(gang1AxisName[i]) : ' ');
Uart0.write(bitnum_is_true(mask, i + 16) ? uint8_t(gang1AxisName[i]) : ' ');
}
}
Error show_limits(const char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) {

View File

@@ -585,7 +585,7 @@ void report_realtime_status(uint8_t client) {
// Report position
float* print_position = system_get_mpos();
if (bit_istrue(status_mask->get(), RtStatus::Position)) {
if (bits_are_true(status_mask->get(), RtStatus::Position)) {
strcat(status, "|MPos:");
} else {
strcat(status, "|WPos:");
@@ -595,7 +595,7 @@ void report_realtime_status(uint8_t client) {
strcat(status, temp);
// Returns planner and serial read buffer states.
if (bit_istrue(status_mask->get(), RtStatus::Buffer)) {
if (bits_are_true(status_mask->get(), RtStatus::Buffer)) {
int bufsize = DEFAULTBUFFERSIZE;
if (client == CLIENT_TELNET) {
bufsize = WebUI::telnet_server.get_rx_buffer_available();
@@ -646,7 +646,7 @@ void report_realtime_status(uint8_t client) {
if (lim_pin_state) {
auto n_axis = config->_axes->_numberAxis;
for (int i = 0; i < n_axis; i++) {
if (bit_istrue(lim_pin_state, bit(i))) {
if (bits_are_true(lim_pin_state, bit(i))) {
addPinReport(status, config->_axes->axisName(i));
}
}

View File

@@ -259,9 +259,9 @@ void IRAM_ATTR Stepper::pulse_func() {
// Execute step displacement profile by Bresenham line algorithm
st.counter[axis] += st.steps[axis];
if (st.counter[axis] > st.exec_block->step_event_count) {
bitnum_true(st.step_outbits, axis);
set_bitnum(st.step_outbits, axis);
st.counter[axis] -= st.exec_block->step_event_count;
if (bitnum_istrue(st.exec_block->direction_bits, axis)) {
if (bitnum_is_true(st.exec_block->direction_bits, axis)) {
sys_position[axis]--;
} else {
sys_position[axis]++;