From 02b45f86e5772d628fd19f049efdd9335bdf8fd0 Mon Sep 17 00:00:00 2001 From: Terje Io Date: Thu, 31 Jul 2025 08:19:07 +0200 Subject: [PATCH] Fix for corrupted tool table entries not beeing reset. This may happen on resizing the tool table. Added system parameter _tool_table_size, 0 if a tool table is not enabled. Removed dependency on safety door input for parking settings: $41, $42, $56-$59, $392 and $393. Removed strict dependency on spindle encoder input for spindle synced motion, allows the use of the stepper spindle which has an implicit encoder. --- changelog.md | 28 +++++++++++++++++++++++++--- config.h | 8 ++++++++ errors.c | 1 + errors.h | 1 + grbl.h | 2 +- ioports.c | 35 ++++++++++++++++++++++++++++------- ioports.h | 1 + ngc_params.c | 7 ++++++- ngc_params.h | 1 + nuts_bolts.c | 8 ++++---- nuts_bolts.h | 4 ++-- pin_bits_masks.h | 4 ++-- settings.c | 46 +++++++++++++++------------------------------- settings.h | 4 ++-- stepper.c | 4 +++- 15 files changed, 100 insertions(+), 54 deletions(-) diff --git a/changelog.md b/changelog.md index 81100c9..10fb68a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,17 +1,39 @@ ## grblHAL changelog +Build 20250731 + +Core: + +* Fix for corrupted tool table entries not beeing reset. This may happen on resizing the tool table. + +* Added system parameter `_tool_table_size`, 0 if a tool table is not enabled. + +* Removed dependency on safety door input for parking settings: `$41`, `$42`, `$56`-`$59`, `$392` and `$393`. + +* Removed strict dependency on spindle encoder input for spindle synced motion, allows the use of the stepper spindle which has an implicit encoder. + +Plugins: + +* Spindle, stepper: updated to work with new spindle sync handling. + +* Plugins misc, eventout: added support for spindle at speed event \(to be verified\), updated for core changes. + +* Plugins keypad, macros: updated for core changes. + +--- + Build 20250724 Core: -Fix for optional control signals not respecting `$14` inversion setting. Ref. issue [#780](https://github.com/grblHAL/core/issues/780). +* Fix for optional control signals not respecting `$14` inversion setting. Ref. issue [#780](https://github.com/grblHAL/core/issues/780). -For developers: added core `on_spindle_at_speed` event. This must be verified with actual VFD spindles, I only have a simulator available. +* For developers: added core `on_spindle_at_speed` event. This must be verified with actual VFD spindles, I only have a simulator available. Improved handling of "iterated" settings, can now be fully implemented by plugins. Plugins: -* Spindle, select: updated for core change, fixed bug in tool number start vs. spindle settings \($52x\). Ref. iMXRT1062 issue [#99](https://github.com/grblHAL/iMXRT1062/issues/99). +* Spindle, select: updated for core change, fixed bug in tool number start vs. spindle settings \(`$52x`\). Ref. iMXRT1062 issue [#99](https://github.com/grblHAL/iMXRT1062/issues/99). * Spindle, offset: added setting `$772` for options, currently _Update G92 on spindle change_ is available. diff --git a/config.h b/config.h index 9997066..45c1721 100644 --- a/config.h +++ b/config.h @@ -1418,6 +1418,14 @@ and less range over the total 255 PWM levels to signal different spindle speeds. #endif ///@} +/*! @name $485 - Setting_EnableToolPersistence +*/ +///@{ +#if !defined DEFAULT_PERSIST_TOOL || defined __DOXYGEN__ +#define DEFAULT_PERSIST_TOOL Off +#endif +///@} + // Homing settings (Group_Homing) /*! @name $22 - Setting_HomingEnable diff --git a/errors.c b/errors.c index 4027cd8..b745564 100644 --- a/errors.c +++ b/errors.c @@ -88,6 +88,7 @@ PROGMEM static const status_detail_t status_detail[] = { { Status_GCodeCoordSystemLocked, "Coordinate system is locked." }, #endif { Status_UnexpectedDemarcation, "Unexpected file demarcation." }, + { Status_AuxiliaryPortUnavailable, "Port is not available" }, #if NGC_EXPRESSIONS_ENABLE { Status_ExpressionUknownOp, "Unknown operation found in expression." }, { Status_ExpressionDivideByZero, "Divide by zero in expression attempted." }, diff --git a/errors.h b/errors.h index 8fe5443..2a48f28 100644 --- a/errors.h +++ b/errors.h @@ -87,6 +87,7 @@ typedef enum { Status_IllegalHomingConfiguration = 55, Status_GCodeCoordSystemLocked = 56, Status_UnexpectedDemarcation = 57, + Status_AuxiliaryPortUnavailable = 58, Status_SDMountError = 60, Status_FileReadError = 61, diff --git a/grbl.h b/grbl.h index 69259f1..2b53b1d 100644 --- a/grbl.h +++ b/grbl.h @@ -42,7 +42,7 @@ #else #define GRBL_VERSION "1.1f" #endif -#define GRBL_BUILD 20250724 +#define GRBL_BUILD 20250731 #define GRBL_URL "https://github.com/grblHAL" diff --git a/ioports.c b/ioports.c index 759a1fe..f49e975 100644 --- a/ioports.c +++ b/ioports.c @@ -191,6 +191,7 @@ uint8_t ioports_unclaimed (io_port_type_t type, io_port_direction_t dir) struct ff_data { uint8_t port; + uint32_t max_port; const char *description; }; @@ -198,7 +199,9 @@ static bool match_port (xbar_t *properties, uint8_t port, void *data) { struct ff_data *ff_data = (struct ff_data *)data; - if(ff_data->description && (properties->description == NULL || strcmp(properties->description, ff_data->description))) + if(ff_data->description + ? (properties->description == NULL || strcmp(properties->description, ff_data->description)) + : port >= ff_data->max_port) return false; ff_data->port = port; @@ -206,24 +209,29 @@ static bool match_port (xbar_t *properties, uint8_t port, void *data) return true; } -/*! \brief find first free or claimed digital or analog port. +/*! \brief find claimable or claimed analog or digital port. Search starts from the last port number. \param type as an \a #io_port_type_t enum value. \param dir as an \a #io_port_direction_t enum value. -\param description pointer to a \a char constant for the pin description of a previousely claimed port or \a NULL if searching for the first free port. +\param description pointer to a \a char constant for the pin description of a previousely claimed port +or a port number to be used as the upper limit for the search, or \a NULL if searching for the first free port. \returns the port number if successful, 0xFF (255) if not. */ uint8_t ioport_find_free (io_port_type_t type, io_port_direction_t dir, pin_cap_t filter, const char *description) { - struct ff_data ff_data; + struct ff_data ff_data = { .port = IOPORT_UNASSIGNED, .max_port = IOPORT_UNASSIGNED + 1 }; - ff_data.port = IOPORT_UNASSIGNED; - ff_data.description = (description && *description) ? description : NULL; + if((ff_data.description = (description && *description) ? description : NULL)) { + uint_fast8_t pos = 0; + read_uint(ff_data.description, &pos, &ff_data.max_port); + if(ff_data.max_port <= IOPORT_UNASSIGNED) + ff_data.description = NULL; + } // TODO: pass modified filter with .claimable off when looking for description match? if(ff_data.description && !ioports_enumerate(type, dir, (pin_cap_t){}, match_port, (void *)&ff_data)) ff_data.description = NULL; - if(ff_data.description == NULL) + if(ff_data.description == NULL && ff_data.max_port != IOPORT_UNASSIGNED) ioports_enumerate(type, dir, filter, match_port, (void *)&ff_data); return ff_data.port; @@ -317,6 +325,19 @@ xbar_t *ioport_claim (io_port_type_t type, io_port_direction_t dir, uint8_t *por return portinfo; } +/*! \brief Check if a analog or digital port is available for exclusive use. +\param type as an \a #io_port_type_t enum value. +\param dir as an \a #io_port_direction_t enum value. +\param port a \a uint8_t holding the ports aux number. +\returns \a TRUE if available, \a FALSE if not. +*/ +bool ioport_claimable (io_port_type_t type, io_port_direction_t dir, uint8_t port) +{ + xbar_t *portinfo = port == IOPORT_UNASSIGNED ? NULL : get_info(type, dir, port, false); + + return port == IOPORT_UNASSIGNED || (portinfo && portinfo->cap.claimable); +} + // Deprecated void ioport_assign_function (aux_ctrl_t *aux_ctrl, pin_function_t *function) { diff --git a/ioports.h b/ioports.h index ecd6759..c26ec99 100644 --- a/ioports.h +++ b/ioports.h @@ -197,6 +197,7 @@ uint8_t ioports_available (io_port_type_t type, io_port_direction_t dir); uint8_t ioports_unclaimed (io_port_type_t type, io_port_direction_t dir); xbar_t *ioport_get_info (io_port_type_t type, io_port_direction_t dir, uint8_t port); xbar_t *ioport_claim (io_port_type_t type, io_port_direction_t dir, uint8_t *port, const char *description); +bool ioport_claimable (io_port_type_t type, io_port_direction_t dir, uint8_t port); io_port_cando_t ioports_can_do (void); uint8_t ioport_find_free (io_port_type_t type, io_port_direction_t dir, pin_cap_t filter, const char *description); bool ioports_enumerate (io_port_type_t type, io_port_direction_t dir, pin_cap_t filter, ioports_enumerate_callback_ptr callback, void *data); diff --git a/ngc_params.c b/ngc_params.c index ea01e17..9da2807 100644 --- a/ngc_params.c +++ b/ngc_params.c @@ -413,7 +413,8 @@ PROGMEM static const ngc_named_ro_param_t ngc_named_ro_param[] = { { .name = "_probe_state", .id = NGCParam_probe_state }, { .name = "_toolsetter_state", .id = NGCParam_toolsetter_state }, { .name = "_homed_state", .id = NGCParam_homed_state }, - { .name = "_homed_axes", .id = NGCParam_homed_axes } + { .name = "_homed_axes", .id = NGCParam_homed_axes }, + { .name = "_tool_table_size", .id = NGCParam_tool_table_size } }; // Named parameters @@ -670,6 +671,10 @@ float ngc_named_param_get_by_id (ncg_name_param_id_t id) value = (float)sys.homed.mask; break; + case NGCParam_tool_table_size: + value = (float)grbl.tool_table.n_tools; + break; + default: value = NAN; } diff --git a/ngc_params.h b/ngc_params.h index f3ae7b0..12c40b5 100644 --- a/ngc_params.h +++ b/ngc_params.h @@ -104,6 +104,7 @@ typedef enum { NGCParam_toolsetter_state, NGCParam_homed_state, NGCParam_homed_axes, + NGCParam_tool_table_size, NGCParam_Last } ncg_name_param_id_t; diff --git a/nuts_bolts.c b/nuts_bolts.c index 40596d8..e5b72fc 100644 --- a/nuts_bolts.c +++ b/nuts_bolts.c @@ -181,9 +181,9 @@ char *trim_float (char *s) } // Extracts an unsigned integer value from a string. -status_code_t read_uint (char *line, uint_fast8_t *char_counter, uint32_t *uint_ptr) +status_code_t read_uint (const char *line, uint_fast8_t *char_counter, uint32_t *uint_ptr) { - char *ptr = line + *char_counter; + const char *ptr = line + *char_counter; int_fast8_t exp = 0; uint_fast8_t ndigit = 0, c; uint32_t intval = 0; @@ -239,9 +239,9 @@ status_code_t read_uint (char *line, uint_fast8_t *char_counter, uint32_t *uint_ // Scientific notation is officially not supported by g-code, and the 'E' character may // be a g-code word on some CNC systems. So, 'E' notation will not be recognized. // NOTE: Thanks to Radu-Eosif Mihailescu for identifying the issues with using strtod(). -bool read_float (char *line, uint_fast8_t *char_counter, float *float_ptr) +bool read_float (const char *line, uint_fast8_t *char_counter, float *float_ptr) { - char *ptr = line + *char_counter; + const char *ptr = line + *char_counter; int_fast8_t exp = 0; uint_fast8_t ndigit = 0, c; uint32_t intval = 0; diff --git a/nuts_bolts.h b/nuts_bolts.h index d125d59..d4003d7 100644 --- a/nuts_bolts.h +++ b/nuts_bolts.h @@ -252,12 +252,12 @@ char *trim_float (char *s); // Returns true if float value is a whole number (integer) bool isintf (float value); -status_code_t read_uint (char *line, uint_fast8_t *char_counter, uint32_t *uint_ptr); +status_code_t read_uint (const char *line, uint_fast8_t *char_counter, uint32_t *uint_ptr); // 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 // a pointer to the result variable. Returns true when it succeeds -bool read_float (char *line, uint_fast8_t *char_counter, float *float_ptr); +bool read_float (const char *line, uint_fast8_t *char_counter, float *float_ptr); // Non-blocking delay function used for general operation and suspend features. bool delay_sec (float seconds, delaymode_t mode); diff --git a/pin_bits_masks.h b/pin_bits_masks.h index d7f0994..3eaed8f 100644 --- a/pin_bits_masks.h +++ b/pin_bits_masks.h @@ -603,8 +603,8 @@ static inline void aux_ctrl_claim_out_ports (aux_claim_explicit_out_ptr aux_clai #define SPINDLE_PULSE_BIT 0 #endif -#if SPINDLE_SYNC_ENABLE && (SPINDLE_INDEX_BIT + SPINDLE_PULSE_BIT) == 0 -#error "Spindle sync requires SPINDLE_PULSE_PIN and SPINDLE_INDEX_PIN defined in the board map!" +#if SPINDLE_ENCODER_ENABLE && (SPINDLE_INDEX_BIT + SPINDLE_PULSE_BIT) == 0 +#error "Spindle encoder requires SPINDLE_PULSE_PIN and SPINDLE_INDEX_PIN defined in the board map!" #endif #ifndef SPI_IRQ_PIN diff --git a/settings.c b/settings.c index 7824c08..fca3503 100644 --- a/settings.c +++ b/settings.c @@ -91,6 +91,7 @@ PROGMEM const settings_t defaults = { .flags.tool_change_fast_pulloff = DEFAULT_TOOLCHANGE_FAST_PROBE_PULLOFF, .flags.no_unlock_after_estop = DEFAULT_NO_UNLOCK_AFTER_ESTOP, .flags.keep_offsets_on_reset = DEFAULT_KEEP_OFFSETS_ON_RESET, + .flags.tool_persistent = DEFAULT_PERSIST_TOOL, .probe.disable_probe_pullup = DEFAULT_PROBE_SIGNAL_DISABLE_PULLUP, .probe.allow_feed_override = DEFAULT_ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES, @@ -378,7 +379,7 @@ PROGMEM static const setting_group_detail_t setting_group_detail [] = { { Group_Root, Group_Toolchange, "Tool change" }, { Group_Root, Group_Homing, "Homing" }, { Group_Root, Group_Probing, "Probing" }, - { Group_Root, Group_SafetyDoor, "Safety door" }, + { Group_Root, Group_SafetyDoor, "Parking/Safety door" }, { Group_Root, Group_Jogging, "Jogging"}, { Group_Root, Group_Stepper, "Stepper" }, { Group_Root, Group_MotorDriver, "Stepper driver" }, @@ -1229,12 +1230,6 @@ inline static setting_id_t normalize_id (setting_id_t id) id = (setting_id_t)(Setting_EncoderSettingsBase + (id % ENCODER_SETTINGS_INCREMENT)); else if(id > Setting_ModbusTCPBase && id <= Setting_ModbusTCPMax) id = (setting_id_t)(Setting_ModbusTCPBase + (id % MODBUS_TCP_SETTINGS_INCREMENT)); - else if((id > Setting_Macro0 && id <= Setting_Macro9) || - (id > Setting_MacroPort0 && id <= Setting_MacroPort9) || - (id > Setting_ButtonAction0 && id <= Setting_ButtonAction9) || - (id > Setting_Action0 && id <= Setting_Action9) || - (id > Setting_ActionPort0 && id <= Setting_ActionPort9)) - id = (setting_id_t)(id - (id % 10)); return id; } @@ -1929,23 +1924,16 @@ static bool is_setting_available (const setting_detail_t *setting, uint_fast16_t #ifndef NO_SAFETY_DOOR_SUPPORT - case Setting_ParkingEnable: - case Setting_ParkingAxis: - case Setting_ParkingPulloutIncrement: - case Setting_ParkingPulloutRate: - case Setting_ParkingTarget: - case Setting_ParkingFastRate: - case Setting_RestoreOverrides: case Setting_DoorOptions: available = hal.signals_cap.safety_door_ajar; break; case Setting_DoorSpindleOnDelay: - available = hal.signals_cap.safety_door_ajar && spindle_get_count() && !spindle_get_caps(true).at_speed; + available = spindle_get_count() && !spindle_get_caps(true).at_speed; break; case Setting_DoorCoolantOnDelay: - available = hal.signals_cap.safety_door_ajar && hal.coolant_cap.mask; + available = hal.coolant_cap.mask != 0; break; #endif @@ -2071,10 +2059,8 @@ PROGMEM static const setting_detail_t setting_detail[] = { { Setting_SpindlePPR, Group_Spindle, "Spindle pulses per revolution (PPR)", NULL, Format_Int16, "###0", NULL, NULL, Setting_IsExtended, &settings.spindle.ppr, NULL, is_setting_available, { .reboot_required = On } }, { Setting_EnableLegacyRTCommands, Group_General, "Enable legacy RT commands", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_enable_legacy_rt_commands, get_int, NULL }, { Setting_JogSoftLimited, Group_Jogging, "Limit jog commands", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_jog_soft_limited, get_int, NULL }, -#ifndef NO_SAFETY_DOOR_SUPPORT - { Setting_ParkingEnable, Group_SafetyDoor, "Parking cycle", NULL, Format_XBitfield, "Enable,Enable parking override control,Deactivate upon init", NULL, NULL, Setting_IsExtendedFn, set_parking_enable, get_int, is_setting_available }, - { Setting_ParkingAxis, Group_SafetyDoor, "Parking axis", NULL, Format_RadioButtons, "X,Y,Z", NULL, NULL, Setting_IsExtended, &settings.parking.axis, NULL, is_setting_available }, -#endif + { Setting_ParkingEnable, Group_SafetyDoor, "Parking cycle", NULL, Format_XBitfield, "Enable,Enable parking override control,Deactivate upon init", NULL, NULL, Setting_IsExtendedFn, set_parking_enable, get_int, NULL }, + { Setting_ParkingAxis, Group_SafetyDoor, "Parking axis", NULL, Format_RadioButtons, "X,Y,Z", NULL, NULL, Setting_IsExtended, &settings.parking.axis, NULL, NULL }, { Setting_HomingLocateCycles, Group_Homing, "Homing passes", NULL, Format_Int8, "##0", "1", "128", Setting_IsExtended, &settings.homing.locate_cycles, NULL, NULL }, { Setting_HomingCycle_1, Group_Homing, "Axes homing, first pass", NULL, Format_AxisMask, NULL, NULL, NULL, Setting_IsExtendedFn, set_homing_cycle, get_int, NULL }, { Setting_HomingCycle_2, Group_Homing, "Axes homing, second pass", NULL, Format_AxisMask, NULL, NULL, NULL, Setting_IsExtendedFn, set_homing_cycle, get_int, NULL }, @@ -2088,12 +2074,12 @@ PROGMEM static const setting_detail_t setting_detail[] = { #ifdef C_AXIS { Setting_HomingCycle_6, Group_Homing, "Axes homing, sixth pass", NULL, Format_AxisMask, NULL, NULL, NULL, Setting_IsExtendedFn, set_homing_cycle, get_int, NULL }, #endif + { Setting_ParkingPulloutIncrement, Group_SafetyDoor, "Parking pull-out distance", "mm", Format_Decimal, "###0.0", NULL, NULL, Setting_IsExtended, &settings.parking.pullout_increment, NULL, NULL }, + { Setting_ParkingPulloutRate, Group_SafetyDoor, "Parking pull-out rate", "mm/min", Format_Decimal, "###0.0", NULL, NULL, Setting_IsExtended, &settings.parking.pullout_rate, NULL, NULL }, + { Setting_ParkingTarget, Group_SafetyDoor, "Parking target", "mm", Format_Decimal, "-###0.0", "-100000", NULL, Setting_IsExtended, &settings.parking.target, NULL, NULL }, + { Setting_ParkingFastRate, Group_SafetyDoor, "Parking fast rate", "mm/min", Format_Decimal, "###0.0", NULL, NULL, Setting_IsExtended, &settings.parking.rate, NULL, NULL }, + { Setting_RestoreOverrides, Group_General, "Restore overrides", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_restore_overrides, get_int, NULL }, #ifndef NO_SAFETY_DOOR_SUPPORT - { Setting_ParkingPulloutIncrement, Group_SafetyDoor, "Parking pull-out distance", "mm", Format_Decimal, "###0.0", NULL, NULL, Setting_IsExtended, &settings.parking.pullout_increment, NULL, is_setting_available }, - { Setting_ParkingPulloutRate, Group_SafetyDoor, "Parking pull-out rate", "mm/min", Format_Decimal, "###0.0", NULL, NULL, Setting_IsExtended, &settings.parking.pullout_rate, NULL, is_setting_available }, - { Setting_ParkingTarget, Group_SafetyDoor, "Parking target", "mm", Format_Decimal, "-###0.0", "-100000", NULL, Setting_IsExtended, &settings.parking.target, NULL, is_setting_available }, - { Setting_ParkingFastRate, Group_SafetyDoor, "Parking fast rate", "mm/min", Format_Decimal, "###0.0", NULL, NULL, Setting_IsExtended, &settings.parking.rate, NULL, is_setting_available }, - { Setting_RestoreOverrides, Group_General, "Restore overrides", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_restore_overrides, get_int, is_setting_available }, { Setting_DoorOptions, Group_SafetyDoor, "Safety door options", NULL, Format_Bitfield, "Ignore when idle,Keep coolant state on open", NULL, NULL, Setting_IsExtended, &settings.safety_door.flags.value, NULL, is_setting_available }, #endif { Setting_SleepEnable, Group_General, "Sleep enable", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_sleep_enable, get_int, is_setting_available }, @@ -2145,10 +2131,8 @@ PROGMEM static const setting_detail_t setting_detail[] = { #if N_AXIS > 3 { Settings_RotaryAxes, Group_Stepper, "Rotary axes", NULL, Format_Bitfield, rotary_axes, NULL, NULL, Setting_IsExtendedFn, set_rotary_axes, get_int, NULL }, #endif -#ifndef NO_SAFETY_DOOR_SUPPORT - { Setting_DoorSpindleOnDelay, Group_SafetyDoor, "Spindle on delay", "s", Format_Decimal, "#0.0", "0.5", "20", Setting_IsExtended, &settings.safety_door.spindle_on_delay, NULL, is_setting_available, { .allow_null = On } }, - { Setting_DoorCoolantOnDelay, Group_SafetyDoor, "Coolant on delay", "s", Format_Decimal, "#0.0", "0.5", "20", Setting_IsExtended, &settings.safety_door.coolant_on_delay, NULL, is_setting_available, { .allow_null = On } }, -#endif + { Setting_DoorSpindleOnDelay, Group_SafetyDoor, "Spindle on delay", "s", Format_Decimal, "#0.0", "0.5", "20", Setting_IsExtended, &settings.safety_door.spindle_on_delay, NULL, NULL, { .allow_null = On } }, + { Setting_DoorCoolantOnDelay, Group_SafetyDoor, "Coolant on delay", "s", Format_Decimal, "#0.0", "0.5", "20", Setting_IsExtended, &settings.safety_door.coolant_on_delay, NULL, NULL, { .allow_null = On } }, { Setting_SpindleOnDelay, Group_Spindle, "Spindle on delay", "s", Format_Decimal, "#0.0", "0.5", "20", Setting_IsExtendedFn, set_float, get_float, is_setting_available, { .allow_null = On } }, { Setting_SpindleType, Group_Spindle, "Default spindle", NULL, Format_RadioButtons, spindle_types, NULL, NULL, Setting_IsExtendedFn, set_default_spindle, get_int, is_setting_available, { .reboot_required = On } }, { Setting_PlannerBlocks, Group_General, "Planner buffer blocks", NULL, Format_Int16, "####0", "30", "1000", Setting_IsExtended, &settings.planner_buffer_blocks, NULL, NULL, { .reboot_required = On } }, @@ -2273,12 +2257,12 @@ PROGMEM static const setting_descr_t setting_descr[] = { { Setting_JogStepDistance, "Jog distance for single step jogging." }, { Setting_JogSlowDistance, "Jog distance before automatic stop." }, { Setting_JogFastDistance, "Jog distance before automatic stop." }, -#ifndef NO_SAFETY_DOOR_SUPPORT { Setting_ParkingPulloutIncrement, "Spindle pull-out and plunge distance in mm.Incremental distance." }, { Setting_ParkingPulloutRate, "Spindle pull-out/plunge slow feed rate in mm/min." }, { Setting_ParkingTarget, "Parking axis target. In mm, as machine coordinate [-max_travel, 0]." }, { Setting_ParkingFastRate, "Parking fast rate to target after pull-out in mm/min." }, { Setting_RestoreOverrides, "Restore overrides to default values at program end." }, +#ifndef NO_SAFETY_DOOR_SUPPORT { Setting_DoorOptions, "Enable this if it is desirable to open the safety door when in IDLE mode (eg. for jogging)." }, #endif { Setting_SleepEnable, "Enable sleep mode." }, @@ -2516,7 +2500,7 @@ static tool_data_t *settings_get_tool_data (tool_id_t tool_id) if(tool_id && !(hal.nvs.type != NVS_None && hal.nvs.memcpy_from_nvs((uint8_t *)&tool_data[tool_id], NVS_ADDR_TOOL_TABLE + (tool_id - 1) * (sizeof(tool_data_t) + NVS_CRC_BYTES), sizeof(tool_data_t), true) == NVS_TransferResult_OK && tool_data[tool_id].tool_id == tool_id)) { - memset(tool_data, 0, sizeof(tool_data_t)); + memset(&tool_data[tool_id], 0, sizeof(tool_data_t)); tool_data[tool_id].tool_id = tool_id; } diff --git a/settings.h b/settings.h index 238cbc5..b7e7aff 100644 --- a/settings.h +++ b/settings.h @@ -655,8 +655,8 @@ typedef union { typedef struct { safety_door_setting_flags_t flags; // TODO: move to last element in next revision - float spindle_on_delay; // TODO: change to uint16_t in next revision - float coolant_on_delay; // TODO: change to uint16_t in next revision + float spindle_on_delay; // TODO: change to uint16_t and move to parking_setting_flags_t in next revision + float coolant_on_delay; // TODO: change to uint16_t and move to parking_setting_flags_t in next revision } safety_door_settings_t; typedef union { diff --git a/stepper.c b/stepper.c index 2c841cd..56ddc88 100644 --- a/stepper.c +++ b/stepper.c @@ -265,7 +265,9 @@ void st_spindle_sync_cfg (settings_t *settings, settings_changed_flags_t changed spindle_tracker.min_cycles_per_tick = hal.f_step_timer / (uint32_t)(settings->axis[Z_AXIS].max_rate * settings->axis[Z_AXIS].steps_per_mm / 60.0f); // hal.driver_cap.spindle_encoder ?? check? - if((hal.driver_cap.spindle_sync = hal.spindle_data.get && settings->spindle.ppr) && pidf_config_changed(&spindle_tracker.pid, &settings->position.pid)) + if((hal.driver_cap.spindle_sync = !!hal.spindle_data.get && + (!hal.driver_cap.spindle_encoder || settings->spindle.ppr > 0)) && + pidf_config_changed(&spindle_tracker.pid, &settings->position.pid)) pidf_init(&spindle_tracker.pid, &settings->position.pid); }