Commit Graph

1765 Commits

Author SHA1 Message Date
Kevin O'Connor b2c78d71b0 gcode: Remove "action_" commands from get_status() calls
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>
2020-08-20 21:03:22 -04:00
Kevin O'Connor 2caaaea9a4 toolhead: Add a manual_move() helper function
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>
2020-08-20 21:03:22 -04:00
Kevin O'Connor b9ac6d6306 skew_correction: Make sure to call reset_last_position() on a skew update
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-20 21:03:22 -04:00
Kevin O'Connor 4115a77342 gcode: Automatically call reset_last_position() on a toolhead set_position()
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>
2020-08-20 21:03:22 -04:00
Janar Sööt 560d48dbc9 menu: reduce timeout timer period to 1s
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
2020-08-20 09:10:23 -04:00
Kevin O'Connor 8fa1c97767 display: Support requesting a screen redraw on a menu key press
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>
2020-08-20 09:04:56 -04:00
alocin73 1bdf705524
hall_filament_width_sensor: Fix Flow update before next pending_position #3184 (#3198)
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>
2020-08-19 18:58:49 -04:00
Janar Sööt bc904dd431 menu: remove surplus self.running=False
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
2020-08-18 21:39:15 -04:00
Janar Sööt ccfcc3789b menu: optimize container populate
- 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>
2020-08-18 21:39:15 -04:00
Kevin O'Connor 9d9e5c7edc klippy: Report "shutdown" category from get_state_message()
Reported by @Arksine.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 14:10:54 -04:00
Kevin O'Connor fa83b1319c webhooks: Improve type checking of api requests
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 13:49:45 -04:00
Kevin O'Connor 7ec2ec30e3 webhooks: Convert to a json-rpc inspired message format
Convert to a new json message format.  Requests look like:

{"id":14, "method": "info", "params": {}}

and responses look like:

{"id": 14, "result": {}}

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 13:23:16 -04:00
Kevin O'Connor 2b0b30ccd5 webhooks: Remove call_remote_method()
Clients will now only receive messages that they've subscribed to.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 13:23:16 -04:00
Kevin O'Connor 1ae671f61f webhooks: Add klippy state to webhooks get_status() method
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>
2020-08-16 13:23:16 -04:00
Kevin O'Connor b0e3effb53 webhooks: Rework get_status() subscriptions
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>
2020-08-16 13:23:05 -04:00
Kevin O'Connor 16a53e6918 webhooks: Require a subscription to receive gcode output
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>
2020-08-16 13:20:26 -04:00
Kevin O'Connor 568393c941 webhooks: Remove "method" parameter from webhook requests
Don't require or use the "method" parameter of requests.  This
simplifies the interface.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 13:20:25 -04:00
Kevin O'Connor 7289af6560 webhooks: Create StatusHandler class in add_early_printer_objects()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 13:20:25 -04:00
Kevin O'Connor b74a5c5217 webhooks: Remove register_static_path()
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>
2020-08-16 13:20:25 -04:00
Kevin O'Connor 0aad2437c5 webhooks: Specify server_address on klippy command-line
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>
2020-08-16 13:20:25 -04:00
Kevin O'Connor 118ef908a5 display: Remove reference to printer.gcode.busy from display.cfg
The "busy" variable was removed and using it isn't necessary.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-15 17:20:24 -04:00
Janar Sööt b490848bc9
menu: fix for overwriting existing menu item (#3189)
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>
2020-08-14 13:42:33 -04:00
Janar Sööt 7a615b4f69 hall_filament_width_sensor: fix error
Fix no attribute error in in get_status

Signed-off-by: Janar Sööt <janar.soot@gmail.com>
2020-08-13 16:49:51 -04:00
Arksine e4f3f60ea6 virtual_sdcard: register sd static path
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-11 10:47:04 -04:00
Arksine 0c7faa978c webhooks: register gcode output handler and additional static paths
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-11 10:47:04 -04:00
Arksine bf221d5e26 webhooks: Implement a send buffer for socket writes
This prevents ClientConnection.send() from blocking, removing the possibility that callers become reentrant.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-11 10:47:04 -04:00
Arksine 4dcf494b97 webhooks: Implement unix domain socket server
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-11 10:47:04 -04:00
Bryan Boettcher 04bd48ca9d
adc_temperature: add support for AD597 (#3164)
The AD597 thermocouple amplifier is used in the Raise3D N2+ (and
possibly others).

Signed-off-by: Bryan Boettcher <bryan.boettcher@gmail.com>
2020-08-09 21:06:43 -04:00
Janar Sööt d991b4c83b
menu: Replace menu with new Jinja2 template system (#2344)
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>
2020-08-09 09:29:55 -04:00
Trevor Jones efebbb9a2f
tmc5160: diag0 support (#3159)
Allow for diag0 only hardware to use sensorless homing.

Signed-off-by:  Trevor Jones <trevorjones141@gmail.com>
2020-08-09 08:17:51 -04:00
Kevin O'Connor ea5e76746a itersolve: Use stricter completion check in itersolve_find_step()
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>
2020-08-08 11:59:19 -04:00
Kevin O'Connor 513582afc4 itersolve: Enhance "false position" method with "illinois algorithm"
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>
2020-08-08 10:58:20 -04:00
Kevin O'Connor e5a3fd7cee gcode: Fix error causing _dump_debug() to fail
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-08 10:02:38 -04:00
Toby Harper f851cfae46
gcode_arcs: increment absolute e coord for each arc segment (#3162)
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>
2020-08-07 12:15:03 -04:00
bondus c9e7119a93
fan_generic: Add support for named fans and gcode to control them (#3054)
Signed-off-by: Pontus Borg <liquidpontus@yahoo.se>
2020-08-07 11:39:44 -04:00
Arksine 3eefc037c5 polar: fix limit_z default value
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-06 14:31:42 -04:00
Arksine 27ef58642e webhooks: Implement StatusHandler class
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>
2020-08-06 14:30:48 -04:00
Arksine cde7e75139 webhooks: Add call_remote_method helper function
This may be used to execute formatted RPC calls.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-06 14:30:13 -04:00
Kevin O'Connor 447374f73e gcode: Separate IO handling to its own class
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>
2020-08-06 14:21:08 -04:00
Kevin O'Connor 795bd03b33 webhooks: Directly invoke printer.invoke_shutdown()
No need to indirectly shutdown via the gcode class - just call
printer.invoke_shutdown() directly.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-06 14:21:08 -04:00
Kevin O'Connor 4346d37c06 webhooks: Introduce add_early_printer_objects()
Create the initial gcode class via new module level
add_early_printer_objects() function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-06 14:21:08 -04:00
Kevin O'Connor 8c8b9b1812 gcode: Introduce add_early_printer_objects()
Create the initial gcode class via new module level
add_early_printer_objects() function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-06 14:21:08 -04:00
Kevin O'Connor 0d930bf871 gcode: Pass the pseudo-tty fd via the start_args system
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-06 14:21:08 -04:00
Kevin O'Connor b66dd1a60f gcode: Allow handlers to be registered for all gcode output
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-06 14:21:08 -04:00
Kevin O'Connor 8ed1696624 gcode: Only write to the gcode pseudo-tty if it appears to be active
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>
2020-08-06 14:21:08 -04:00
Arksine b9f48e634e print_stats: Add virtual_sdcard state tracking
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-05 13:46:24 -04:00
Arksine 6b1ad715aa print_stats: stat tracking for virtual sdcard prints in progress
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2020-08-05 13:46:24 -04:00
Arksine 463194b1a3 virtual_sdcard: update get_status method
Do not reset progress to zero while paused.  Report 'is_active' and 'file_position'.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-05 13:46:24 -04:00
Arksine 963d7c247b virtual_sdcard: add SDCARD_PRINT_FILE gcode
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>
2020-08-05 13:46:24 -04:00
Arksine af39a209f3 virtual_sdcard: add SDCARD_RESET_FILE gcode
This allows the user to close a currently loaded file and reset the virtual_sdcard's state.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-05 13:46:24 -04:00