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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>