aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/toolhead.py
Commit message (Collapse)AuthorAgeFilesLines
* klippy: remove a few unused variable assignments (#6504)Kamil Domański2024-04-051-1/+0
| | | Signed-off-by: Kamil Domański <kamil@domanski.co>
* toolhead: Populate minimum_cruise_ratio to printer.configfile.settingsKevin O'Connor2024-04-021-6/+7
| | | | | | | | | | | | The default minimum_cruise_ratio setting does not get populated to the printer.configfile.settings information due to the way the max_accel_to_decel backwards compatibility support was implemented. Slightly rework the config reading so that the default for minimum_cruise_ratio is populated there. Reported by @ReXT3D. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Replace max_accel_to_decel with minimum_cruise_ratioKevin O'Connor2024-03-131-18/+29
| | | | | | | | | The user facing max_accel_to_decel setting is complicated and confusing. Replace it with a new minimum_cruise_ratio parameter. Internally this user-facing parameter will calculate the existing low-level "accel_to_decel" mechanism. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Rename note_kinematic_activity() to note_mcu_movequeue_activity()Kevin O'Connor2024-01-181-7/+7
| | | | | | Rename this function to make it more clear why it is called. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Rename MoveQueue class to LookAheadQueueKevin O'Connor2024-01-181-14/+14
| | | | | | | Rename this class so that is is not confused with the mcu "move queue". Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Extend flushing slightly past required timeKevin O'Connor2024-01-171-3/+5
| | | | | | | | | There is no harm in enabling flushing for a little longer than necessary. In contrast, a slight rounding issue causing a message to not get flushed properly could result in an error. So, extend the flushing time slightly to avoid potential issues. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Ensure full kin_flush_delay after flush_step_generation()Kevin O'Connor2024-01-161-3/+4
| | | | | | | | | | | | | | | | | | | | Commit b7b13588 made it possible that the kinematic code could be restarted after a flush_step_generation() call without a sufficient delay. Rename last_sg_flush_time to min_restart_time and use that to ensure _calc_print_time() always pauses kin_flush_delay time since the last flush_step_generation() call. Also, update force_move to invoke flush_step_generation() after any movements. This is needed to ensure there is a sufficient delay should force_move be called on a stepper motor that is part of the toolhead kinematics and is using a step generation "scan time". This fixes possible "internal error in stepcompress" reports when using FORCE_MOVE. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Make sure to flush history when in debug output modeKevin O'Connor2023-12-301-9/+11
| | | | | | | | When in debugging "batch mode", use the existing method of keeping the last 30 seconds of history from the furthest planned move time. This avoids keeping all moves in memory during a batch test. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Avoid calling reactor.monotonic() on each _advance_flush_time()Kevin O'Connor2023-12-301-6/+7
| | | | | | | Move calculation of clear_history_time to the callers of _advance_flush_time() as a minor processing optimization. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Keep stepcompress move history relative to current time (#6439)Francois Chagnon2023-12-301-4/+7
| | | | | Expire history relative to current time rather than last move in history queue Signed-off-by: Francois Chagnon <fc@francoischagnon.net>
* toolhead: Simplify _advance_flush_time() sg_flush_time calculationKevin O'Connor2023-12-261-2/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Fix _calc_print_time() after G4 and SET_PRESSURE_ADVANCEKevin O'Connor2023-12-261-2/+4
| | | | | | | | | | | | Commit b7b13588 changed the internal flush time tracking, but introduced the possibility of motion restart occurring too close to the last motion end in some rare cases. This could result in internal stepcompress errors. Track the last step generation flush time (last_sg_flush_time) and use when recalculating the next print_time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Track separate time for flush_step_generation() and need_flush_timeKevin O'Connor2023-12-161-5/+9
| | | | | | | | Introduce a new step_gen_time variable for flush_step_generation(). This allows need_flush_time to be set to future times without interfering with flush_step_generation(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Support flushing even while lookahead queue is idleKevin O'Connor2023-12-071-26/+45
| | | | | | | | Track a "NeedPrime" queue state instead of the "Flushed" state, and continue running the background flushing timer as long as there may be data in any of the move queues. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Rework flushing to be based on mcu flush timeKevin O'Connor2023-12-071-35/+38
| | | | | | | | | | Rename last_kin_move_time to need_flush_time and rename force_flush_time to last_flush_time to improve variable name clarity. Move low-level flushing to new _advance_flush_time() so that it is possible to flush the queues without needing to advance print_time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Separate out priming flush notification to its own timerKevin O'Connor2023-12-071-4/+21
| | | | | | | | Simplify the code by introducing a separate lookahead priming flush timer. After this change, the flush_timer is not active in any of the special queuing states. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Clarify internal toolhead "stall" and "pause" namingKevin O'Connor2023-12-071-30/+32
| | | | | | | | Clarify the internal naming to make a more clear distinction between "stalling" (input not coming fast enough) and "pausing" (the need to hold up reading of input to avoid buffering too far into the future). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Remove undocumented buffer management config parametersKevin O'Connor2023-12-071-19/+14
| | | | | | | | These internal low-level config parameters were never documented. Going forward, developers may modify them by altering the internal settings in toolhead.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Revert "toolhead: Use dict for step generation flush times. (#6303)"Kevin O'Connor2023-10-211-9/+8
| | | | | | | | | | This reverts commit 6749985302fe002a9cb5672dab9badb11e4e3c36. A defect was found in the above commit (the input shaper code calls note_step_generateion_scan_time() for many steppers, so the input_shaper class can't be used as the index). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Use dict for step generation flush times. (#6303)Viesturs Zariņš2023-10-191-8/+9
| | | | | Makes the API to extruder and input shaper more robust, avoiding the need to track the old delay. Signed-off-by: Viesturs Zariņš <viesturz@gmail.com>
* toolhead: Flush in chunks from flush_step_generation()Kevin O'Connor2023-01-081-2/+8
| | | | | | | | | If note_kinematic_activity() has a time far in the future it could result in a single flush attempt of that time range. Be sure to break up that range into small chunks using the normal _update_move_time() mechanism. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Rename last_kin_flush_time to force_flush_timeKevin O'Connor2023-01-081-8/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Fix note_kinematic_activity()Kevin O'Connor2023-01-081-1/+1
| | | | | | | | It was possible a note_kinematic_activity() call could increase last_kin_move_time, but _process_moves() could reset it. Fix by making sure _process_moves() only ever increases last_kin_move_time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Capture current junction_deviation in a Move classDmitry Butyugin2022-10-171-3/+4
| | | | | | | If a maximum acceleration is changed between two consecutive moves, this allows to correctly compute the junction velocity between them. Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
* toolhead: Fix toolhead stop on SET_VELOCITY_LIMIT (#5053)Stephen Hurd2021-12-301-1/+0
| | | | | This fixes issue #5050 Signed-off-by: Stephen Hurd <deuce@synchro.net>
* toolhead: change SET_VELOCITY_LIMIT respond (fixed) (#4620)Stefan Dej2021-08-311-10/+19
| | | | | Returns only the current values if no new ones have been passed. Signed-off-by: Stefan Dej <meteyou@gmail.com>
* Revert "toolhead: change SET_VELOCITY_LIMIT respond behavior"Kevin O'Connor2021-08-241-19/+7
| | | | | | This reverts commit 9f75e348b06f494c0aa4181867b92013f72a9278. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: change SET_VELOCITY_LIMIT respond behaviorstefand2021-08-241-7/+19
| | | | | | Returns only the current values if no new ones have been passed. Signed-off-by: Stefan Dej <meteyou@gmail.com>
* trapq: Store toolhead.set_position() updates in trapq historyKevin O'Connor2021-07-291-1/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* trapq: Rename trapq_free_moves() to trapq_finalize_moves()Kevin O'Connor2021-07-291-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Do not limit SET_VELOCITY_LIMIT to values specified in configKevin O'Connor2021-04-301-8/+4
| | | | | | | Allow a larger velocity, accel, and square_corner_velocity than what is specified in the config file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Do not set min_stop_interval in micro-controllerKevin O'Connor2021-04-301-6/+0
| | | | | | | | The min_stop_interval safety check is fragile and leads to a notable amount of complexity. Avoid these issues by not programming this safety check. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Export the print_stalls value via get_status()Kevin O'Connor2021-04-091-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Make sure input_shaper movement starts after endstop checkingKevin O'Connor2021-03-291-0/+1
| | | | | | | | | | Add a dwell() to the start of drip_move() to ensure that input_shaper movements scheduled in advance of the nominal move time aren't scheduled prior to the homing start. (Otherwise the stepper may move prior to endstop checking, which can corrupt the "no movement" checks.) Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Make homing.py an "extras" moduleKevin O'Connor2021-01-081-2/+2
| | | | | | | Move klippy/homing.py to klippy/extras/homing.py and convert the code to an "extras" modules. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Move definition of CommandError and Coord from homing.py to gcode.pyKevin O'Connor2021-01-081-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kinematics: Calculate axis_minimum/axis_maximum in advanceKevin O'Connor2021-01-081-1/+2
| | | | | | | | Calculate the get_status() axis_minimum and axis_maximum fields in advance so that they don't need to be calculated on each get_status() call. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Fixed reporting of the kinematic limitsDmitry Butyugin2020-10-141-2/+3
| | | | Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
* homing: Prefer printer.command_error() instead of homing.CommandError()Kevin O'Connor2020-09-041-2/+2
| | | | | | | Update callers to use the printer.command_error reference instead of directly using homing.CommandError() when raising or catching errors. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Remove EndstopErrorKevin O'Connor2020-09-041-3/+3
| | | | | | | There's no reason to distinguish between an EndstopError and a CommandError, so just use CommandError. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Add a move.move_error() helperKevin O'Connor2020-09-031-0/+4
| | | | | | | Move the EndstopMoveError() code from homing.py to a new method in the toolhead Move class. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode_move: Move GCodeMove class from gcode.py to new extras moduleKevin O'Connor2020-08-201-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Move G4 and M400 commands from gcode.py to toolhead.pyKevin O'Connor2020-08-201-1/+10
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Remove unused get_stats() dataKevin O'Connor2020-08-201-10/+2
| | | | | | | The "status" and "printing_time" are now available in the "idle_timeout" module, so no need to report them from toolhead. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Add a manual_move() helper functionKevin O'Connor2020-08-201-0/+7
| | | | | | | | Add a helper function for submitting relative movements. This function will also automatically ensure gcode.reset_last_position() is called. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Automatically call reset_last_position() on a toolhead set_position()Kevin O'Connor2020-08-201-0/+1
| | | | | | | | Generate a "toolhead:set_position" event on a call to toolhead.set_position() and use that event to automatically call gcode.reset_last_position(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: report velocity and accel via get_statusArksine2020-08-011-1/+5
| | | | Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* toolhead: Handle flush_step_generation() call after dwell()Kevin O'Connor2020-06-011-0/+1
| | | | | | | | | If self.kin_flush_delay changes after a G4 dwell command (or other non-kinematic time update) then it could lead to "internal step compression" errors. Make sure to handle this case in flush_step_generation(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Rename try_load_module() to load_object()Kevin O'Connor2020-05-081-4/+3
| | | | | | | | Rename try_load_module() so that it uses consistent naming for "printer objects". Change the function to raise an error by default if the specified module does not exist. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Use new GCodeCommand wrappersKevin O'Connor2020-05-051-23/+19
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>