diff --git a/changelog.md b/changelog.md index 25988ac..a759965 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,34 @@ ## grblHAL changelog +Build 20231229 + +Core: + +* Fixed regression that prevented builds with compatibiliy level set > 1. + +* Added `[SIGNALS:xxx]` element to the `$I` output, `xxx` uses the same letters as the `Pn:` +element in the [real time report](https://github.com/grblHAL/core/wiki/Report-extensions#realtime-report) and list all available from the controller except limits inputs. + +Drivers: + +* Most: added new configuration options in _my_machine.h_ for assigning optional signals to aux input ports. These are: +1. `SAFETY_DOOR_ENABLE` - bound to aux port in the map file for backwards comaptibility. +2. `MOTOR_FAULT_ENABLE` - bound to aux port in the map file since a single MCU input might be routed to several external inputs. +3. `MOTOR_WARNING_ENABLE` - bound to aux port in the map file since a single MCU input might be routed to several external inputs. +4. `PROBE_DISCONNECT_ENABLE` - assigned from unused ports. +5. `STOP_DISABLE_ENABLE` - assigned from unused ports. +6. `BLOCK_DELETE_ENABLE` - assigned from unused ports. +7. `SINGLE_BLOCK_ENABLE` - assigned from unused ports. +8. `LIMITS_OVERRIDE_ENABLE` - assigned from unused ports. Always active low. + +If too many inputs are enabled assignment will fail silently for those who cannot be bound. +__NOTE:__ core functionality for some of these inputs might change after user input! +Tip: use the `$pins` command to output the mapping. + +* ESP32: moved board maps and board specific code to separate folder. + +--- + 20231226 Core: diff --git a/config.h b/config.h index 8cb727f..05453a4 100644 --- a/config.h +++ b/config.h @@ -177,9 +177,20 @@ the speed is not limited to 115200 baud. An example is native USB streaming. #define CHECK_MODE_DELAY 0 // ms #endif +/*! \def DEBOUNCE_DELAY +\brief +When > 0 adds a short delay when an input changes state to avoid switch bounce +or EMI triggering the related interrupt falsely or too many times. +*/ +#if !defined DEBOUNCE_DELAY || defined __DOXYGEN__ +#define DEBOUNCE_DELAY 40 // ms +#endif + // --------------------------------------------------------------------------------------- // ADVANCED CONFIGURATION OPTIONS: +#define ENABLE_PATH_BLENDING Off // Do NOT enable unless working on adding this feature! + // Enables code for debugging purposes. Not for general use and always in constant flux. //#define DEBUG // Uncomment to enable. Default disabled. //#define DEBUGOUT 0 // Uncomment to claim serial port with given instance number and add HAL entry point for debug output. diff --git a/crossbar.c b/crossbar.c index 92c9bd2..efd535b 100644 --- a/crossbar.c +++ b/crossbar.c @@ -127,3 +127,16 @@ limit_signals_t xbar_get_homing_source_from_cycle (axes_signals_t homing_cycle) return source; } + +const char *xbar_fn_to_pinname (pin_function_t fn) +{ + const char *name = NULL; + uint_fast8_t idx = sizeof(pin_names) / sizeof(pin_name_t); + + do { + if(pin_names[--idx].function == fn) + name = pin_names[idx].name; + } while(idx && !name); + + return name ? name : "N/A"; +} diff --git a/crossbar.h b/crossbar.h index 271dfc6..66899a5 100644 --- a/crossbar.h +++ b/crossbar.h @@ -503,5 +503,6 @@ void xbar_set_homing_source (void); limit_signals_t xbar_get_homing_source (void); limit_signals_t xbar_get_homing_source_from_cycle (axes_signals_t homing_cycle); axes_signals_t xbar_fn_to_axismask (pin_function_t id); +const char *xbar_fn_to_pinname (pin_function_t id); #endif diff --git a/driver_opts.h b/driver_opts.h index 0217e1a..ec8a820 100644 --- a/driver_opts.h +++ b/driver_opts.h @@ -379,9 +379,32 @@ #endif #endif +// Optional control signals + #ifndef SAFETY_DOOR_ENABLE #define SAFETY_DOOR_ENABLE 0 #endif +#ifndef PROBE_DISCONNECT_ENABLE +#define PROBE_DISCONNECT_ENABLE 0 +#endif +#ifndef STOP_DISABLE_ENABLE +#define STOP_DISABLE_ENABLE 0 +#endif +#ifndef BLOCK_DELETE_ENABLE +#define BLOCK_DELETE_ENABLE 0 +#endif +#ifndef SINGLE_BLOCK_ENABLE +#define SINGLE_BLOCK_ENABLE 0 +#endif +#ifndef MOTOR_FAULT_ENABLE +#define MOTOR_FAULT_ENABLE 0 +#endif +#ifndef MOTOR_WARNING_ENABLE +#define MOTOR_WARNING_ENABLE 0 +#endif +#ifndef LIMITS_OVERRIDE_ENABLE +#define LIMITS_OVERRIDE_ENABLE 0 +#endif #if SAFETY_DOOR_ENABLE && defined(NO_SAFETY_DOOR_SUPPORT) #error "Driver does not support safety door functionality!" @@ -397,6 +420,8 @@ #warning "Enabling ESTOP may not work with all senders!" #endif +// + #ifndef WIFI_ENABLE #define WIFI_ENABLE 0 #endif diff --git a/gcode.c b/gcode.c index 39405ac..07aad75 100644 --- a/gcode.c +++ b/gcode.c @@ -1084,12 +1084,7 @@ status_code_t gc_execute_block (char *block) } break; - case 61: - word_bit.modal_group.G13 = On; - if (mantissa != 0) // [G61.1 not supported] - FAIL(Status_GcodeUnsupportedCommand); - break; -/* +#if ENABLE_PATH_BLENDING case 61: word_bit.modal_group.G13 = On; if (mantissa != 0 || mantissa != 10) @@ -1101,7 +1096,13 @@ status_code_t gc_execute_block (char *block) word_bit.modal_group.G13 = On; gc_block.modal.control = ControlMode_PathBlending; // G64 break; -*/ +#else + case 61: + word_bit.modal_group.G13 = On; + if (mantissa != 0) // [G61.1 not supported] + FAIL(Status_GcodeUnsupportedCommand); + break; +#endif case 65: // NOTE: Mach 3/4 GCode word_bit.modal_group.G0 = On; @@ -2081,14 +2082,17 @@ status_code_t gc_execute_block (char *block) } // [16. Set path control mode ]: N/A. Only G61. G61.1 and G64 NOT SUPPORTED. -/* - if (command_words.G13) { // Check if called in block +#if ENABLE_PATH_BLENDING + if(command_words.G13) { // Check if called in block if(gc_block.modal.control == ControlMode_PathBlending) { - gc_state.blending_tolerance = gc_block.words.p ? gc_block.values.p : 0.0f; - gc_block.words.p = Off; - } + gc_state.path_tolerance = gc_block.words.p ? gc_block.values.p : 0.0f; + gc_state.cam_tolerance = gc_block.words.q ? gc_block.values.q : 0.0f; + gc_block.words.p = gc_block.words.q = Off; + } else + gc_state.path_tolerance = gc_state.cam_tolerance = 0.0f; } -*/ +#endif + // [17. Set distance mode ]: N/A. Only G91.1. G90.1 NOT SUPPORTED. // [18. Set retract mode ]: N/A. @@ -2159,7 +2163,10 @@ status_code_t gc_execute_block (char *block) } while(idx); break; - case 1: case 10: case 11: + case 1: case 10: +#if COMPATIBILITY_LEVEL <= 1 + case 11: +#endif if(grbl.tool_table.n_tools) { if(p_value == 0 || p_value > grbl.tool_table.n_tools) FAIL(Status_GcodeIllegalToolTableEntry); // [Greater than max allowed tool number] @@ -2172,8 +2179,10 @@ status_code_t gc_execute_block (char *block) } float g59_3_offset[N_AXIS]; +#if COMPATIBILITY_LEVEL <= 1 if(gc_block.values.l == 11 && !settings_read_coord_data(CoordinateSystem_G59_3, &g59_3_offset)) FAIL(Status_SettingReadFail); +#endif if(gc_block.values.l == 1) grbl.tool_table.read(p_value, &grbl.tool_table.tool[p_value]); @@ -3258,6 +3267,9 @@ status_code_t gc_execute_block (char *block) // [16. Set path control mode ]: G61.1/G64 NOT SUPPORTED // gc_state.modal.control = gc_block.modal.control; // NOTE: Always default. +#if ENABLE_PATH_BLENDING + gc_state.modal.control = gc_block.modal.control; +#endif // [17. Set distance mode ]: gc_state.modal.distance_incremental = gc_block.modal.distance_incremental; @@ -3349,9 +3361,13 @@ status_code_t gc_execute_block (char *block) gc_state.modal.motion = gc_block.modal.motion; gc_state.modal.canned_cycle_active = gc_block.modal.canned_cycle_active; - if (gc_state.modal.motion != MotionMode_None && axis_command == AxisCommand_MotionMode) { + if(gc_state.modal.motion != MotionMode_None && axis_command == AxisCommand_MotionMode) { plan_data.output_commands = output_commands; +#if ENABLE_PATH_BLENDING + plan_data.cam_tolerance = gc_state.cam_tolerance; + plan_data.path_tolerance = gc_state.path_tolerance; +#endif output_commands = NULL; pos_update_t gc_update_pos = GCUpdatePos_Target; diff --git a/gcode.h b/gcode.h index e399bd1..a5ba6b6 100644 --- a/gcode.h +++ b/gcode.h @@ -380,8 +380,8 @@ typedef struct { float ijk[3]; //!< I,J,K Axis arc offsets float k; //!< G33 distance per revolution float m; //!< G65 argument. - float p; //!< G10 or dwell parameters - float q; //!< User defined M-code parameter, M67 output value, G83 delta increment + float p; //!< G10, 664 or dwell parameters + float q; //!< User defined M-code parameter, M67 output value, G64 naive CAM tolerance, G83 delta increment float r; //!< Arc radius or retract position float s; //!< Spindle speed - single-meaning word float xyz[N_AXIS]; //!< X,Y,Z (and A,B,C,U,V when enabled) translational axes @@ -462,7 +462,9 @@ typedef struct { //< uint8_t cutter_comp; //!< {G40} NOTE: Don't track. Only default supported. tool_offset_mode_t tool_offset_mode; //!< {G43,G43.1,G49} coord_system_t coord_system; //!< {G54,G55,G56,G57,G58,G59,G59.1,G59.2,G59.3} - // control_mode_t control; //!< {G61} NOTE: Don't track. Only default supported. +#if ENABLE_PATH_BLENDING + control_mode_t control; //!< {G61} NOTE: Don't track. Only default supported. +#endif program_flow_t program_flow; //!< {M0,M1,M2,M30,M60} coolant_state_t coolant; //!< {M7,M8,M9} spindle_mode_t spindle; //!< {M3,M4,M5 and G96,G97} @@ -532,7 +534,10 @@ typedef struct { float feed_rate; //!< Millimeters/min float distance_per_rev; //!< Millimeters/rev float position[N_AXIS]; //!< Where the interpreter considers the tool to be at this point in the code - // float blending_tolerance; //!< Motion blending tolerance +#if ENABLE_PATH_BLENDING + float path_tolerance; //!< Path blending tolerance + float cam_tolerance; //!< Naive CAM tolerance +#endif int32_t line_number; //!< Last line number sent tool_id_t tool_pending; //!< Tool to be selected on next M6 #if NGC_EXPRESSIONS_ENABLE diff --git a/grbl.h b/grbl.h index 547554f..ced1557 100644 --- a/grbl.h +++ b/grbl.h @@ -42,7 +42,7 @@ #else #define GRBL_VERSION "1.1f" #endif -#define GRBL_BUILD 20231222 +#define GRBL_BUILD 20231229 #define GRBL_URL "https://github.com/grblHAL" diff --git a/pin_bits_masks.h b/pin_bits_masks.h index a1a9a76..7b6c7b9 100644 --- a/pin_bits_masks.h +++ b/pin_bits_masks.h @@ -89,14 +89,6 @@ #endif #endif -#if SAFETY_DOOR_ENABLE && !defined(SAFETY_DOOR_BIT) -#ifdef SAFETY_DOOR_PIN -#define SAFETY_DOOR_BIT (1<type == NVS_None || nvs->type == NVS_Emulated)) { @@ -1232,7 +1237,7 @@ void report_realtime_status (void) append = axis_signals_tostring(append, lim_pin_state); if(ctrl_pin_state.value) - append = control_signals_tostring(append, ctrl_pin_state); + append = control_signals_tostring(append, ctrl_pin_state, false); *append = '\0'; hal.stream.write_all(buf); @@ -2074,7 +2079,7 @@ status_code_t report_last_signals_event (sys_state_t state, char *args) strcpy(buf, "[LASTEVENTS:"); - append = control_signals_tostring(append, sys.last_event.control); + append = control_signals_tostring(append, sys.last_event.control, false); *append++ = ','; append = add_limits(append, sys.last_event.limits); @@ -2141,19 +2146,6 @@ status_code_t report_spindle_data (sys_state_t state, char *args) return spindle->get_data ? Status_OK : Status_InvalidStatement; } -static const char *get_pinname (pin_function_t function) -{ - const char *name = NULL; - uint_fast8_t idx = sizeof(pin_names) / sizeof(pin_name_t); - - do { - if(pin_names[--idx].function == function) - name = pin_names[idx].name; - } while(idx && !name); - - return name ? name : "N/A"; -} - static void report_pin (xbar_t *pin, void *data) { hal.stream.write("[PIN:"); @@ -2161,7 +2153,7 @@ static void report_pin (xbar_t *pin, void *data) hal.stream.write((char *)pin->port); hal.stream.write(uitoa(pin->pin)); hal.stream.write(","); - hal.stream.write(get_pinname(pin->function)); + hal.stream.write(xbar_fn_to_pinname(pin->function)); if(pin->description) { hal.stream.write(","); hal.stream.write(pin->description); diff --git a/settings.c b/settings.c index a1bc939..dcda797 100644 --- a/settings.c +++ b/settings.c @@ -42,6 +42,8 @@ settings_t settings; +static const control_signals_t limits_override = { .limits_override = On }; + const settings_restore_t settings_all = { .defaults = SETTINGS_RESTORE_DEFAULTS, .parameters = SETTINGS_RESTORE_PARAMETERS, @@ -968,7 +970,7 @@ static status_code_t set_ngc_debug_out (setting_id_t id, uint_fast16_t int_value static status_code_t set_control_invert (setting_id_t id, uint_fast16_t int_value) { - settings.control_invert.mask = int_value & hal.signals_cap.mask; + settings.control_invert.mask = (int_value & hal.signals_cap.mask) | limits_override.mask; return Status_OK; } @@ -1584,7 +1586,7 @@ static uint32_t get_int (setting_id_t id) break; case Setting_ControlInvertMask: - value = settings.control_invert.mask & hal.signals_cap.mask; + value = (settings.control_invert.mask & hal.signals_cap.mask) & ~limits_override.mask; break; case Setting_SpindleInvertMask: @@ -2140,6 +2142,8 @@ bool read_global_settings () settings.steppers.enable_invert.mask = AXES_BITMASK; #endif + settings.control_invert.mask |= limits_override.mask; + return ok && settings.version == SETTINGS_VERSION; } @@ -2172,7 +2176,7 @@ void settings_restore (settings_restore_t restore) memcpy(&settings, &defaults, sizeof(settings_t)); - settings.control_invert.mask &= hal.signals_cap.mask; + settings.control_invert.mask = (settings.control_invert.mask & hal.signals_cap.mask) | limits_override.mask; settings.spindle.invert.ccw &= spindle_get_caps(false).direction; settings.spindle.invert.pwm &= spindle_get_caps(false).pwm_invert; #if ENABLE_BACKLASH_COMPENSATION