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>
Make sure to initialize mcu_enable to None so that it is initialized
if no 'enable_pin' config value is provided.
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>
On corexy, the stepper velocity of a diagonal move could be greater
than the maximum printer velocity. Account for that when setting the
maximum xy halt velocity in the mcu stepper config.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 4655a6bf allowed naks to be honored if receive_seq was greater
than the last retransmitted sequence. However, receive_seq is the
receiver's next sequence number, so a nak should only be processed if
it is one greater than that.
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>
Extend the look-ahead mechanism to work between moves that contain Z
movement. This improves Klipper's handling of g-code produced in
"vase mode".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Allow the kinematic classes to query the max velocity, max accel, and
max halt velocity from the toolhead class instead of having the
toolhead class call into the kinematic classes with those values.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit d0932009 changed the way command handling was performed, and
commit 95950949 fixed a defect in that commit. Unfortunately, the fix
was incomplete.
If multiple commands were sent to Klippy without waiting for an "ok"
response from Klippy, then it was possible for those additional
commands to be queued and processed after subsequent commands. This
would result in commands being processed out of order.
Fix this by only reregistering the input fd in the greenlet that
performs the unregistration of the fd.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Invert the if conditional in queue_append() and change the order of
reads in minmax_point() - gcc on the rpi seems to do generate better
code this way.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The RaspberryPi processor implements 'double to int32' conversions
much faster than 'double to int64' conversions. Rework the code so
that steps stored in the queue are always a small offset from the last
sent step time. (In the unlikely event that a step is far from the
last step time, then the queue is flushed to maintain this invariant.)
This simplifies the step compression code as well - it no longer needs
to check for integer overflows.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Create an insertion "cursor" for adding items to the step compression
queue. This makes the calling code simpler and it makes it easier to
update the queue memory management in the future.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The homing operation can be cpu intensive for the host software. Add
a small (250ms) delay before homing so that the host has additional
time to process the command before it is due on the mcu. This is
intended to work around some reports of "timer too close" errors
during Z homing on RPi2 hosts and printers with high precision Z
positioning.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Adjust the configured homing speed so that it always results in a
speed that is an even number of mcu ticks per step. This ensures that
the code can always get good step compression during homing, which is
important as the entire homing operation must be able to fit within
the mcu's move queue. This fixes some "move queue empty" mcu shutdown
errors that could occur when the Z step distance was an unusual size.
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>
Preface the internal functions to make it more clear which functions
are interfaces to external code.
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>
Support an "ad5206" config section so that one can configure the
digipots found on Reprap "RAMBo" boards.
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>