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

USE_LINE_NUMBERS, USER_ANALOG_PIN_*_FREQ -> yaml

This commit is contained in:
Stefan de Bruijn
2021-06-21 20:37:32 +02:00
parent 9a1041a7b2
commit d68a19e865
13 changed files with 50 additions and 69 deletions

View File

@@ -130,10 +130,6 @@ static const uint8_t NHomingLocateCycle = 1; // Integer (1-128)
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
// ESP32 Note: These are mostly hard coded, so these values will not change anything
// Allows GRBL to track and report gcode line numbers. Enabling this means that the planning buffer
// goes from 16 to 15 to make room for the additional line number data in the plan_block_t struct
// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.
// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates
// through an automatically generated message. If disabled, users can still access the last probe
// coordinates through Grbl '$#' print parameters.
@@ -259,13 +255,6 @@ const double ARC_ANGULAR_TRAVEL_EPSILON = 5E-7; // Float (radians)
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.
const int DWELL_TIME_STEP = 50; // Integer (1-255) (milliseconds)
// Line buffer size from the serial input stream to be executed. Also, governs the size of
// each of the startup blocks, as they are each stored as a string of this size.
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
// can be too small and GCode blocks can get truncated. Officially, the GCode standards
// support up to 256 characters.
// #define LINE_BUFFER_SIZE 80 // Uncomment to override default in protocol.h
// Serial send and receive buffer size. The receive buffer is often used as another streaming
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
// interfaces will character count and track each block send to each block response. So,

View File

@@ -39,19 +39,6 @@
# define SERVO_TIMER_INTERVAL 75.0 // Hz This is the update inveral in milliseconds
#endif
#ifndef USER_ANALOG_PIN_0_FREQ
# define USER_ANALOG_PIN_0_FREQ 5000
#endif
#ifndef USER_ANALOG_PIN_1_FREQ
# define USER_ANALOG_PIN_1_FREQ 5000
#endif
#ifndef USER_ANALOG_PIN_2_FREQ
# define USER_ANALOG_PIN_2_FREQ 5000
#endif
#ifndef USER_ANALOG_PIN_3_FREQ
# define USER_ANALOG_PIN_3_FREQ 5000
#endif
#ifndef DEFAULT_USER_MACRO0
# define DEFAULT_USER_MACRO0 ""
#endif

View File

@@ -164,9 +164,9 @@ Error gc_execute_line(char* line, uint8_t client) {
gc_parser_flags |= GCParserJogMotion;
gc_block.modal.motion = Motion::Linear;
gc_block.modal.feed_rate = FeedRate::UnitsPerMin;
#ifdef USE_LINE_NUMBERS
gc_block.values.n = JOG_LINE_NUMBER; // Initialize default line number reported during jog.
#endif
if (config->_useLineNumbers) {
gc_block.values.n = JOG_LINE_NUMBER; // Initialize default line number reported during jog.
}
}
/* -------------------------------------------------------------------------------------
@@ -1339,9 +1339,8 @@ Error gc_execute_line(char* line, uint8_t client) {
// [0. Non-specific/common error-checks and miscellaneous setup]:
// NOTE: If no line number is present, the value is zero.
gc_state.line_number = gc_block.values.n;
#ifdef USE_LINE_NUMBERS
pl_data->line_number = gc_state.line_number; // Record data for planner use.
#endif
// [1. Comments feedback ]: NOT SUPPORTED
// [2. Set feed rate mode ]:
gc_state.modal.feed_rate = gc_block.modal.feed_rate;

View File

@@ -32,9 +32,7 @@ Error jog_execute(plan_line_data_t* pl_data, parser_block_t* gc_block, bool* can
pl_data->feed_rate = gc_block->values.f;
pl_data->motion.noFeedOverride = 1;
pl_data->is_jog = true;
#ifdef USE_LINE_NUMBERS
pl_data->line_number = gc_block->values.n;
#endif
pl_data->line_number = gc_block->values.n;
if (config->_axes->hasSoftLimits()) {
if (limitsCheckTravel(gc_block->values.xyz)) {

View File

@@ -116,9 +116,8 @@ void limits_go_home(uint8_t cycle_mask, uint n_locate_cycles) {
pl_data->motion = {};
pl_data->motion.systemMotion = 1;
pl_data->motion.noFeedOverride = 1;
#ifdef USE_LINE_NUMBERS
pl_data->line_number = HOMING_CYCLE_LINE_NUMBER;
#endif
pl_data->line_number = HOMING_CYCLE_LINE_NUMBER;
// Initialize variables used for homing computations.
uint8_t n_cycle = (2 * n_locate_cycles + 1);

View File

@@ -391,11 +391,21 @@ void SPIBus::afterParse() {
}
}
UserOutputs::UserOutputs() {
for (int i = 0; i < 4; ++i) {
_analogFrequency[i] = 5000;
}
}
void UserOutputs::group(Configuration::HandlerBase& handler) {
handler.item("analog0", _analogOutput[0]);
handler.item("analog1", _analogOutput[1]);
handler.item("analog2", _analogOutput[2]);
handler.item("analog3", _analogOutput[3]);
handler.item("analog_frequency0", _analogFrequency[0]);
handler.item("analog_frequency1", _analogFrequency[1]);
handler.item("analog_frequency2", _analogFrequency[2]);
handler.item("analog_frequency3", _analogFrequency[3]);
handler.item("digital0", _digitalOutput[0]);
handler.item("digital1", _digitalOutput[1]);
handler.item("digital2", _digitalOutput[2]);
@@ -435,6 +445,7 @@ void MachineConfig::group(Configuration::HandlerBase& handler) {
handler.item("homing_single_axis_commands", _homingSingleAxisCommands);
handler.item("limits_two_switches_on_axis", _limitsTwoSwitchesOnAxis);
handler.item("disable_laser_during_hold", _disableLaserDuringHold);
handler.item("use_line_numbers", _useLineNumbers);
Spindles::SpindleFactory::factory(handler, _spindles);
}

View File

@@ -210,9 +210,10 @@ public:
class UserOutputs : public Configuration::Configurable {
public:
UserOutputs() = default;
UserOutputs();
Pin _analogOutput[4];
int _analogFrequency[4];
Pin _digitalOutput[4];
void group(Configuration::HandlerBase& handler) override;
@@ -393,6 +394,9 @@ public:
// to ensure the laser doesn't inadvertently remain powered while at a stop and cause a fire.
bool _disableLaserDuringHold = true;
// Allows GRBL to track and report gcode line numbers. Disabled by default.
bool _useLineNumbers = false;
String _board = "None";
String _name = "None";

View File

@@ -305,10 +305,8 @@ uint8_t plan_buffer_line(float* target, plan_line_data_t* pl_data) {
block->coolant = pl_data->coolant;
block->spindle = pl_data->spindle;
block->spindle_speed = pl_data->spindle_speed;
block->line_number = pl_data->line_number;
#ifdef USE_LINE_NUMBERS
block->line_number = pl_data->line_number;
#endif
// Compute and store initial move distance data.
int32_t target_steps[MAX_N_AXIS], position_steps[MAX_N_AXIS];
float unit_vec[MAX_N_AXIS], delta_mm;

View File

@@ -53,12 +53,10 @@ typedef struct {
uint8_t direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
// Block condition data to ensure correct execution depending on states and overrides.
PlMotion motion; // Block bitflag motion conditions. Copied from pl_line_data.
SpindleState spindle; // Spindle enable state
CoolantState coolant; // Coolant state
#ifdef USE_LINE_NUMBERS
int32_t line_number; // Block line number for real-time reporting. Copied from pl_line_data.
#endif
PlMotion motion; // Block bitflag motion conditions. Copied from pl_line_data.
SpindleState spindle; // Spindle enable state
CoolantState coolant; // Coolant state
int32_t line_number; // Block line number for real-time reporting. Copied from pl_line_data.
// Fields used by the motion planner to manage acceleration. Some of these values may be updated
// by the stepper module during execution of special motion cases for replanning purposes.
@@ -85,10 +83,8 @@ typedef struct {
PlMotion motion; // Bitflag variable to indicate motion conditions. See defines above.
SpindleState spindle; // Spindle enable state
CoolantState coolant; // Coolant state
#ifdef USE_LINE_NUMBERS
int32_t line_number; // Desired line number to report when executing.
#endif
bool is_jog; // true if this was generated due to a jog command
int32_t line_number; // Desired line number to report when executing.
bool is_jog; // true if this was generated due to a jog command
} plan_line_data_t;
// Initialize and reset the motion plan subsystem

View File

@@ -996,9 +996,7 @@ static void protocol_exec_rt_suspend() {
pl_data->motion = {};
pl_data->motion.systemMotion = 1;
pl_data->motion.noFeedOverride = 1;
#ifdef USE_LINE_NUMBERS
pl_data->line_number = PARKING_MOTION_LINE_NUMBER;
#endif
pl_data->line_number = PARKING_MOTION_LINE_NUMBER;
plan_block_t* block = plan_get_current_block();
CoolantState restore_coolant;

View File

@@ -24,15 +24,16 @@
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
*/
// Line buffer size from the serial input stream to be executed.
// Line buffer size from the serial input stream to be executed.Also, governs the size of
// each of the startup blocks, as they are each stored as a string of this size.
//
// NOTE: Not a problem except for extreme cases, but the line buffer size can be too small
// and g-code blocks can get truncated. Officially, the g-code standards support up to 256
// characters. In future versions, this will be increased, when we know how much extra
// memory space we can invest into here or we re-write the g-code parser not to have this
// buffer.
#ifndef LINE_BUFFER_SIZE
# define LINE_BUFFER_SIZE 256
#endif
const int LINE_BUFFER_SIZE = 256;
void protocol_reset();

View File

@@ -641,17 +641,18 @@ void report_realtime_status(uint8_t client) {
strcat(status, temp);
}
#ifdef USE_LINE_NUMBERS
// Report current line number
plan_block_t* cur_block = plan_get_current_block();
if (cur_block != NULL) {
uint32_t ln = cur_block->line_number;
if (ln > 0) {
sprintf(temp, "|Ln:%d", ln);
strcat(status, temp);
if (config->_useLineNumbers) {
// Report current line number
plan_block_t* cur_block = plan_get_current_block();
if (cur_block != NULL) {
uint32_t ln = cur_block->line_number;
if (ln > 0) {
sprintf(temp, "|Ln:%d", ln);
strcat(status, temp);
}
}
}
#endif
// Report realtime feed speed
if (config->_reportInches) {
sprintf(temp, "|FS:%.1f,%d", st_get_realtime_rate() / MM_PER_INCH, sys.spindle_speed);

View File

@@ -77,10 +77,10 @@ void init_output_pins() {
}
// Setup M67 Pins
myAnalogOutputs[0] = new UserOutput::AnalogOutput(0, userOutputs->_analogOutput[0], USER_ANALOG_PIN_0_FREQ);
myAnalogOutputs[1] = new UserOutput::AnalogOutput(1, userOutputs->_analogOutput[1], USER_ANALOG_PIN_1_FREQ);
myAnalogOutputs[2] = new UserOutput::AnalogOutput(2, userOutputs->_analogOutput[2], USER_ANALOG_PIN_2_FREQ);
myAnalogOutputs[3] = new UserOutput::AnalogOutput(3, userOutputs->_analogOutput[3], USER_ANALOG_PIN_3_FREQ);
myAnalogOutputs[0] = new UserOutput::AnalogOutput(0, userOutputs->_analogOutput[0], userOutputs->_analogFrequency[0]);
myAnalogOutputs[1] = new UserOutput::AnalogOutput(1, userOutputs->_analogOutput[1], userOutputs->_analogFrequency[1]);
myAnalogOutputs[2] = new UserOutput::AnalogOutput(2, userOutputs->_analogOutput[2], userOutputs->_analogFrequency[2]);
myAnalogOutputs[3] = new UserOutput::AnalogOutput(3, userOutputs->_analogOutput[3], userOutputs->_analogFrequency[3]);
}
void system_flag_wco_change() {