aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper.py
Commit message (Collapse)AuthorAgeFilesLines
* klippy: Avoid using '%' syntax when calling logging moduleKevin O'Connor2017-09-271-1/+1
| | | | | | | The logging module can build strings directly from printf syntax - no need to build the string first. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Implement print time to clock conversion in C codeKevin O'Connor2017-09-191-0/+2
| | | | | | | Implement the conversion from print_time to the local mcu's clock within the C code. This simplifies the python code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Return number of steps traveled from stepcompress_push()Kevin O'Connor2017-09-131-1/+1
| | | | | | | Return the same information from stepcompress_push() that is returned from stepcompress_push_const() and stpcompress_push_delta(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Rename clock estimation variable namesKevin O'Connor2017-06-301-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* hub-ctrl: Add support for micro-controller reset via RPi usb power togglingKevin O'Connor2017-04-131-9/+32
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Modify check_expand() into check_push()Kevin O'Connor2017-04-071-1/+1
| | | | | | | | | | Add the new item at the same time as checking if there is space in the queue. Also, update the default optimization level of c_helper.so to O2 to improve the compiled code layout. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* delta: Make it clear that a "virtual tower" is createdKevin O'Connor2017-04-071-3/+2
| | | | | | | | | | | The delta code calculates a "virtual tower" along the line of movement. Rework the variable names and comments to make it clear that this is occurring. It is not necessary to pass the start_pos variable to the C code as it is simple to update the start_pos at the start of each movement. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Merge stepcompress_delta_const and stepcompress_delta_accelKevin O'Connor2017-04-071-5/+1
| | | | | | | | It's not necessary to have separate C delta kinematic functions for constant acceleration and constant velocity as constant velocity can be obtained by using a constant acceleration of zero. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Pass delta velocity and acceleration directly to C codeKevin O'Connor2017-04-071-6/+6
| | | | | | | | Update the C delta kinematic code to take velocity and acceleration directly in step distances and clock ticks. This simplifies the mcu.py python code as it only needs to do unit and axis conversion. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Merge stepcompress_push_accel() and stepcompress_push_const()Kevin O'Connor2017-04-071-2/+0
| | | | | | | | It's not necessary to have separate C functions for constant acceleration and constant velocity as constant velocity can be obtained by using a constant acceleration of zero. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Pass constant velocity and acceleration directly to C codeKevin O'Connor2017-04-071-6/+4
| | | | | | | | Update the C code to take velocity and acceleration directly in step distances and clock ticks. This simplifies the mcu.py python code as it only needs to do unit and axis conversion. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Move stepcompress_push_* functions to their own sectionKevin O'Connor2017-04-071-3/+4
| | | | | | This is only code movement; no code changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* reactor: Use the system monotonic clock instead of the normal system clockKevin O'Connor2017-02-061-0/+1
| | | | | | | | | | | | | The normal system clock can have sudden jumps if the system clock is changed. Use the system monotonic clock to avoid these sudden changes in time. It appears the Raspbian OS (which is used by OctoPi) is setup to update the system clock upon network connectivity. This could cause sudden system clock changes which could lead to Klippy processing errors. Using the monotonic clock eliminates these issues. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Propagate errors back to python codeKevin O'Connor2017-02-061-7/+5
| | | | | | | Propagate error codes back to the python code and raise an exception on an error. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Remove serialqueue_flush_ready()Kevin O'Connor2016-12-301-1/+0
| | | | | | | | | The serialqueue_flush_ready() code was used to flush queue_step commands during a homing operation. It's no longer necessary now that moves during a homing operation use the normal message priority system. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Using normal message priority system during homingKevin O'Connor2016-12-301-0/+1
| | | | | | | | | | | | | | The endstop homing system requires all queue_step commands be in the MCU's 'move queue' before endstop checking starts. Use the normal message priority system to request that stepper queue_step commands are received prior to the start of the end_stop_home command. This simplifies the code and removes the need for special serial queue flushing. This also fixes a bug in homing operations that take longer than 2^31 clock ticks. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* delta: Rework delta math to avoid using inv_movexy_rKevin O'Connor2016-12-051-8/+8
| | | | | | | | | | | | | | | Taking the inverse of the XY move distance can lead to extremely large values when the XY distance is very small. This can lead to saturation of the double precision variables and incorrect results. Rework the delta kinematic math to avoid using this inverse. Pass the closestxy_d value directly to the C functions so that the C code can calculate its intermediate constants. After this change the move_z special case is no longer necessary as the regular delta functions now work with movexy_r=0 and movez_r=1. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pyhelper: Add ability to route error messages to python loggingKevin O'Connor2016-11-301-1/+13
| | | | | | | Instead of writing error messages to stderr, route them into the python code and use the standard python logging system. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pyhelper: Move helper functions from serialqueue.c to new fileKevin O'Connor2016-11-301-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Be careful to free memory allocated in C codeKevin O'Connor2016-11-301-0/+3
| | | | | | Free steppersync, stepcompress, and commandqueue objects. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Fully deallocate serialqueue on disconnectKevin O'Connor2016-11-291-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* delta: Initial support for linear delta kinematicsKevin O'Connor2016-11-141-0/+8
| | | | | | This adds support for delta based robots. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Do all step rounding in C codeKevin O'Connor2016-11-131-4/+6
| | | | | | | | | | | | | | | | | Commits f0cefebf and 8f331f08 changed the way the code determined what steps to take on fractional steps. Unfortunately, it was possible in some situations for the C code to round differently from the python code which could result in warnings and lost steps. Change the code so that all fractional step handling is done in the C code. Implementing the step rounding logic in one location avoids any conflicts. In order to efficiently handle the step rounding in the C code, the C code has also been extended to directly send the "set_next_step_dir" command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Calculate baudadjust from MCU's baud instead of host baudKevin O'Connor2016-07-161-2/+2
| | | | | | | Store the baud rate the MCU is configured for in the "identify" data and use that rate when calculating the baudadjust parameter. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Initial commit of source code.Kevin O'Connor2016-05-251-0/+95
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>