Commit Graph

258 Commits

Author SHA1 Message Date
Kevin O'Connor b3cfe55b39 clocksync: Remove no longer used get_adjusted_freq() function
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-06 16:35:02 -05:00
Kevin O'Connor 62fcc5a56f mcu: Calculate homing rest_ticks via standard print_time_to_clock() call
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-06 16:33:54 -05:00
Kevin O'Connor 245917bf03 mcu: Introduce new lookup_query_command() command wrapper
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>
2020-02-20 13:24:53 -05:00
Kevin O'Connor 332038ea01 serialhdl: Convert queries to use new notify message ack system
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>
2020-02-20 12:01:21 -05:00
Kevin O'Connor 804f95ebe4 homing: Don't raise a TimeoutError from home_wait()
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>
2020-02-19 12:20:00 -05:00
Kevin O'Connor fbbbbc85cf homing: Replace notify callback with a completion
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>
2020-02-19 11:45:44 -05:00
Kevin O'Connor feb15eaf2e homing: Merge home_prepare()/home_finalize() into move_begin/move_end events
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>
2020-02-15 17:52:44 -05:00
Kevin O'Connor e532b75e21 mcu: Minor simplification to default reset detection
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-12 22:15:04 -05:00
Kevin O'Connor 4ca190d393 stepper: Move MCU_stepper from mcu.py to stepper.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-12 17:32:18 -05:00
Kevin O'Connor 0bfb655f66 query_adc: Add a new module to help query and debug analog pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-07 19:28:27 -05:00
Kevin O'Connor 797dcfcb12 itersolve: Remove unused gen_steps()
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>
2019-11-06 15:51:51 -05:00
Kevin O'Connor bd3c8920f6 mcu: Remove set_ignore_move()
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>
2019-11-06 15:51:51 -05:00
Kevin O'Connor f3ef9c1889 itersolve: Add support for generating steps from a trapq
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>
2019-11-06 15:51:51 -05:00
Kevin O'Connor 5eb5841eaf mcu: Contact and identify all the mcus prior to configuring them
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>
2019-11-06 10:35:24 -05:00
Kevin O'Connor 1b454c0943 mcu: Prevent "math domain errors" in stats calculation
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 13:57:07 -04:00
Kevin O'Connor 395429be14 pins: Move reserved pin handling into PinResolver class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-19 12:57:59 -04:00
Kevin O'Connor 28aa2f507a endstop: Rename mcu end_stop commands to endstop
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>
2019-07-12 08:10:53 -04:00
Kevin O'Connor c3fe3d0d2c stepcompress: Remove no longer needed stepcompress_set_homing()
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>
2019-07-10 10:43:20 -04:00
Kevin O'Connor 43064d197d homing: Implement homing via new toolhead "drip" movement
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>
2019-07-10 10:43:20 -04:00
Kevin O'Connor 84be96aeff mcu: Rework home_wait() to use a reactor completion
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-10 10:43:20 -04:00
Kevin O'Connor 4f6982c4d0 serialhdl: Update SendWithRetry to use reactor completions
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-10 10:43:20 -04:00
Kevin O'Connor e148dbe52a mcu: Use regular send_with_response() for query_endstop()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-10 10:43:20 -04:00
Kevin O'Connor b2c778b931 mcu: Integrate query_endstop_wait() into query_endstop()
There is no need to have two separate calls to query an endstop.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-10 10:43:20 -04:00
Kevin O'Connor 80194a7e18 endstop_phase: Fix endstop_phase on trinamic drivers that aren't inverted
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-21 22:56:16 -04:00
Kevin O'Connor 9feb05ce41 mcu: Support minclock in send_with_response() requests
Enhance send_with_response() so that it supports queries with a
minclock.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-21 21:42:20 -04:00
Kevin O'Connor e202a8802b mcu: Move SerialCommand from serialhdl.py to mcu.py
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>
2019-06-21 21:42:20 -04:00
Kevin O'Connor d98bbc772c serialhdl: Eventually timeout connect attempt
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>
2019-06-21 21:42:20 -04:00
Kevin O'Connor 461ed4cb80 serialhdl: Add a get_msgparser() method
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-21 18:14:00 -04:00
Kevin O'Connor 647f1ee2e0 serialhdl: Rename register_callback() to register_response()
Rename the method and use that name in the mcu class as well.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-21 18:14:00 -04:00
Kevin O'Connor f96239019a mcu: Support a start value for soft pwm pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-02 10:59:33 -04:00
Kevin O'Connor 8532e2123e gpiocmds: Specify soft pwm duration in clock ticks
Improve the precision of soft pwm pulses by allowing the host to
directly specify the clock duration of the pulse.  This improvement in
precision may be noticeable when controller servos (and bltouch).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-05-26 11:09:32 -04:00
Kevin O'Connor 84bae6ff41 mcu: Fix reserve pin check
Fix typo causing conflict with mcu name and constant name.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-05-21 09:40:13 -04:00
Kevin O'Connor 1ab02e5225 bus: Support bus enumerations and add support for reserved pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-04-04 18:29:31 -04:00
Kevin O'Connor 746a378c18 endstop: Use "pin_value" instead of "pin" when querying endstop state
Now that enumerations are available, any variable named "pin" can only
be used to describe a gpio pin.  Rename the end_stop_state "pin"
parameter to "pin_value".  Also, rename "end_stop_query" command to
"end_stop_query_state" to notify users to upgrade both host and mcu
code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-19 10:48:33 -04:00
Kevin O'Connor db6e2d4c9e msgproto: Convert static strings to a more generic enumeration system
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-17 19:38:18 -04:00
Kevin O'Connor e36122797b bltouch: Attempt to verify that the probe raises after each probe attempt
Query the bltouch state during the pin_up command to try and verify
that the probe does actually retract.  This may be useful to detect if
the bltouch enters into an "error" state.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-01-21 09:52:11 -05:00
Kevin O'Connor 32632c8226 mcu: Fix timing of endstop checking
Make sure to not query the given endstop until after the start of the
requested operation.  This ensures that the operation has started
prior to querying the status of that operation.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-01-10 12:27:56 -05:00
Kevin O'Connor 857e7ed5f1 klippy: Convert printer_state("connect") to an event handler
Convert all users of the printer_state("connect") handler to register
a "klippy:connect" event handler instead.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-01-08 11:09:55 -05:00
Kevin O'Connor f4be0ac7be klippy: Convert printer_state("disconnect") to an event handler
Convert all users of the printer_state("disconnect") handler to
register a "klippy:disconnect" event handler instead.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-01-08 10:59:43 -05:00
Kevin O'Connor fb7fe282c8 klippy: Convert printer_state("shutdown") to an event handler
Convert all users of the printer_state("shutdown") handler to register
a "klippy:shutdown" event handler instead.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-01-08 10:59:43 -05:00
Kevin O'Connor c6065e29a6 mcu: Allow set_stepper_kinematics() to set the kinematics back to None
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-12-24 11:42:13 -05:00
Kevin O'Connor 770b92863f mcu: Add a set_commanded_position() method to MCU_stepper
Add the ability to directly set the "commanded" stepper position.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-10-10 14:30:09 -04:00
Kevin O'Connor ef6068dc42 mcu: Log MCU information before configuring
Log the details of the MCU prior to attempting to configure the MCU.
This way, the log contains the MCU information even if a configuration
error occurs.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-09-03 18:34:10 -04:00
Kevin O'Connor 30013a1fb8 mcu: Rename add_config_object() to register_config_callback()
Change the name of the config registration method and pass an explicit
reference to the callback to the new method.  This makes the
relationship between mcu registration and build_config() more clear in
the calling code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-09-03 11:48:22 -04:00
Kevin O'Connor ad480bd470 mcu: Avoid adding the same stepper multiple times to an endstop
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-08-26 23:06:32 -04:00
Kevin O'Connor 13ccb1a46f mcu: Minor whitespace changes
Wrap lines at 80 columns.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-26 10:54:31 -04:00
Kevin O'Connor 273a98d39a pins: Explicitly pass can_invert and can_pullup to lookup_pin()
Don't pass pin_type to lookup_pin() - instead, if a pin can be
inverted or can have a pullup, then the caller must explicitly specify
that when calling lookup_pin().  This simplifies the code for the
cases where it is not valid to invert or pullup.

Explicitly pass the pin_type to setup_pin() and have ppins.setup_pin()
apply default pullup and invert flags.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-26 09:44:45 -04:00
Kevin O'Connor cb29143939 itersolve: Support calculating a stepper position from a cartesian coordinate
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-18 11:51:28 -04:00
Kevin O'Connor a31c31aed4 mcu: Enhance itersolve stepper kinematics allocation
Allocate the stepper_kinematics directly in mcu.py - that way the
kinematic classes don't have to interact with the chelper code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-13 11:37:36 -04:00
Kevin O'Connor 7d897d84d7 klippy: No need to pass printer reference to add_printer_objects()
The config reference already stores a reference to the printer object.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-12 22:26:32 -04:00
Kevin O'Connor 5cdba1fda8 mcu: Send mcu config and init immediately after building it
Don't issue a get_config command after building the config as the
built config may contain time sensitive initialization commands.
Instead, send the config and init commands immediately after invoking
the build_config() callbacks.  This avoids some rare "timer too close"
errors during configuration.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-12 12:54:12 -04:00
Kevin O'Connor 211e34e62b mcu: Add leading underscore to handle_shutdown() and handle_mcu_stats()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-12 12:19:04 -04:00
Kevin O'Connor 0dbfa915de adccmds: Add support for min/max temperature check filtering
Extend the ADC out of range check so that it is possible to sample
multiple times before going into a shutdown state.  This reduces the
chance that measurement noise will cause an error.  In an actual over
temperature (or under temperature event) it is expected that the
sensor will consistently report the problem, so extra checks for an
additional second or two should not substantially increase risk.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-02 13:56:34 -04:00
Kevin O'Connor 890298d34d itersolve: Support setting the stepper position via a cartesian coordinate
Add support for an itersolve_set_position() function that sets a
stepper position from a cartesian coordinate.  This eliminates the
need for both the python and C code to be able to translate from a
cartesian coordinate to a stepper position.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-22 14:09:01 -04:00
Kevin O'Connor 926829e737 itersolve: Move tracking of commanded position to itersolve code
Track the commanded position in just the itersolve.c code instead of
in mcu.py.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor 8f747e2720 kin_cartesian: Remove stepcompress_push_const()
All the kinematic code now uses the iterative solver to generate
steps.  Remove the old stepcompress_push_const() mechanism.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor eb73b5d0b0 stepper_buzz: Convert to iterative solver
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor ca0d0135dc delta: Convert delta kinematics to use iterative solver
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor ba3428822d stepcompress: Allow stepcompress_alloc() to be called early
Don't require an mcu connection to allocate the stepcompress object.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
cruwaller 26378c2564 mcu: config_reset_cmd typo fixed
Signed-off-by: Petri Honkala <cruwaller@gmail.com>
2018-06-01 09:49:55 -04:00
Kevin O'Connor ff9543eee2 clocksync: Simplify is_active() check
In some rare circumstances it was possible for the host software to
become so busy that it does not transmit a get_clock request for
several seconds.  (In particular, this could occur with some complex
calls to coordinate_descent.)  If that happened, it was possible for
the code to incorrectly report a "Timeout with MCU" error.  Rework the
is_active() check to prevent that.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-05-31 18:20:30 -04:00
Kevin O'Connor 879c45db19 mcu: Do not automatically restart MCU with new config if it is shutdown
Normally, the MCU is restarted on a config change.  However, that
should not be done automatically if the MCU is in a shutdown state.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-05-29 10:57:29 -04:00
Kevin O'Connor ee4f37fe0c stepper: Add STEPPER_BUZZ command
Add a new command that can help diagnose stepper motor connectivity.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-05-24 09:49:17 -04:00
Kevin O'Connor 3025638b9b z_tilt: Add support for Z_TILT_ADJUST
Add new module to support independent adjustments to multiple Z
steppers to account for bed tilt.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-05-22 22:23:44 -04:00
Kevin O'Connor 4eeb43b191 pins: Remove module level get_printer_pins() and setup_pin() functions
Most callers did a lookup of the pins module via
printer.lookup_object("pins").  Use that as the standard method and
remove these less frequently used methods.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-04-04 12:26:39 -04:00
Kevin O'Connor bb8926d67a klippy: Automatically clear rollover_info on each restart
Automatically clear the information printed at the start of each log
file rollover on a klippy internal restart.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-04-03 13:18:52 -04:00
Kevin O'Connor b139a8561f serialhdl: Add a wrapper around the results of lookup_command()
Add a lookup_command() method to the SerialReader class that provides
a wrapper that stores the serial and commandqueue references.  This
makes it easier to run the send() method.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-02-27 21:06:16 -05:00
Dave Bacon 5abea041b4 mcu: Fix PWM static start value setup
config_setup uses ._start_value instead of ._static_value which isn't defined.

Signed-off-by: Dave Bacon <drb.github@mrbacon.com>
2018-02-10 13:00:22 -05:00
Kevin O'Connor 0a5b07f9da klippy: Allow any stats producer to determine when stats are needed
Instead of using the toolhead class to determine if stats should be
reported, allow every printer object with a stats() callback to
determine if stats are needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-02-05 13:52:05 -05:00
Kevin O'Connor 21df21b7af fan: Clarify hardware_pwm and allow cycle_time to be set on software pwm
Specify hardware pwm cycle times using the same method as software pwm
(in seconds, not clock ticks).  Allow the fan code to be configured
with an explicit cycle time even when using software pwm.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-29 13:08:15 -05:00
Kevin O'Connor 077a56c2ca mcu: Default the restart method to 'command' on non-serial ports
If the mcu supports command restarts and it does not appear to use a
real serial port, then default the restart method to 'command'.  This
is a better default on boards with native USB support.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-29 10:25:25 -05:00
Kevin O'Connor e38c7df064 probe: Support activate/deactivate scripts on each probe
Allow a set of g-code scripts to be run on each probe invocation.
This may be useful for probes that need to be setup before they are
useful (eg, with servo actuated probes).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-28 12:19:26 -05:00
Kevin O'Connor ce9db609ad probe: Initial support for Z-Probe hardware
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-28 12:19:26 -05:00
Kevin O'Connor d3665699f1 klippy: Support generic printer_state() and stats() callbacks
Instead of hardcoding which objects are called on state transitions,
allow any "printer object" to be invoked if it has a printer_state()
method.  Convert connect, ready, shutdown, and disconnect callbacks to
this mechanism.

Similarly, allow all printer objects to provide a stats() callback.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-28 12:19:26 -05:00
Kevin O'Connor 81013ba5c8 klippy: Add access methods and avoid peeking into the printer classes
Add get_reactor(), lookup_object(), lookup_module_objects(), and
set_rollover_info() to the main Printer class so that callers do not
need to peek into the class' members.  Similarly, add get_printer()
and get_name() methods to the ConfigWrapper class.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-28 12:19:26 -05:00
Kevin O'Connor 3833669c3a pins: Check if the same pin is referenced via different aliases
Change the update_command() call to use a new PinResolver class.  In
that new class, verify that the same pin isn't referenced in two
different parts of the config using different aliases for the pin.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-10 19:26:06 -05:00
Kevin O'Connor ed80b92b59 mcu: Setup static values via setup_start_value() call
Add an "is_static" setting to setup_start_value() and remove the
setup_static() method.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-08 21:21:30 -05:00
Kevin O'Connor ed9dee4602 mcu: Only report an MCU timeout once
Don't flood the log with timeout messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-08 10:55:37 -05:00
Kevin O'Connor d778ae1846 build: Add gcc and binutils version to mcu data dictionary
Store the gcc and binutils versions used in the compilation of the
firmware in the firmware data dictionary.  Forward that information to
the log so it is available during debugging.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-21 20:32:10 -05:00
Kevin O'Connor 68d03e4a3e mcu: Allow both shutdown and startup values to be set for output pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-18 20:45:00 -05:00
Kevin O'Connor e0c947e188 mcu: Store MCU_stepper commanded_pos as a float
It's valid to consider the stepper at a position that is not on a step
interval - only the "mcu position" needs to be an integer.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-07 18:14:50 -05:00
Kevin O'Connor 1d6af72de5 mcu: Remove unneeded MCU_digital_out.get_last_setting() method
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 19:13:54 -05:00
Kevin O'Connor 2a8dd5c51f mcu: Reset the stepper step clock on init - not after each motor on
Reset the last step clock during the init phase and after each home -
this simplifies the runtime code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 19:13:54 -05:00
Kevin O'Connor c78f66b8e8 mcu: Be sure all moves are completed before raising a home timeout
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 19:13:54 -05:00
Kevin O'Connor b340fdcc4a homing: Make sure to clean up homing state even if homing fails
Make sure to always call MCU_endstop.home_wait() if
MCU_endstop.home_start() is invoked.  Rename
MCU_stepper.note_homing_triggered() to note_homing_end() and make sure
it is always called if MCU_stepper.note_homing_start() is invoked.

With these changes, MCU_endstop.home_finalize() is no longer needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 19:13:53 -05:00
Kevin O'Connor 7785d3a87d homing: Pass list of endstops (not steppers) to the homing code
The homing code wants the list of endstops to enable during a homing
operation - it's confusing to pass the steppers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 18:49:14 -05:00
Kevin O'Connor 31db4cc772 mcu: Make sure steppers added to an endstop are on the same mcu
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 18:35:51 -05:00
Kevin O'Connor 7932de11a7 mcu: Make sure all endstop objects are disabled on a reconnect
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 18:35:51 -05:00
Kevin O'Connor 38643f52c9 stepper: Add get_endstops() / set_position wrappers
Add wrappers around mcu_endstop and mcu_stepper so that the kinematic
classes do not need to directly access these low-level classes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-11-18 17:36:45 -05:00
Kevin O'Connor 07a69df62f mcu: Fix command restart
Fix omission in commit f8750b14 that broke restarts via Klipper
command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-10-12 21:43:33 -04:00
Kevin O'Connor f8750b142f klippy: Rework shutdown handling
If an MCU signals a shutdown from the background thread, notify the
main thread and handle the shutdown there.  Dispatch shutdown handling
from the main Printer() class instead of from the Toolhead class.
This simplifies the shutdown logic.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-10-12 16:28:53 -04:00
Kevin O'Connor db97f36631 gpiocmds: Allow the start value for a pin to differ from the default_value
Allow the start value to be different from the default/shutdown value
for the pin.  This will be useful for "heater fans" that should
startup in the off state, and transition to full on in a shutdown
state.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-10-12 11:59:27 -04:00
Kevin O'Connor 3b9b4e4d6f endstop: Eliminate end_stop_set_oversample command
Pass the sample_ticks and sample_count parameters directly in the
end_stop_home command instead.  This simplifies the code.

Also, simplify calculation of next wakeup time in
end_stop_oversample_event().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-10-12 11:59:27 -04:00
Kevin O'Connor ece1f71c64 endstop: Support oversampling of the endstop
Some printers can show occasional noise on the endstop pin.  Support
sampling the endstop pin multiple times to attempt to filter out this
noise.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-10-01 19:15:55 -04:00
Kevin O'Connor f658819862 clocksync: Add support for dumping internal state for debugging
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-27 13:13:38 -04:00
Kevin O'Connor 8f8951b4c1 serialhdl: Make dump_debug() output atomic
Build a single (very large) logging message with the debug state.
This prevents the output from being fragmented.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-27 12:38:20 -04:00
Kevin O'Connor 387cab27bd mcu: Separate restart_microcontroller() into multiple functions
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-20 16:04:41 -04:00
Kevin O'Connor d851882278 linux: Initial support for running Klipper in a Linux real-time process
Add support for compiling the Klipper micro-controller code as a
real-time process capable of running on standard Linux systems.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-20 12:55:28 -04:00
Kevin O'Connor 3ccecc568d mcu: Initial support for multiple micro-controllers
Add initial support for controlling multiple independent
micro-controllers from a single Klippy host instance.  Add basic
support for synchronizing the clocks of the additional mcus to the
main mcu's clock.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-20 12:45:00 -04:00
Kevin O'Connor cee200e509 mcu: Move code around in MCU class to keep like code together
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-19 17:27:18 -04:00