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>
Don't directly access any of the mcu class variables externally from
the class. Add wrapper functions for those external callers that need
access to some internal state.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
Everywhere the data in get_last_clock() is used can be done just as
easily with estimated_print_time().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Now that the print_time is always synchronized with the mcu_time,
there is no longer a need to track mcu_time as a separate quantity.
Eliminate references to mcu_time from the code and pass print_time
directly in its place.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Instead of starting the print_time at zero, start it at the estimated
time of the main mcu's clock. This simplifies the code and it ensures
that print_time never goes backwards.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
Make sure schedule_digital_out and schedule_pwm_out commands always go
out with a value that is in range for the particular command.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make sure the ADC range sent to the MCU can be encoded into a 16bit
integer. Otherwise, if the provided min_temp/max_temp was outside the
range of possible values it could result in a spurious mcu shutdown.
In particular, the AD595 could not properly encode a min_temp of zero.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Allow external code to obtain the mcu object that controls a pin setup
with setup_pin(). Also, don't bother defining print_to_mcu_time() and
system_to_mcu_time() on each pin object as they can be obtained via
the new get_mcu() method.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 9d75c3b0 changed the order of allocation for mcu oid integer
ids. However, the stepper oids must always be allocated before
endstop oids so that corexy can register multiple steppers on a single
endstop.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's no longer necessary to use the TICKS() hack as the config
commands are now all generated after the mcu speed is known.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Allow digital and PWM output pins to be setup via new config
sections. This makes it easier to setup pin configurations.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The MCU() class needs to track the stepqueues so that it can
initialize the steppersync object. Track the stepqueues directly
instead of via the list of steppers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Track the oid count separately from the configurable object count -
this way it is possible to have internal objects that don't require an
oid in the mcu.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's not necessary to register and execute "init callbacks" when
configuring the mcu. Instead, have each mcu object produce its init
messages in the build_config() callback.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Allow multiple chips to provide pin mappings (not just the main mcu
chip). Move the pin parsing from the mcu.py code to pins.py and
support mapping from pin descriptions to their corresponding chips and
parameters.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Store pertinent information from the software startup in a dictionary
that the various printer components can access instead of in
individual variables in the Printer() class. This makes it easier to
add future command-line options.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Instead of assuming the maximum PWM value is 255, export a constant
from the firmware to the host with the maximum value.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
When the log file does a rollover, start the top of the log with
critical system information (eg, software versions).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Always log the last synchronized clock during a shutdown event, and
use debug level for normal reports.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Advice users to issue a FIRMWARE_RESTART command on a printer shutdown
event, and remove support for CLEAR_SHUTDOWN. A full mcu reset is
preferable and it simplifies the interface.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Extend the FIRMWARE_RESTART command so that it can use the firmware
"reset" command instead of the "arduino" mechanism.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>