aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper
Commit message (Collapse)AuthorAgeFilesLines
* trapq: Prune interrupted moves from history on trapq_set_position()Kevin O'Connor2021-08-061-1/+16
| | | | | | | | It is possible for a homing move to not fully complete. Fixup the trapq history to make processing of the history easier for callers. Similarly, do not add artificial "null" moves to the trapq history. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Pass clock to stepcompress_set_last_position()Kevin O'Connor2021-08-063-4/+5
| | | | | | | | | Using sc->last_step_clock for the last position marker does not work properly, because the stepper.py code calls stepcompress_reset() prior to calling stepcompress_set_last_position(). Fix by passing an explicit clock to stepcompress_set_last_position(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Support extracting stepcompress historyKevin O'Connor2021-07-293-4/+53
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Rename 'struct history_move' to 'struct history_steps'Kevin O'Connor2021-07-291-25/+25
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* trapq: Store toolhead.set_position() updates in trapq historyKevin O'Connor2021-07-293-0/+21
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* trapq: Keep history of recent trapq movesKevin O'Connor2021-07-293-4/+71
| | | | | | | Store trapq moves in a separate "history" list after each move is nominally expired. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* trapq: Rename trapq_free_moves() to trapq_finalize_moves()Kevin O'Connor2021-07-293-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kinematics: Add dual_carriage to hybrid-corexyz (#4296)Tircown2021-06-272-0/+40
| | | | | | | - Add dual_carriage abilities for hybrid-corexy and hybrid-corexz - Introduce the module idex_mode - Fix add_stepper to the correct rail in hybrid-corexy Signed-off-by: Fabrice GALLET <tircown@gmail.com>
* stepcompress: Add missing functions to stepcompress.hKevin O'Connor2021-06-111-0/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* trdispatch: Support fast responses to trsync_state messagesKevin O'Connor2021-06-092-4/+244
| | | | | | | Add C code that can process trsync_state messages and dispatch responses with low-latency. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Add serialqueue_send_one() helper functionKevin O'Connor2021-06-092-5/+14
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Add "fast reader" supportKevin O'Connor2021-06-092-11/+69
| | | | | | | Add ability to run C code directly from the low-level socket reading thread. This enables host based low-latency handlers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* msgblock: Add clock estimation helper functionsKevin O'Connor2021-06-095-18/+61
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* msgblock: Add msgblock_decode()Kevin O'Connor2021-06-092-0/+34
| | | | | | | Add function that can parse a simple VLQ encoded message to an array of integers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* msgblock: Move message manipulation code from serialqueue.c to new msgblock.cKevin O'Connor2021-06-095-181/+201
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pollreactor: Move C pollreactor code from serialqueue.c to its own fileKevin O'Connor2021-06-094-201/+226
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Improve numerical stability of step+dir+step filterKevin O'Connor2021-04-111-1/+1
| | | | | | | Apply the step+dir+step filter even if, for some reason, a negative time is found. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Add support for tracking history of queue_step commandsKevin O'Connor2021-03-132-27/+120
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Support sending messages over a CAN busKevin O'Connor2021-03-133-27/+76
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: correctly report EOF errorsLasse Dalegaard2021-03-011-1/+4
| | | | | | | | | If `klippy` loses connection to a device, the next `read()` from the device file descriptor will result in a zero-byte result, i.e. an `EOF`. Right now this gives a confusing error message, so this simply handles the special case of `EOF` and outputs a better log message. Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
* chelper: Move logging_callback() to global scopeKevin O'Connor2021-03-011-4/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* buildcommands: Extend number of available mcu messages from 96 to 128Kevin O'Connor2021-02-183-14/+15
| | | | | | | | | | | Some internal code treats the message ids as encoded "variable length quantities", while other internal code assumes the message id is always one byte long. Continue using this scheme, but convert the VLQ users to use the name "msgtag" while the 1-byte users use "msgid". Increase the number of available msgids from 96 to 127 - the higher values get encoded as negative "msgtags". Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Batch multiple message blocks in a single write()Kevin O'Connor2021-02-121-29/+38
| | | | | | | | Some communication protocols are more efficient if fewer write() calls are invoked. If multiple message blocks can be sent at the same time then batch them into a single write() call. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Improve timing of sleep durationsKevin O'Connor2021-02-121-4/+10
| | | | | | | | If any callback is invoked from the pollreactor then obtain a new eventtime before calculating a sleep duration. This improves the timing of events. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* chelper: Fix check for failed code buildKevin O'Connor2021-02-071-2/+11
| | | | | | | Commit 73b78af6 inadvertently removed the check for a successful gcc compilation. Add the check back in. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Improve checking of out-of-order messagesKevin O'Connor2021-02-011-15/+23
| | | | | | | Consider any message block that acks a message never sent as an out-of-order block and discard it. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* itersolve: Convert iterative solver to use "secant method"Kevin O'Connor2020-11-021-100/+79
| | | | | | | | | | The previous code calculates each step time via an "exponential search" followed by a "false position with Illinois algorithm" search. Replace with a "secant method" with "bounds check" search. This simplifies the code, improves the performance, and does a better job of finding steps near a direction change. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Fix registration of serial fd in debug modeKevin O'Connor2020-10-301-5/+6
| | | | | | | | When in debug output mode, make sure to register the fd correctly. Otherwise, the poll() call will use the 0 fd which could cause random results. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kin_extruder: Fix numerical stability when using pressure advanceKevin O'Connor2020-10-231-7/+11
| | | | | | | | | Avoid using the absolute E position when calculating pressure advance as that position can grow arbitrarily large, which can result in "numerical stability" problems. That instability could eventually lead to internal errors during step compression. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* chelper: Add missing serialqueue_set_receive_window() def to serialqueue.hKevin O'Connor2020-09-261-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* chelper: Use standard C type definition for pyhelper_logging_callbackKevin O'Connor2020-09-261-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* chelper: Rework check for building C codeKevin O'Connor2020-09-261-22/+26
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* chelper: Set compiler flags to never use "x387" floating point mathKevin O'Connor2020-09-151-7/+18
| | | | | | | | | The default on X86 32bit machines is to use 80bit floating point math (as found in the ancient "387 coprocessor"). This can cause numerical stability problems. Set the compiler flags to make sure the newer SSE math is always used on X86. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kin_shaper: Fix check for optimized X or Y only calculationsKevin O'Connor2020-08-301-5/+4
| | | | | | | The optimized version is only available if it's the only axis used. This fixes input_shaper on corexz. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kin_shaper: Add an init_shaper() helper functionKevin O'Connor2020-08-301-26/+22
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kin_shaper: Group shaper setup code togetherKevin O'Connor2020-08-301-90/+93
| | | | | | No code changes - just code movement. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kin_shaper: Allocate space for maximum number of shaper pulses in advanceKevin O'Connor2020-08-301-110/+99
| | | | | | | | Combine the shaper pulses and count of those pulses into a `struct shaper_pulses`. Allocate space for the maximum number of pulses in `struct input_shaper`. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* itersolve: Use stricter completion check in itersolve_find_step()Kevin O'Connor2020-08-081-2/+4
| | | | | | | | Use a more strict check for determining if the iterative solver has correctly found a step - the guess must be within 1 picometer of the target or correct to within 1 nanosecond. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* itersolve: Enhance "false position" method with "illinois algorithm"Kevin O'Connor2020-08-081-1/+8
| | | | | | | This prevents some cases where the iterative solver fails to converge in a reasonable time, causing "no next step" errors. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* corexz: Add CoreXZ kinematics (#3129)Voron2020-07-302-7/+51
| | | | | Add a CoreXZ kinematics Signed-off-by: Maks Zolin <mzolin@vorondesign.com>
* input_shaper: Fixed C module compilation on older gnu90 compilersDmitry Butyugin2020-07-071-1/+2
| | | | | | | For example, Raspbian GNU/Linux 8 (jessie) uses an old GCC version 4.9.2 which uses -std=gnu90 by default. Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
* input_shaper: Initial support of input shaping (#3032)Dmitry Butyugin2020-07-052-2/+445
| | | | | | Input shaping can help to reduce printer vibrations due to resonances and eliminate or reduce ghosting in prints. Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
* itersolve: Use more explicit list traversal in itersolve_generate_steps()Kevin O'Connor2020-05-041-28/+44
| | | | | | | | Avoid using doubles as flags when generating steps during "lead up to stepper activity". Instead, explicitly track how many inactive move entries are skipped and only generate steps for those entries. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* itersolve: Fix numeric stability of flush range timesKevin O'Connor2020-05-041-2/+6
| | | | | | | | | Don't assume the times passed to itersolve_gen_steps_range() are contained within the move. It's possible the checks in itersolve_generate_steps() may round to different values when converting the times to a relative move time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Implement a step+dir+step filterKevin O'Connor2020-03-133-28/+101
| | | | | | | | | | Some stepper motor drivers do not respond well to rapid "step + direction change + step" events. In particular, it is believed this can cause "over current" events on the tmc2208 drivers when they are in "stealthchop" mode. Detect these events and remove them from the generated step times. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Move code around in stepcompress.cKevin O'Connor2020-03-132-51/+51
| | | | | | Just code movement - no code changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Revert "itersolve: Implement a step+dir+step filter"Kevin O'Connor2020-03-052-81/+5
| | | | | | | | This reverts commit c9cb462f90a68deb73cacb179f7bbcde2cb9aeed. The step flushing for this commit was not complete. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* itersolve: Implement a step+dir+step filterKevin O'Connor2020-03-042-5/+81
| | | | | | | | | | Some stepper motor drivers do not respond well to rapid "step + direction change + step" events. In particular, it is believed this can cause "over current" events on the tmc2208 drivers when they are in "stealthchop" mode. Detect these events and remove them from the generated step times. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* itersolve: Reset bounds search on a direction changeKevin O'Connor2020-03-041-2/+10
| | | | | | | | If the stepper changes direction then the average velocity since the last step pulse isn't a good indicator of the next step pulse. Instead, reset the bounds checking to use a low starting guess. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* itersolve: Simplify main itersolve_gen_steps_range() loopKevin O'Connor2020-03-041-46/+42
| | | | | | Reorder the loop to try and make the code flow a little simpler. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>