- remove lot of helper methods
- differentiate class instantiate from config or directly
- don't use 'enable' template rendering when static value is used.
- new element 'disabled'
- other internal adjustments
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
Don't use the reactor eventtime to schedule micro-controller commands
as that time may have low accuracy.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't use the reactor eventtime to schedule micro-controller commands
as that time may have low accuracy.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Writes to the max31856 chip use "burst mode", so only one address
during the initialization sequence can be sent. This fixes erroneous
"Cold Junction Fault" errors.
Reported by @NBouquain.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add an 'mcu' option to the board_pins config and use that to specify
the name of the mcu to apply the aliases to. Support applying the
aliases to multiple mcus.
Add support for any number of options starting with an "aliases_"
prefix.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move all the config reference information from files in the config/
directory to a new Config_Reference.md document.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Queue updates so that delays between updates are properly applied.
This fixes macros that would blink LEDs by pausing between update
commands.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Users may use this action to call methods registered by a webhooks client from a command template.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The previous code calculates each step time via an "exponential
search" followed by a "false position with Illinois algorithm" search.
Replace with a "secant method" with "bounds check" search. This
simplifies the code, improves the performance, and does a better job
of finding steps near a direction change.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
When in debug output mode, make sure to register the fd correctly.
Otherwise, the poll() call will use the 0 fd which could cause random
results.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
It is only valid to call raise_probe() when the toolhead is not
moving. Make sure to call sync_print_time() from multi_probe_end() to
ensure that. This fixes a bug that could cause the Z axis steppers to
lose their position when "stow_on_each_sample=False".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Avoid using the absolute E position when calculating pressure advance
as that position can grow arbitrarily large, which can result in
"numerical stability" problems. That instability could eventually
lead to internal errors during step compression.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
On a reset, the mcu.py code may have sent an initialization message to
the bltouch, which needs time to complete. Add additional time during
the bltouch setup to avoid a race with these two times. This avoids
some "timer too close" errors that users of fast host machines were
reporting.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The M117 command parser discards the last character of the message
whenever the M117 command does not begin the line and there is no *xx
checksum, e.g.
N0 M117 Look at me
causes the banner area of the printer screen to display "Look at m".
This patch only trims the checksum when one is found to trim.
Signed-Off-By: Jonathan Pickard <jhp@adjustablelabs.info>
Add support for performing Python gc work only from the main reactor
thread and only when it appears the main thread is idle.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Explicitly run the python garbage collector on a restart. This cleans
up memory from the previous session.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make sure to terminate any greenlets that are in a pause() state.
This is necessary to ensure the reactor can be deallocated.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The existence of a __del__() method prevents deallocation on python2
if there are circular references. Replace the __del__() method with a
new finalize() call and arrange for it to be called when the main
reactor is released.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
The default on X86 32bit machines is to use 80bit floating point math
(as found in the ancient "387 coprocessor"). This can cause numerical
stability problems. Set the compiler flags to make sure the newer SSE
math is always used on X86.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add get_status wrapper with last_query status for macros It is sometimes useful to determine the state of the probe from a macro. If the probe is connected to an endstop pin, the results can be obtained via QUERY_ENDSTOPS but if a physical endstop is in use in addition to the probe the probe state cannot be obtained. This change allows one to use QUERY_PROBE and then access the printer.probe.last_query object to obtain the state.
Signed-off-by: Paul McGowan <mental405@gmail.com>
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>
Try to invoke a shutdown on an unhandled exception from reactor.run().
If that fails, try to do a clean exit.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Update callers to use the printer.command_error reference instead of
directly using homing.CommandError() when raising or catching errors.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
There's no reason to distinguish between an EndstopError and a
CommandError, so just use CommandError.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The optimized version is only available if it's the only axis used.
This fixes input_shaper on corexz.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Combine the shaper pulses and count of those pulses into a `struct
shaper_pulses`. Allocate space for the maximum number of pulses in
`struct input_shaper`.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Increase the maximum redraw rate from 4 times per second to 10 times
per second. Some users have reported slower rendering times as a
result of 8fa1c977.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Split up the main GCodeParser class into GCodeDispatch and GCodeMove
classes. The GCodeMove class is now available using the "gcode_move"
printer object name. This split simplifies the gcode.py code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The "status" and "printing_time" are now available in the
"idle_timeout" module, so no need to report them from toolhead.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rename printer.gcode.action_emergency_stop() to
action_emergency_stop(), printer.gcode.action_respond_info() to
action_respond_info(), and printer.gcode.action_respond_error() to
action_raise_error() in command templates.
This simplifies the get_status() interface, as returning callable
functions from that interface was confusing.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a helper function for submitting relative movements. This
function will also automatically ensure gcode.reset_last_position() is
called.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Generate a "toolhead:set_position" event on a call to
toolhead.set_position() and use that event to automatically call
gcode.reset_last_position().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a request_redraw() method and call it when a key menu event
occurs. Limit these proactive screen redraws to no more than 4 per
second.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
After reading the first item of self.filament_array, filament_width is updated back to self.nominal_filament_dia or self.diameter instead of retaining the value until next pending_position.
Updated Filament Menu Template.
Signed-off-by: Nicola Falciani <nicola.fal@gmail.com>
- don't populate all items at once
- populate items when container is pushed to stack
- precreate List back item, don't create it during populate.
- don't update items during populate
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
Clients can now subscribe to the webhooks get_status() info to
determine if the printer state changes. It is no longer needed to
send a message to all clients on a shutdown transition.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Implement a new subscription system for get_status() updates.
Subscriptions are per-client. After an initial update, only changes
will be transmitted. Responses are only transmitted to the client
that issued the subscription.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a new "gcode/subscribe_output" webhook endpoint to subscribe to
gcode output. Only client connections that subscribe to the gcode
output will receive that output.
This also moves all the gcode webhooks from gcode.py to webhooks.py
and arranges for gcode.py to be initialized prior to webhooks.py.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use the "info" webhook to pass critical process information back to
the caller. The remaining users of register_static_path() can get the
required information via get_status() calls.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't default to "/tmp/klippy_uds" for the webhooks unix domain socket
filename. Instead, require the filename to be specified on the
command-line (via a new "-a" parameter).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
In case of an overwriting existing menu item,
the new item was added additionally to the end of the items list.
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
This prevents ClientConnection.send() from blocking, removing the possibility that callers become reentrant.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
menu.cfg:
- jinja2 template scripting
- new Setup menu
- new Calibration menu
menu:
- redesigned menu code
- jinja2 support
- option to reverse menu up and down directions
- functionality set to support menu injection from other modules
- a new way of defining menu hierarchy
- other adjustments
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
Use a more strict check for determining if the iterative solver has
correctly found a step - the guess must be within 1 picometer of the
target or correct to within 1 nanosecond.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This prevents some cases where the iterative solver fails to converge
in a reasonable time, causing "no next step" errors.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Arc travel was working but extrusion in absolute mode seemed not to be happening at all. This was because the E coord being sent with each G1 segment of the arc was not incrementing, effectively the same value was being sent over and over so the total extrusion for the whole arc was the amount for just one segment which is an extremely tiny amount.
My change increments e_base by e_per_move for each subsequent coord when in absolute extrude mode which results in the correct absolute E value being sent for each segment.
Signed-off-by: Toby Harper <toby@fuith.org>
This class provides endpoints that allow connected hosts to fetch the state of printer objects and subscribe to state "pushed" over the connection.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Move the pseudo-tty IO handling from the main gcode class to a new
gcode_io class. This simplifies the main gcode class.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If there isn't a reader of the output pipe it can lead to the
generation of a large number of errors. Only attempt to write if it
appears the pipe is active.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
SDCARD_PRINT_FILE allows Klipper to load and start the print for any
gcode file within the virtual_sdcard path, including subdirectories.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
In it's current behavior, safe_z_home will attempt to home Z if it thinks the toolhead is above the z endstop even if the motors have since been disabled and the toolhead was moved to another position
Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
This streamlines the BedMeshCalibrate class, making it only resposible for configuring and executing the calibration procedure.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Using the setup_start_value() method avoids the PWM output line
transitioning to an intermediate state prior to setting the initial
value.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
Add user-configurable contrast, vcomh (affects "smearing"), and invert options for SSD1306/SH1106 type OLED displays.
Signed-off-by: James Esau <james_esau@hotmail.com>
For example, Raspbian GNU/Linux 8 (jessie) uses an old GCC version 4.9.2
which uses -std=gnu90 by default.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Changing this check from debugoutput to debuginput allows remote applications to perform tests against Klippy without an MCU connected.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Input shaping can help to reduce printer vibrations due to resonances
and eliminate or reduce ghosting in prints.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Register API endpoints for "pause_resume/pause", "pause_resume/resume" and "pause_resume/cancel".
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
If a shutdown occurs during a PID_CALIBRATE command (eg, due to a
heater problem) then exit cleanly instead of throwing an internal
error.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Change write_graphics() from taking one pixel row of n characters to
taking all the rows and columns for one character cell.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit allows to modify the icons (or glyphs) in the displays that
support it. Existing icons can be modified and new icons can be added via
a [display_glyph] section in the config.
Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
Rework extruder.get_trapq() into extruder.sync_stepper() so that
extruder_stepper.py does not need to directly access the extruder
internals.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Option for using the current diameter instead of nominal while the first measurement isn't in place
Signed-off-by: Matthias Pabel <matthias.pabel@hs-augsburg.de>
This reverts commit 43fa41c1af.
The above commit disabled absolute extrude moves because it was
unclear if the code would work properly when an M221 extrude factor or
G92 offset was in use. However, since the calculation is done
relative to the raw E position and is sent as a raw E position to
gcode.cmd_G1() these modes should not matter.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If self.kin_flush_delay changes after a G4 dwell command (or other
non-kinematic time update) then it could lead to "internal step
compression" errors. Make sure to handle this case in
flush_step_generation().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make it clear that gcode.get_status() to be called without an
eventtime by defaulting eventtime=None.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Store a reference to the gcode class in self.code. Obtain the
z_offset once and use for both the oldval and newval calculation.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 9530373c introduced a minimum value of zero for the g-code z
position. Unfortunately, that would likely cause the tuning tower to
not emit a command at the start of a test because the initial dummy z
position is set to a negative value. The minimum bound should not be
needed so remove it.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This gives it parity with heater_fan. Also change the default speed from
max_power to 1.0, since it is already scaled by max_power in set_speed.
Signed-off-by: Adrian Keet <arkeet@gmail.com>
Commit c3899cef inadvertently broke the error check for unused config
options. Add a new note_valid parameter to the config access wrappers
and use that in get_status() to fix the check.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
round to only 6 decimal places of precision. prevents doing extra retry
from small variations due to floating point math.
Signed-off-by: John "Fess" Fessenden <fess@fess.org>
Always disable the PWM after each command sent. Automatically trim
the command duration so the PWM disable doesn't increase the total
pulse time (when the duration is 200ms or greater).
Track the ideal command end time separately from the pwm transmit time
and only delay toolhead moves to this ideal time.
Update verify_state() to automatically schedule the check using the
time of the last sent command.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rename try_load_module() so that it uses consistent naming for
"printer objects". Change the function to raise an error by default
if the specified module does not exist.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Remove the parsing helpers from the main gcode class now that all
callers have been converted to use the parsing helpers in the
GCodeCommand class.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Instead of passing a dictionary to the command handlers, create a
wrapper class and pass that class to the command handlers. This can
simplify the command handler code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Avoid using doubles as flags when generating steps during "lead up to
stepper activity". Instead, explicitly track how many inactive move
entries are skipped and only generate steps for those entries.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't assume the times passed to itersolve_gen_steps_range() are
contained within the move. It's possible the checks in
itersolve_generate_steps() may round to different values when
converting the times to a relative move time.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The beagleboard TI kernel 4.14 and 4.19 contain a commit which change
the device names ("pwm: Create device class for pwm channels") from
pwmN to pwm-${chip}:N. This commit was never merged into the upstream
kernel.
Decrease the number of pwm channels to a more reasonable 16. Increase
the number of pwm chips to 8 since the replicape servo pwm outputs are
on pwmchip4.
Update replicape code to detect appropriate channel.
Signed-off-by: Janne Grunau <janne-gh@jannau.net>
Add a 50ms delay from the initial clock measurement to the first
get_clock query. Disable the prediction_variance filter on each
get_clock query so that none of those measurements are ignored.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The heater logic is an independent module that does not need to be
treated as part of the "core" klipper code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's no longer necessary to queue gcode scripts - gcode.run_script()
now does that automatically.
Also, make release_gcode config optional.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The probe_finalize() name is used for callbacks in both the
PrinterProbe and ProbePointsHelper classes. Rename the PrinterProbe
callback to avoid confusion.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rename the method to make it more clear that it is a low-level call
that should be rarely used.
Also, change gcode_button.py, hall_filament_width_sensor.py, and
tsl1401cl_filament_width_sensor.py to use respond_info() instead of
respond_raw().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Report low-level disk errors via the log and use the normal sdcard
mechanism to report end of sdcard print to gcode users.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's important to raise an error (instead of calling respond_error() )
so that a G20 will stop a virtual_sdcard print.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
No need to check for '#original' in params - it's always there.
Properly handle a lower case m118 command. Don't register a help text
for the legacy M118 g-code command.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Raising an error (instead of reporting an error) is important as only
a raised error will stop a print from virtual_sdcard.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 402110f6 didn't actually fix absolute extrude mode. For now,
report an error if an extrude move is requested in absolute extrude
mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Fix linear_travel optimization. Use "2*pi" instead of "radians(360)".
Always emit at least one segment and always end at the final target
coordinates.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Fix Z moves so that the movement is spaced out among the arc movements.
Fix extrude moves when in absolute extrude mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use the normal gcode.get_float() mechanism for extracting parameters
from the g-code command.
Don't register descriptions for the G2/G3 commands as the convention
is to only use descriptions for "extended g-code commands".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This reverts commit 5c8d15bbee.
The lower_probe() code was already manually optimizing the timing of
the pwm disable, and that conflicted with the optimization in commit
5c8d15bb.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
Some clones don't raise the pin on a reset and the ANTClabs BL-Touch
sometimes doesn't raise the pin either.
Rework the (infrequently called) sensor test code to always issue a
pin_up command before the touch command. Also, perform a reset and
retry if the sensor test fails.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Be sure to fully raise the probe prior to starting any future toolhead
movements in the multi_probe_end() case.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If an error is found during the pin_up_not_triggered check, then apply
the reset command for a full second (instead of just 100ms). This
gives the bltouch more time to check its internal state.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Return the triggered state from verify_state() and update the callers
to raise the error (if needed).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some stepper motor drivers do not respond well to rapid "step +
direction change + step" events. In particular, it is believed this
can cause "over current" events on the tmc2208 drivers when they are
in "stealthchop" mode. Detect these events and remove them from the
generated step times.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>