aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
Commit message (Collapse)AuthorAgeFilesLines
...
* gpiocmds: Merge digital output and soft pwm codeKevin O'Connor2020-12-101-6/+6
| | | | | | | | The digital output commands implement a subset of the software pwm commands. Change the host code to just use the software pwm commands and simplify the micro-controller code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Use move queue for software pwmKevin O'Connor2020-12-041-2/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Use move queue for digital output pinsPascal Pieper2020-12-041-4/+5
| | | | | Signed-off-by: Pascal Pieper <accounts@pascalpieper.de> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pwmcmds: Use move queue for hard PWMPascal Pieper2020-12-041-2/+3
| | | | | Signed-off-by: Pascal Pieper <accounts@pascalpieper.de> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Support reserving move queue slotsPascal Pieper2020-12-041-1/+6
| | | | | Signed-off-by: Pascal Pieper <accounts@pascalpieper.de> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Send soft pwm cycle_time separately from schedule_soft_pwm_outKevin O'Connor2020-12-041-10/+17
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Add support for setting reqclock in CommandQueryWrapper.send()Kevin O'Connor2020-10-291-4/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Don't default serial config option to /dev/ttyS0Kevin O'Connor2020-10-281-10/+10
| | | | | | | | If the mcu config section is omitted, it leads to confusing error messages. Don't default the serial config option to /dev/ttyS0 to improve the error reporting. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Increase the time to reset a pwm pin during startupKevin O'Connor2020-10-111-6/+3
| | | | | | | | Some RPi0 users were reporting "timer too close" errors due to pwm pin resets - increase the time the host has to complete the startup to avoid this. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Fix set_pwm() for hard pwmKevin O'Connor2020-09-271-11/+13
| | | | | | Must use self._pwm_max to calculate range for hard pwm updates. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Add support for changing cycle_time in set_pwm()Kevin O'Connor2020-09-261-3/+5
| | | | | Signed-off-by: Guy Shapira <gayuha@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Add soft-pwm frequency modulation supportGuy Shapira2020-09-261-9/+16
| | | | | Signed-off-by: Guy Shapira <gayuha@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Setup for steppersync_free to be automatically calledKevin O'Connor2020-09-161-14/+14
| | | | | | Use ffi_main.gc() to automatically free the C steppersync object. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Don't define a __del__() methodKevin O'Connor2020-09-161-2/+0
| | | | | | | | The existence of a __del__() method prevents deallocation on python2 if there are circular references. Just remove the method as disconnect() should already be called directly. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Use schedule_pwm_out instead of set_pwm_out on a restartKevin O'Connor2020-09-091-4/+7
| | | | | | | | Some mcu implementations don't like it when the pwm pin is configured twice, so use the normal schedule_pwm_out implementation to update on a restart. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Reset pwm and digital output pins to start values on a host restartKevin O'Connor2020-07-251-35/+43
| | | | | | | This makes sure output pins are reset to their defaults when the host is restarted and the micro-controller is not. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Add support for commands to send only on a host restartKevin O'Connor2020-07-251-7/+12
| | | | | | | | Add a new "on_restart" parameter to mcu.add_config_cmd() and only send those commands on a host restart that does not involve a micro-controller restart. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Remove undocumented "custom" config parameterKevin O'Connor2020-07-191-13/+2
| | | | | | | The "custom" config parameter is not documented and has not been recommended in years. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Avoid using "async" for variables as it conflicts with Python3Kevin O'Connor2020-06-151-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serial: Add Fysetc Cheetah board specific reset sequenceGrigori Goronzy2020-04-021-2/+14
| | | | | | | | | | | | | | | | | | Fysetc Cheetah v1.2 boards require a special sequence to reset reliably. This sequence works for me in all cases. Simpler sequences without double reset did not work correctly. This is likely because of a weird stateful circuitry for toggling the bootloader state. Cheetah boards use RTS to configure bootloader triggering. By default, pySerial sets RTS on connect, which unfortunately configures the board to start the bootloader on reset. Add a toggle for the RTS state to allow users to workaround. The RTS state is set before the serial connection is opened, so there are no glitches. Addresses #2026. Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
* mcu: Shutdown if a spontaneous restart of an mcu is observedKevin O'Connor2020-03-221-3/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Remove no longer used get_adjusted_freq() functionKevin O'Connor2020-03-061-2/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Calculate homing rest_ticks via standard print_time_to_clock() callKevin O'Connor2020-03-061-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Introduce new lookup_query_command() command wrapperKevin O'Connor2020-02-201-37/+51
| | | | | | | Use new mcu.lookup_query_command() for all commands that query information from the micro-controller. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Convert queries to use new notify message ack systemKevin O'Connor2020-02-201-5/+38
| | | | | | | | | | | Convert standard queries to use the acknowledgments of the sent command to determine if the response was received or not. This also controls command retransmissions (should the response have been lost). The tmc_uart.py will continue to use the old mechanism as the tmcuart responses are not sent synchronously with the query command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Don't raise a TimeoutError from home_wait()Kevin O'Connor2020-02-191-4/+1
| | | | | | | Change home_wait() to return if the homing operation completed succesfully or not. This simplifies the callers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Replace notify callback with a completionKevin O'Connor2020-02-191-9/+7
| | | | | | | | | Update the endstop code to return its trigger completion object during home_start(). Update the toolhead class to take a completion object (instead of creating its own). This reduces the number of intermediate callbacks needed during a homing operation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Merge home_prepare()/home_finalize() into move_begin/move_end eventsKevin O'Connor2020-02-151-4/+0
| | | | | | | | Collapse the "homing:move_begin", "homing:move_end", home_prepare(), and home_finalize() into two new events: "homing:homing_move_begin" and "homing:homing_move_end". This simplifies the homing code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Minor simplification to default reset detectionKevin O'Connor2019-11-121-5/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Move MCU_stepper from mcu.py to stepper.pyKevin O'Connor2019-11-121-133/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* query_adc: Add a new module to help query and debug analog pinsKevin O'Connor2019-11-071-0/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* itersolve: Remove unused gen_steps()Kevin O'Connor2019-11-061-5/+0
| | | | | | | Eliminate the old gen_steps() call now that all callers have been converted to the newer trapq based generate_steps(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Remove set_ignore_move()Kevin O'Connor2019-11-061-15/+4
| | | | | | | Update callers of set_ignore_move() to use the trapq system to set a stepper to ignore moves. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* itersolve: Add support for generating steps from a trapqKevin O'Connor2019-11-061-3/+35
| | | | | | | Support associating a stepper_kinematics with a trapq. Support generating steps from a time range on the given trapq. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Contact and identify all the mcus prior to configuring themKevin O'Connor2019-11-061-20/+23
| | | | | | | | | | | Break up the connect phase into two phases - mcu_identify and connect. The first phase will contact all the micro-controllers and obtain the "identify" data dictionaries for them. Once all the micro-controllers have been contacted, then they can be configured. This fixes an issue with FIRMWARE_RESTART not working correctly on multi-mcu setups that use restart_method=command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Prevent "math domain errors" in stats calculationKevin O'Connor2019-08-301-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pins: Move reserved pin handling into PinResolver classKevin O'Connor2019-08-191-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop: Rename mcu end_stop commands to endstopKevin O'Connor2019-07-121-11/+11
| | | | | | | | | Rename the commands. The main reason for this change is to force a micro-controller code updated (due to important bugfix in 7fefe52d). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Remove no longer needed stepcompress_set_homing()Kevin O'Connor2019-07-101-10/+0
| | | | | | | Now that homing is implemented via "drip moves", it is no longer necessary for the stepcompress code to have special homing logic. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Implement homing via new toolhead "drip" movementKevin O'Connor2019-07-101-27/+31
| | | | | | | | | | | Rework the low-level implementation of homing movement. The existing mechanism buffers all homing movement into the micro-controller prior to starting the home. Replace with a system that buffers all movement into the host look-ahead buffer and then "drip feed" those moves to the micro-controllers. Then clear the host look-ahead buffer when all endstops trigger. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Rework home_wait() to use a reactor completionKevin O'Connor2019-07-101-34/+37
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Update SendWithRetry to use reactor completionsKevin O'Connor2019-07-101-4/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Use regular send_with_response() for query_endstop()Kevin O'Connor2019-07-101-16/+13
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Integrate query_endstop_wait() into query_endstop()Kevin O'Connor2019-07-101-3/+1
| | | | | | There is no need to have two separate calls to query an endstop. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop_phase: Fix endstop_phase on trinamic drivers that aren't invertedKevin O'Connor2019-06-211-0/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Support minclock in send_with_response() requestsKevin O'Connor2019-06-211-5/+11
| | | | | | | Enhance send_with_response() so that it supports queries with a minclock. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Move SerialCommand from serialhdl.py to mcu.pyKevin O'Connor2019-06-211-1/+23
| | | | | | | | Move the serial command wrapper class from serialhdl.py to mcu.py. This will allow that class to better support higher level functionality. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Eventually timeout connect attemptKevin O'Connor2019-06-211-2/+5
| | | | | | | If the serial connection has not been successful after 2.5 minutes then report an error. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Add a get_msgparser() methodKevin O'Connor2019-06-211-7/+7
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Rename register_callback() to register_response()Kevin O'Connor2019-06-211-9/+9
| | | | | | Rename the method and use that name in the mcu class as well. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>