Commit Graph

2345 Commits

Author SHA1 Message Date
chrenderle afd80c1de9
bed_screws: Finish bed_screws_adjust after n consecutive accepts (#4521)
Changed the bed_screws_adjust command so that it finishes after 4
consecutive accepts. Before if you had 4 screws and adjusted the
first one you had to accept 7 times to finish the bed_screws_adjust.

Signed-off-by: Christian Enderle <mail@chrenderle.de>
2021-08-17 13:56:43 -04:00
Kevin O'Connor 1aa4becc60 bed_mesh: Fix off-by-one error in faulty region error report
Reported by @craiglink.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-17 12:05:59 -04:00
Kevin O'Connor e3cf8fc819 motion_report: Fix typo causing incomplete queries
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-17 00:10:44 -04:00
Kevin O'Connor cf3c7cd99a avr: Rename the analog-only PE0/PE1 pins on atmega168/328 to PE2/PE3
The atmega328pb has officially named these pins as PE2 and PE3, so use
that naming scheme instead of the previous Klipper invented names.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-14 22:00:17 -04:00
Kevin O'Connor f759df3cd7 endstop_phase: Convert to using tmc mcu_phase_offset
Now that the TMC drivers track the phase offset, use that to implement
endstop phase.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-08 22:28:10 -04:00
Kevin O'Connor 06b8169f56 tmc: Track offset between tmc driver and mcu position
Track the offset between driver phase and mcu position.  This offset
should be constant as long as neither the driver nor the mcu is reset.
If the offset ever changes, log a warning.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-08 22:28:10 -04:00
Kevin O'Connor c2bfeb60aa tmc: Move stepper phase reading code to TMCCommandHelper class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-06 13:12:49 -04:00
Kevin O'Connor 24586f0c31 stepper: Query the stepper mcu position during startup
Try to keep the host mcu_position synchronized with the
micro-controller by querying during startup and after every homing
event.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-06 13:12:49 -04:00
Kevin O'Connor 33dcb38297 tmc: Consistently use lower case for all TMC field names
The Trinamic specs aren't consistent with upper vs lower case, which
can be confusing.  Improve clarity by using lower case names
consistently in the code.  Register names will continue to use all
upper case naming in the code.

Update the SET_TMC_FIELD command to automatically convert field names
to lower case.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-06 13:12:49 -04:00
Kevin O'Connor a52a627893 tmc2208: Send pdn_disable UART setup as first command to chip during init
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-06 13:12:49 -04:00
Kevin O'Connor fa7a91a38b homing: Improve error messages on a printer shutdown during homing
If a shutdown occurs during homing, make sure any follow up errors are
clear that the cause of the error is the shutdown.  This suppresses
the confusing "Unable to obtain 'trsync_state' response" messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-06 13:05:09 -04:00
Kevin O'Connor afada5e79e trapq: Prune interrupted moves from history on trapq_set_position()
It is possible for a homing move to not fully complete.  Fixup the
trapq history to make processing of the history easier for callers.
Similarly, do not add artificial "null" moves to the trapq history.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-06 12:22:07 -04:00
Kevin O'Connor b17ec3d2e9 stepcompress: Pass clock to stepcompress_set_last_position()
Using sc->last_step_clock for the last position marker does not work
properly, because the stepper.py code calls stepcompress_reset() prior
to calling stepcompress_set_last_position().  Fix by passing an
explicit clock to stepcompress_set_last_position().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-06 11:19:36 -04:00
shiftingtech 36e3969219
probe: bugfix to z_offset_apply_probe (#4553)
Command was accessing the wrong variable for the existing z offset,
leading to bad behavior.

Signed-off-by: Ben Eastep <shifting@shifting.ca>
2021-08-02 16:08:19 -04:00
Tircown a143921534
idex_modes: Fix get_status (#4550)
Fix get_status to be called without eventtime parameter.

Signed-off-by: Fabrice GALLET <tircown@gmail.com>
2021-08-01 15:10:45 -04:00
Kevin O'Connor 69d9497df3 webhooks: Remove spaces from json messages sent on api server
Reduce the bandwidth slightly by removing unnecessary spaces in
messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:54:21 -04:00
Kevin O'Connor 60aa05829f motion_report: Add get_status() method with current requested toolhead position
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:53:32 -04:00
Kevin O'Connor 38766c367f motion_report: Add new extras module for low-level motion diagnostics
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor f0dbeb0493 stepper: Simplify helper module registration of stepper motors
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor c632b377ca mcu: Support returning the mcu reported shutdown time
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor cbd5680ae0 extruder: Add get_trapq() method
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor 7013a7b15f stepcompress: Support extracting stepcompress history
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor fbfa31a3c3 stepcompress: Rename 'struct history_move' to 'struct history_steps'
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor 07f0ecb4d0 trapq: Store toolhead.set_position() updates in trapq history
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor 45c232b2c7 trapq: Keep history of recent trapq moves
Store trapq moves in a separate "history" list after each move is
nominally expired.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor e2f483aea3 trapq: Rename trapq_free_moves() to trapq_finalize_moves()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor d1b41ea4a1 force_move: Note force_enable() and restore_enable() are internal functions
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kamil Trzcinski 7e88f9220c menu: fix crash when opening SDCard menu while printing
This fixes the bug introduced by f1091a484b.
The problem is that condition was returning string which
could not be converted to boolean. We solve that by showing
`Start Printing` when `is_active`.

```
ERROR:root:Unhandled exception during run
Traceback (most recent call last):
   ...
   File "/opt/klipper/klippy/extras/display/menu.py", line 117, in eval_enable
     return bool(ast.literal_eval(self._enable_tpl.render(context)))
   File "/usr/lib/python2.7/ast.py", line 49, in literal_eval
     node_or_string = parse(node_or_string, mode='eval')
   File "/usr/lib/python2.7/ast.py", line 37, in parse
     return compile(source, filename, mode, PyCF_ONLY_AST)
   File "<unknown>", line 1
     /opt/octoprint/uploads/wait_print.gcode
```

Signed-off-by: Kamil Trzcinski <ayufan@ayufan.eu>
2021-07-26 22:34:43 -04:00
shiftingtech f949bc882d
probe: add ability to save babystepping (#4404)
Created two new extended gcodes: Z_OFFSET_APPLY_ENDSTOP, and Z_OFFSET_APPLY_PROBE.
These use the z gcode offset to revise the probe offset, or z endstop position
allowing users to make a frequently used babystepping value permanent without
manual config editing.

Signed-off-by: Ben Eastep <shifting@shifting.ca>
2021-07-25 20:20:15 -04:00
Kevin O'Connor 0075b29081 tmc_uart: Increase default UART rate to 40000 on 32bit MCUs
A higher UART baud rate will allow for faster transfers and may result
in more stable operation in general.  Increase the baud to 40000 on
32bit MCUs and leave the baud at 9000 baud for 8bit AVR MCUs.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-23 13:37:20 -04:00
Kevin O'Connor b4fec8502c tmc2209: Set SENDDELAY=2 to avoid uart rx/tx errors
It looks like the tmc2209 chips have increased uart errors with the
default SENDDELAY of zero.  Increasing the SENDDELAY to two seems to
work around this issue.

Reported by @ReXT3D.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-23 13:37:20 -04:00
Justin Schuh bb801905be spi_flash: Make SD updates more tolerant of flaky boards
Validation passes if either of the following succeeds (in order):
1. Active firmware's raw dictionary changed after update
2. Checksum of firmware.cur matches expected

Additionally, deletes firmware.bin if found after update succeeds.

Signed-off-by: Justin Schuh <code@justinschuh.com>
2021-07-20 18:05:05 -04:00
Kevin O'Connor 103dcf27ff controller_fan: Minor updates
Document change in behavior of the controller_fan module.

Lookup heater objects in connect() event handler.

Return list of stepper names from stepper_enable.get_steppers().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-20 10:34:14 -04:00
Sophie Hirn de57ce3a99
controller_fan: Add "stepper" config option (#4447)
Allows contoller_fan sections to monitor only certain steppers instead of
all of them, similar to how heaters are currently handled.

Signed-off-by: Sophie Hirn <sophie.hirn@wyvernscale.com>
2021-07-20 10:19:59 -04:00
Kevin O'Connor f24210054a mcu: Set reqclock on trsync_start commands
Set the reqclock on trsync commands to ensure those commands do not
cause 32-bit timer rollover errors.  Otherwise, it may result in
"Timer too close" errors.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-09 14:34:38 -04:00
Dmitry Butyugin 1128e9179b resonance_tester: Arbitrary AXIS in TEST_RESONANCES command
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2021-07-08 11:00:23 -04:00
Kevin O'Connor 59fe878241 rp2040: Add initial adc support
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-04 10:11:02 -04:00
Kevin O'Connor d1bdde56cc samd_sercom: Specify the sercom explicitly in a config option
Do not infer the sercom from the config section name, as that
prevents one from using SPI buses on multiple samd mcus.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-04 09:48:45 -04:00
Kevin O'Connor df43c9e9bf stepper_enable: Move pin handling out of EnableTracking class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-03 23:58:40 -04:00
Kevin O'Connor 57bd1c6b9f stepper: Minor indentation changes
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-03 23:58:40 -04:00
henrikssn 430578957f
stm32: Add support for STM32F072 (used in the TurboCAN board) (#4412)
* Add menuconfig option for stm32f072
* Add support for internal temp of stm32f072
* Share the temperature calculation logic between stm32f0x2 MCUs

Signed-off-by: Erik Henriksson <erikhenrikssn@gmail.com>
2021-06-27 20:35:34 -04:00
Kevin O'Connor 7fd7853785 duplicate_pin_override: Debugging tool to permit multiple use pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-27 18:50:51 -04:00
Tircown 4d559633e3
kinematics: Add dual_carriage to hybrid-corexyz (#4296)
- Add dual_carriage abilities for hybrid-corexy and hybrid-corexz
- Introduce the module idex_mode
- Fix add_stepper to the correct rail in hybrid-corexy

Signed-off-by: Fabrice GALLET <tircown@gmail.com>
2021-06-27 18:37:05 -04:00
Kevin O'Connor 6c8d1ddaec bltouch: Ensure the z_offset is not negative
It would not make sense to have a negative z_offset.  Reported by
@Yoyolick.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-22 15:30:25 -04:00
Matthew Lloyd c2907c998c
screws_tilt_adjust: Add DIRECTION parameter to SCREWS_TILT_CALCULATE (#4357)
Signed-off-by: Matthew Lloyd <github@matthewlloyd.net>
2021-06-22 15:18:05 -04:00
Kamil Trzcinski f1091a484b virtual_sdcard: add `file_path` and `file_size` to `status`
This provides a comprehensive information if currently
we have a file loaded.

Signed-off-by: Kamil Trzcinski <ayufan@ayufan.eu>
2021-06-22 15:15:03 -04:00
Eric Callahan 7ced62ab9c dotstar: report color data via get_status()
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-18 10:53:12 -04:00
Arksine 65afad9428 neopixel: report color data via get_status() method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-18 10:53:12 -04:00
Kamil Trzciński 46f51b2bb0
print_stats: add `cancelled` when `CANCEL_PRINT` used (#4366)
Before this change, a `CANCEL_PRINT` set a `print_stats` to `paused`
that would later be workaround-ed with `fluidd`/`mainsail` to re-define
`CANCEL_PRINT`.

This sets a proper canceled state, but additionally closes a file
from a `virtual_sdcard` context for `canceled`/`error`, as this is no longer
resumable from this point.

Signed-off-by: Kamil Trzcinski <ayufan@ayufan.eu>
2021-06-14 15:09:55 -04:00
Kamil Trzcinski d2c2aaf55d extruder: expose `can_extrude` flag based on temperature
Sometimes an automated filament load is implemented,
but extruder might not always extrude filament.

This adds a flag to check if this operation is possible.

Signed-off-by: Kamil Trzcinski <ayufan@ayufan.eu>
2021-06-14 12:56:50 -04:00
Kevin O'Connor 0bc0767997 stepper: Restore mcu_position on set_stepper_kinematics() and set_step_dist()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-11 23:13:05 -04:00
Kevin O'Connor 1506043477 stepcompress: Add missing functions to stepcompress.h
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-11 23:12:16 -04:00
Kevin O'Connor acdad76408 klippy: Add a newline between initial error message and hint text
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-10 21:30:09 -04:00
Kevin O'Connor bc29ee1c6d homing: Check for failures during multi-endstop homing
If any endstop reports a failure, then stop homing on all endstops.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor 983951443c mcu: Enable trdispatch infrastructure during homing
Separate out trsync handling from endstop handling in mcu.py code.
Enable the low-level trdispatch C code.

This is in preparation for multi-mcu homing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor e1f7748e1a trdispatch: Support fast responses to trsync_state messages
Add C code that can process trsync_state messages and dispatch
responses with low-latency.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor b6d8cf27d2 serialqueue: Add serialqueue_send_one() helper function
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor c53e8c7d4a serialqueue: Add "fast reader" support
Add ability to run C code directly from the low-level socket reading
thread.  This enables host based low-latency handlers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor 620f77ddb7 msgblock: Add clock estimation helper functions
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor f938caa0d2 msgblock: Add msgblock_decode()
Add function that can parse a simple VLQ encoded message to an array
of integers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor 1865080a07 msgblock: Move message manipulation code from serialqueue.c to new msgblock.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor 2559a2dd5a pollreactor: Move C pollreactor code from serialqueue.c to its own file
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor 05c2d51a12 trsync: Introduce new "trigger synchronization" support
Separate out the stepper stopping code from endstop.c into its own
trsync.c code file.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor f3bd4e6acf probe: Call add_stepper() earlier in boot process
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor ecbfa76242 mcu: Raise config_error (not protocol error) on pin enumeration errors
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:26 -04:00
Kevin O'Connor 31fcd491fd serialhdl: Support prepending a warn_prefix to error and log messages
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:26 -04:00
Eric Callahan 3fcce4bb4b bed_mesh: implement BED_MESH_OFFSET
The BED_MESH_OFFSET gcode can be used to apply X and/or Y offsets the the mesh lookup.  This allows printers with independent extruders to correct the Z adjustment when changing a tool.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-08 00:02:35 -04:00
Eric Callahan 4dfe01a2cd bed_mesh: move the "fade offset" out of the ZMesh
This is a temporary offset applied to the mesh used to fade toward a "target".  For clarity, apply the fade offset when the final z calculation is made.

SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-08 00:02:35 -04:00
Kevin O'Connor be4fb7f128 endstop_phase: Unify phase conversion code
Introduce a new PhaseCalc class and use that for both homing and
ENDSTOP_PHASE_CALIBRATE.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-06 20:41:27 -04:00
Dmitry Butyugin 4596a244e3
resonance_tester: Set max_accel ignoring the limit from the config (#4174)
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2021-06-06 13:04:53 -04:00
Kevin O'Connor 93b9a85d19 endstop_phase: Add support for reporting phase information via get_status()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-03 22:27:30 -04:00
Michael Rose 27f8cf025e
z_tilt: expose an 'applied' status to allow macros to skip QGL/Z_TILT_ADJUST (#4313)
This is useful for macros that'd like to skip QGL if already leveled,
e.g.:

```
    {% if not printer.quad_gantry_level.applied %}
        QUAD_GANTRY_LEVEL
    {% endif %}
```

Signed-off-by: Michael Rose <elementation@gmail.com>
2021-06-02 11:11:19 -04:00
Paul McGowan c148f17ea3
neopixel: add sync parameter to prevent waking toolhead (#4339)
neopixel: add sync param to prevent waking toolhead

dotstar: refactor to match neopixel methods and add sync parameter

Signed-off-by: Paul McGowan <mental405@gmail.com>
2021-06-02 10:51:45 -04:00
Stefan Dej b5e4f3d204
gcode: Update gcode descriptions (#4335)
Add help description to HELP
Add help description to RESPOND
Add help description to MEASURE_AXES_NOISE, TEST_RESONANCES and SHAPER_CALIBRATE
Add help description to PAUSE, RESUME, CLEAR_PAUSE and CANCEL_PRINT
Add help description to GET_POSITION
Add help description to SET_RETRACTION and GET_RETRACTION

Signed-off-by: Stefan Dej <meteyou@gmail.com>
2021-06-02 10:45:27 -04:00
Kevin O'Connor c0d860487a stepper: Remove set_tag_position() code
Have callers store the stepper positions in a dict.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-05-29 21:54:34 -04:00
Kevin O'Connor 77bc5e4388 stepper: Improve get_past_commanded_position()
Pass a print_time instead of a clock to get_past_commanded_position().
Fix calculation on steppers that home and use an inverted direction
pin.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-05-29 21:29:00 -04:00
Alex Zellner 341fc64a67
gcode_macro: add description property (#4317)
Signed-off-by: Alex Zellner <alexander.zellner@googlemail.com>
2021-05-26 14:21:21 -04:00
Florian Heilmann ba3bbca861
gcode_macro: Disallow whitespace in macro name (#4312)
Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
2021-05-26 13:03:10 -04:00
Florian Heilmann cf61ca301b safe_z_home: Simplify logic and fix edge case
Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
2021-05-26 12:57:31 -04:00
Jason S. McMullan 913649de2e loop_sdcard: Add loopable SD card file sections
To support continuous belt printing, add nestable repeat
loop support via an `[sdcard_loop]` module.

Supported G-Code:
  - SDCARD_LOOP_BEGIN COUNT=n  ; Loop for N times, or infinitely if N is 0
  - SDCARD_LOOP_END            ; End of loop
  - SDCARD_LOOP_DESIST         ; Complete all loops without iterating

Marlin M808 compatibility example in `config/sample-macros.cfg`:
  - M808 Ln        ; Loop for N times, or infinitely if N is 0
  - M808           ; End of loop
  - M808 K         ; Complete all loops without iterating

Added unit tests in test/klippy/sdcard_loop.test

See https://reprap.org/wiki/G-code#M808:_Set_or_Goto_Repeat_Marker

Signed-off-by: Jason S. McMullan <jason.mcmullan@gmail.com>
2021-05-26 11:57:57 -04:00
Alex Zellner 60352f4b67
filament_motion_sensor: add get_status (#4281)
Signed-off-by: Alex Zellner <alexander.zellner@googlemail.com>
2021-05-11 13:17:22 -04:00
Arksine dc71b64c0a virtual_sdcard: fix check for case sensitive files
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-11 13:15:56 -04:00
Dany Yanev b333547f1f
menu: Fixed typo when reading `print_stats.state` (#4261)
Fixed typo when reading `print_stats.state` causing some of the menus to now show up.

Signed-off-by: Dany Yanev <yanev89@gmail.com>
2021-05-06 11:54:27 -04:00
Tircown f2c74ec023
kinematics: Add hybrid-corexy and hybrid-corexz (#4229)
Signed-off-by: Fabrice GALLET <tircown@gmail.com>
2021-05-03 14:31:23 -04:00
Kevin O'Connor 89082b494f klippy: Report known software versions on a protocol error during connection
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-05-02 17:51:15 -04:00
Kevin O'Connor edea52863a endstop: Report trigger time in endstop_query response
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-30 11:40:37 -04:00
Kevin O'Connor 470b1e2e46 adxl345: Use "clock" suffix instead of "time" in commands
The debugging code knows how to handle fields that end in "clock".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-30 11:40:37 -04:00
Kevin O'Connor b611e72a19 pulse_counter: Use "clock" suffix instead of "time" in commands
The debugging code knows how to handle fields that end in "clock".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-30 11:40:37 -04:00
Kevin O'Connor 8f76e53c0e stepper: Remove min_stop_interval from mcu code
Now that the host never uses a min_stop_interval, remove it from the
mcu code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-30 11:26:19 -04:00
Kevin O'Connor b1ea4f3bef toolhead: Do not limit SET_VELOCITY_LIMIT to values specified in config
Allow a larger velocity, accel, and square_corner_velocity than what
is specified in the config file.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-30 11:26:19 -04:00
Kevin O'Connor 5a5ecd88e2 stepper: Do not set min_stop_interval in micro-controller
The min_stop_interval safety check is fragile and leads to a notable
amount of complexity.  Avoid these issues by not programming this
safety check.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-30 11:09:08 -04:00
Kevin O'Connor 0a4a64058d probe: Use original XY position on multiple probe samples
On some kinematics it's possible for the XY position to change
slightly during a probing move.  Return back to the original XY
position on a probe lift so each probe attempt starts at the same
nominal position.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-28 21:40:49 -04:00
Kevin O'Connor 0990a3da6f gcode: Generate M115 output even if command not sent from gcode pseudo-terminal
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-28 21:40:03 -04:00
Kevin O'Connor 25389027de Revert "endstop_phase: wip"
This reverts commit f2e4653ca4.

Revert incomplete testing code that was accidentally committed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-28 20:42:33 -04:00
Kevin O'Connor f2e4653ca4 endstop_phase: wip 2021-04-28 20:32:14 -04:00
Dmitry Butyugin 3b33d6652f resonance_tester: Refactored the testing code
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2021-04-28 12:36:23 -04:00
Johannes Stuettgen ed6ab6b9cc screws_tilt_adjust: Add MAX_DEVIATION parameter for bed level invariant.
This is useful when a saved bed mesh is used to ensure that the bed level
has not drifted too far from where it was when the mesh was created.

Signed-off-by: Johannes Stuettgen <johannes.stuettgen@gmail.com>
2021-04-28 11:53:18 -04:00
nlef 2d2db0f839
probe: Add deactivate_on_each_sample: param for Probe (#4161)
Signed-off-by: Nick Lefskiy <n.lefskiy@yandex.ru>
2021-04-24 13:39:58 -04:00
Dmitry Butyugin 200b62bcb4 adxl345: Verify the register writes, added debug adxl345 commands
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2021-04-24 13:15:17 -04:00
Kevin O'Connor ca1d431653 stepper: Register a config default for calculated homing_positive_dir
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-16 11:42:39 -04:00
Clifford Roche 3a023d0ff4
palette2: Fix get_status (#4171)
Signed-off-by: Clifford Roche <clifford.roche@gmail.com>
2021-04-15 13:53:06 -04:00
Clifford Roche e7b0e7b43b
palette2: Add ping variation + ping status reports (#4114)
Signed-off-by: Clifford Roche <clifford.roche@gmail.com>
2021-04-14 11:37:24 -04:00
Kevin O'Connor dce9971aa9 stepcompress: Improve numerical stability of step+dir+step filter
Apply the step+dir+step filter even if, for some reason, a negative
time is found.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-11 12:19:57 -04:00
Arksine 60372fd0cf bed_mesh: introduce "faulty_regions" option
Users may define "faulty regions", locations within the mesh where a probed value is unreliable. When bed mesh generates points it will substitute points in faulty regions with up to 4 points nearest to the region. After calibration is complete the Z values at these points will be averaged and assigned to the original value inside the faulty region.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-04-10 11:16:07 -04:00
Arksine 5f5dfbaa7f bed_mesh: Allow user to clear the relative_reference_index via gcode
If a negative number is specified for the RELATIVE_REFERENCE_INDEX parameter clear the internal relative_reference_index.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-04-10 11:16:07 -04:00
Kevin O'Connor 38b2805136 toolhead: Export the print_stalls value via get_status()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-09 20:44:27 -04:00
Kevin O'Connor 49a2b0354f statistics: Export the OS and process load in a get_status() method
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-09 20:27:38 -04:00
le-Bark eb4abdd830
pca9533: RGB support for the mightyboard (#4150)
Signed-off-by: Marc-André Denis <marcadenis@msn.com>
2021-04-09 17:47:16 -04:00
le-Bark 317402d5ba
hd44780_spi: added lcd support to the mightyboard (#4121)
Signed-off-by: Marc-André Denis <marcadenis@msn.com>
2021-04-07 21:07:23 -04:00
Dmitry Butyugin 165d2fc228 resonance_tester: Fixed multi-point resonance testing
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2021-04-07 19:05:23 -04:00
Kevin O'Connor b5b2fe2d2b bed_mesh: Perform initialization from klippy:connect instead of klippy:ready
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-02 13:50:38 -04:00
Kevin O'Connor 3cfc42e54a bltouch: Minor indentation change
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-02 13:43:01 -04:00
Kevin O'Connor 2a9a133f36 bltouch: Raise the probe as soon as the endstop triggers
Start the raise sequence once the endstop notification arrives.  This
can reduce the response time as it does not require waiting for the
homing sequence to fully finalize.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-02 13:43:01 -04:00
Kevin O'Connor c9ae89e142 bltouch: Use hmove.check_no_movement() to verify bltouch deployed
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-02 13:43:01 -04:00
Kevin O'Connor cdaf9379b0 pause_resume: Perform setup via "klippy:connect" instead of "klippy:ready"
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-01 10:10:39 -04:00
Arksine 74d527776e bed_mesh: lookup the toolhead object in "handle_connect"
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-04-01 09:32:23 -04:00
Kevin O'Connor d609753a6a gcode_move: Make sure to call reset_last_position() in _handle_ready()
If reset_last_position() is invoked prior to the printer being
"ready", then the transform may not be properly accounted for.  Handle
this by calling reset_last_position() when the printer becomes
"ready".

This should fix some "must home first" errors on extrude-only moves.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-31 22:15:54 -04:00
Kevin O'Connor 3390088d3a skew_correction: Register during "connect" phase instead of "ready" phase
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-31 22:13:36 -04:00
Kevin O'Connor 20245d2e46 rotary_delta: Fix typo in get_status() homed_axes
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-29 23:05:34 -04:00
Kevin O'Connor 58a0eb76c5 homing: Pass the HomingMove class to homing_move_begin/end events
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-29 21:20:57 -04:00
Kevin O'Connor 37a263c0b9 homing: Move homing logic from manual_stepper.py to homing.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-29 21:20:57 -04:00
Kevin O'Connor 38719c1359 homing: Extract out movement verification to new check_no_movement()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-29 21:17:53 -04:00
Kevin O'Connor d39f849203 homing: Separate homing/probing movement logic to its own class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-29 21:17:53 -04:00
Kevin O'Connor 5002dda37c homing: Move home_axes() into cmd_G28()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-29 21:17:53 -04:00
Kevin O'Connor df56c723b9 homing: Minor simplification of verify_movement tracking
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-29 21:17:53 -04:00
Kevin O'Connor 862d3f9633 homing: Move low-level probing logic from probe.py to homing.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-29 21:17:53 -04:00
Kevin O'Connor da735ab312 toolhead: Make sure input_shaper movement starts after endstop checking
Add a dwell() to the start of drip_move() to ensure that input_shaper
movements scheduled in advance of the nominal move time aren't
scheduled prior to the homing start.  (Otherwise the stepper may move
prior to endstop checking, which can corrupt the "no movement"
checks.)

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-29 21:11:39 -04:00
Kevin O'Connor 00706dec21 output_pin: Fix bug in setting of self.resend_interval
Only set resend_interval if a mcu_duration is specified.  This fixes a
bug introduced in commit 861144d8.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-27 14:52:21 -04:00
Denis Ignatenko cc31810fa8
hall_filament_width_sensor: fix range check error (#4113)
Signed-off-by: Denis Ignatenko <deniss979@gmail.com>
2021-03-27 12:53:40 -04:00
Kevin O'Connor d02c80ef08 output_pin: Make sure to not use a cycle_time or max_duration over 5 seconds
Times longer than 5 seconds may result in a 32bit ticks overflow in
the micro-controller (for fast micro-controllers).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-26 11:37:40 -04:00
Kevin O'Connor 861144d884 output_pin: Increase time host has to confirm a pin setting
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-26 11:33:05 -04:00
Pascal P 88f6061cd7
output_pin: Support setting max_duration (#3995)
Also added documentation for using powered tools.

Signed-off-by: Pascal Pieper <accounts@pascalpieper.de>
2021-03-26 11:25:09 -04:00
Clifford Roche e2a3217289
palette2: Add support for P2 devices (#4057)
Module which bring support for P2 devices running in connected mode. This enables using a Palette2 directly with Klippy without Octoprint, or without Palette2 plugins for Octoprint which are not functional out of the box with Klipper.

Signed-off-by: Clifford Roche <clifford.roche@gmail.com>
2021-03-26 11:21:10 -04:00
Kevin O'Connor 36b1ccd598 replicape: Don't require a host alias for the enable_pin default
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-25 10:49:17 -04:00
Janar Sööt 2130e3e5d4
menu: changes in tune menu according to #4023 (#4086)
- set 1% as input minimum for speed and flow
- set speed maximum from 200% to 500%

Signed-off-by: Janar Sööt <janar.soot@gmail.com>
2021-03-23 10:55:25 -04:00
Dmitry Butyugin 2d8945dc1c graph_accelerometer: Support axis-level comparison of adxl345 data
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2021-03-20 13:24:43 -04:00
Dmitry Butyugin f248b91414 shaper_calibrate: Reduced min shaper freqs to match max_accel ~= 1500
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2021-03-20 13:24:43 -04:00
Dmitry Butyugin 57494458f3 shaper_calibrate: Ignore vibrations below max_psd / 20 threshold
The input shaper can only reduce vibrations by 20x. Therefore,
the best-case achievable vibrations level is max(psd) / 20.
Any vibrations below that level can be ignored for the prupose
of input shaper scoring. This allows tuning script to ignore
wide tails of resonances, because it is not helpful to try to
reduce them with input shaping.

Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2021-03-20 13:24:43 -04:00
Dmitry Butyugin 73a39370ad shaper_calibrate: Estimate max_accel to avoid excessive smoothing
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2021-03-20 13:24:43 -04:00
Kevin O'Connor 8eceb9d40a mcu: Update hints for "Timer too close" and "No next step" errors
In practice, these errors are usually due to problems on the host
computer instead of problems with communication.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-19 08:35:21 -04:00
Jon Sanders 6c9404ac0c
htu21d: sensor definition fix (#4075)
HTU21D sensor class lacked the method `get_report_time_delta` invoked
during watermark control loops. This short fix simply adds that method
in, calling the `self.report_time` attribute created during class
construction.

Signed-off-by: Jon Sanders <jonsan@gmail.com>
2021-03-18 23:38:07 -04:00
Kevin O'Connor 2144f716f6 tmc2660: Fix typo in seup field
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-18 23:36:25 -04:00
Kevin O'Connor b6eea021b1 tmc2660: Use lowercase for stallguard/coolstep fields
Use lowercase for the field names so that it matches the
tmc2130/tmc5160 field names.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-18 22:44:38 -04:00
Kevin O'Connor 3f04238e79 tmc2660: Report SE in DUMP_TMC even if zero
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-16 11:31:30 -04:00
Kevin O'Connor 6ebdc48b7c tmc2130: Report CS_ACTUAL in DUMP_TMC even if zero
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-16 11:31:24 -04:00
Kevin O'Connor 22753f3b38 tmc: Only check for tmc2130 reset via CS_ACTUAL if IHOLD > 0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-15 13:48:58 -04:00
Michael Kurz b4437f8eee
bme280: Add support for BMP280 and BME680 sensors (#4040)
This adds support for BMP280 and BME680 sensor ICs,
along with fixing calibration data readout for BME280.

Gas sensor readout for the BME680 is just the raw compensated value.
To get actual meaningful values, more research is needed.

Signed-off-by: Michael Kurz <michi.kurz@gmail.com>
2021-03-15 11:50:29 -04:00
Kevin O'Connor 86a924f5a6 tmc: Improve driver reset check on tmc2130 and tmc2660
Use the CS_ACTUAL/SE field to check for a mid-print driver reset.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-15 11:16:15 -04:00
Kevin O'Connor d184d9fd91 tmc: Move clear_gstat check for tmc2130 to within TMCErrorCheck class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-15 10:28:08 -04:00
Kevin O'Connor 88d0af3da3 tmc2660: Change stallguard flags to better match tmc2130/tmc5160
The tmc2660 spec has an ambiguous "SG" field that sometimes refers to
the "stallGuard" flag and sometimes refers to the "SG_RESULT" field.
The tmc2130 and tmc5160 have similar fields that are not ambiguous, so
adopt that naming strategy.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-15 10:28:03 -04:00
TheJoshW bf8f7133b4
filament_motion_sensor: Add filament_motion_sensor (#3857)
Add functionality to support a Filament Motion Sensor for detecting extruder jams as well as runouts.  Works by an encoder toggling the switch_pin 0/1 as the filament is pulled through the sensor.

Signed-off-by: Joshua Wherrett <thejoshw.code@gmail.com>
2021-03-14 21:36:19 -04:00
Kevin O'Connor d77928b17b extruder: Support looking up an extruder position from a past time
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-13 15:19:43 -05:00
Kevin O'Connor 81428265bd stepcompress: Add support for tracking history of queue_step commands
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-13 15:19:43 -05:00
Kevin O'Connor 4cbcd45ce9 serialhdl: Only load the CAN module if CAN bus is configured
Temporarily postpone loading the CAN module so that moonraker (and
similar) can improve upgrade scripts.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-13 15:02:41 -05:00
Kevin O'Connor 041692828c mcu: Add support for connecting to devices on a CAN bus
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-13 11:29:41 -05:00
Kevin O'Connor babde17c4c console: Add support for connecting via CAN bus
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-13 11:29:41 -05:00
Kevin O'Connor a20f4a8759 serialhdl: Add support for communicating over a CAN bus
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-13 11:29:41 -05:00
Kevin O'Connor 8b4ad34e22 serialqueue: Support sending messages over a CAN bus
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-13 11:29:41 -05:00
Kevin O'Connor 9572ad4327 tmc_uart: Limit to only one active uart at a time on an mcu
The tmcuart_send command increases cpu usage on the micro-controller.
Should multiple tmcuart_send commands be issued at the same time to a
single AVR micro-controller, it could increase the load to the point
that it introduces a failure. It could also lead to tmcuart_send
transmission errors, which would cause retransmission requests, which
further increase the load.

Track and share mutexes so that only one tmcuart_send command can be
active on a single mcu at a time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-12 20:51:11 -05:00
Kevin O'Connor bf5c2505ab tmc2130: Fix broken error report due to missing self.name
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-11 17:52:18 -05:00
Kevin O'Connor 7dd2bf4af3 tmc2130: Verify SPI register writes
The tmc2130 (and tmc5160) will respond back with the value written
during the next SPI command.  Use this feature to verify that the
value written matches the value sent.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-10 17:12:25 -05:00
Kevin O'Connor 3ea2e4fc58 tmc2660: Do not enable SFILT by default
None of the other TMC driver enable SFILT by default and it seems
enabling SFILT may not be ideal for sensorless homing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-10 12:07:18 -05:00
fleinze 153698c90d
idle_timeout: change standard timeout g-code (#4018)
Machines that have no heaters produce an error when the idle timeout occurs. This commit fixes this by checking if there are any heaters to turn off.

Signed-off-by: Florian Heinze <florian@heinze.at>
2021-03-07 13:48:54 -05:00
Kevin O'Connor 64b3e5642e heaters: Make sure set_temp() command wakes up the idle_timeout
Introduce a heaters.set_temperature() command and call that from
commands that set a heater temperature.  This new function calls
toolhead.register_lookahead_callback() so that the idle_timeout gets
notification that activity has occurred.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-05 18:59:01 -05:00
Kevin O'Connor 1950380d6c klippy: Fix check for duplicate objects
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-05 13:59:20 -05:00
Kevin O'Connor 5f80c84309 console: Add option to enable debug output mode
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-02 11:38:50 -05:00
Kevin O'Connor 3c6eb376ac console: Make baud an optional parameter
Make the baud rate an optional parameter to the console.py tool.  When
not present, it will default to 250000.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-02 11:38:50 -05:00
Kevin O'Connor 9d3a3f3f30 serialhdl: Update callers to decide serial fd type
Don't try to detect a "real serial port" in serialhdl.py.  Instead,
have the callers invoke either connect_uart(), connect_file(), or
connect_pipe().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-02 11:38:50 -05:00
teeminus bc2096f543
st7920: Better support for emulated ST7920 displays (#3979)
Added new ST7920E display driver which is better suited for displays with emulated ST7920

Signed-off-by: Christian Kehe <teeminus@posteo.net>
2021-03-01 18:23:06 -05:00
Kevin O'Connor 4d3d25b1f7 fan: Minor updates to tachometer handling
Add new fields to Command_Templates.md.

Remove unused self.rpm variable.

Use an explicit get_frequency() method in keeping with Klipper's
convention of not "peeking into member variables".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-01 14:57:40 -05:00
Adrian Keet 16d85d1a78 fan: Add tachometer support
This adds new config options for fans:  'tachometer_pin' to specify the
GPIO pin, and 'tachometer_ppr' (default 2) to specify the number of
signal pulses per revolution.  The rpm is also exposed by get_status for
command templates and the API server.  For fast fans (at least 10000
RPM), the polling interval can be shortened using the
'tachometer_poll_interval' option.

There is a new mcu object for a generic edge counter, which repeatedly
polls a GPIO pin and periodically reports the count to the host.

Signed-off-by: Adrian Keet <arkeet@gmail.com>
2021-03-01 14:53:13 -05:00
Lasse Dalegaard f8b0ea53dc serialqueue: correctly report EOF errors
If `klippy` loses connection to a device, the next `read()` from the
device file descriptor will result in a zero-byte result, i.e. an `EOF`.
Right now this gives a confusing error message, so this simply handles
the special case of `EOF` and outputs a better log message.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
2021-03-01 13:46:59 -05:00
Kevin O'Connor 70a1b752c9 chelper: Move logging_callback() to global scope
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-01 13:30:02 -05:00
Lasse Dalegaard e0db9f3a6e serialhdl: prevent creation of controlling tty
When `serialhdl` opens a terminal device it must prevent the device from
becoming the controlling terminal of `klippy`, as such a terminal will
send additional messages to the session leader, e.g. a SIGHUP, which
would kill `klippy`. See e.g. #3981.

pySerial already does this, but for e.g. `klipper_mcu` we were not doing
this ourselves.

On Linux a process must set `O_NOCTTY` when opening any file that could
potentially be a terminal device, to avoid this.

Earlier process daemonization tools prevent this from being an issue by
double forking, but under `systemd` a process must take steps to avoid
opening a controlling terminal.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-01 12:59:33 -05:00
Kevin O'Connor 1b989b81e0 tmc: Fix order of init during sensorless homing
With commit 53b10d3a the setup of sensorless homing could occur before
the driver was enabled which would cause the reinitialization of the
driver settings to undo the sensorless homing setup.

Use set_field() when setting the sensorless homing registers so that
it wont conflict with a driver init.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-28 18:30:25 -05:00
Kevin O'Connor 36ca639e1f tmc: No need to delay init on a stepper enable
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-28 18:04:20 -05:00
Kevin O'Connor c9b81e698e tmc: Allow more retries on a TMC UART read error during background checks
Allow three retries if we can't contact the TMC driver at all when it
is in UART mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-28 16:44:03 -05:00
Kevin O'Connor 86c943467f tmc_uart: Minor change - make the baud rate setting more clear
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-27 11:46:03 -05:00
Kevin O'Connor f035de264f tmc: Add support for periodic checking of driver status
Check the status of all Trinamic stepper motor drivers once a second.
If the driver reports an error then invoke a shutdown.  Also log any
serious warnings.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-27 10:39:47 -05:00
Kevin O'Connor 53b10d3ae7 tmc: Reinitialize on every driver enable
Send the full TMC stepper motor driver initialization sequence every
time the driver is enabled.

Don't raise an error on startup if unable to contact a tmc2208/tmc2209
driver.  If the driver is still unavailable when it is enabled then a
shutdown will be issued.  This allows users to troubleshoot (and
possibly bring up communication to the driver) prior to enabling the
driver.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-27 10:39:47 -05:00
Kevin O'Connor af8bfee210 tmc2660: Fix tmc register reading
The tmc2660 appears to send responses as soon as the clk starts
toggling.  That means the 20 bit response is at the top of the 24bit
sent message.  Also, this implies that RDSEL must already have the
correct value in the prior message.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-27 10:39:47 -05:00
Kevin O'Connor e24709b112 tmc2660: Use common warning/error flag names and descriptions
Where the tmc2660 flags match other drivers, use lowercase so that the
same monitoring code can be used for all the tmc drivers.  Also, use
the same field formatters where applicable.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-27 10:39:47 -05:00
Kevin O'Connor 2d781b8340 tmc5160: Merge field formatters into tmc2130.py
The tmc5160 field formatters were mostly duplicates of the tmc2130 -
add the "reset" field to tmc2130.py so both drivers have similar
reporting.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-27 10:39:46 -05:00
Kevin O'Connor 21383fa32e tmc: Always report values after a SET_TMC_CURRENT command
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-27 10:39:46 -05:00
Kevin O'Connor 6e4270fa79 tmc: Move SET_TMC_CURRENT command to TMCCommandHelper()
Refactor the tmc driver implementations so that there is a single
implementation of the SET_TMC_CURRENT command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-27 10:39:46 -05:00
Kevin O'Connor a657aab0bf tmc2660: Add set_current()/get_current() helpers to TMC2660CurrentHelper
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-27 10:39:46 -05:00
Kevin O'Connor 8312843bbe tmc5160: Add set_current()/get_current() helpers to TMC5160CurrentHelper
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-27 10:39:46 -05:00
Kevin O'Connor 9c9f78037b tmc2130: Add set_current()/get_current() helper functions to TMCCurrentHelper
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-27 10:39:46 -05:00
Kevin O'Connor 0bdee6bc04 mcu: Raise a command_error on a command timeout event
Raise a printer.command_error() instead of an mcu.error() if a query
command does not succeed.  That error is less likely to result in an
unhandled exception error.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-27 10:39:46 -05:00
Andre LeBlanc 3fc72da9ae virtual_sdcard: exact filename match before case insensitive one
currently, if there are 2 files on the virtual sd card whose names differ only in
case (eg. MyFile.gcode vs myfile.gcode) the actual file that gets loaded is at
best unpredictable.  this patch checks for an exact match before attempting a
case-insensitive one.

Signed-off-by: Andre LeBlanc <andrepleblanc@gmail.com>
2021-02-26 22:53:35 -05:00
Kevin O'Connor c5a9d7914b extruder: Make sure to flush steps during sync_stepper()
The stepper positions will only be in sync after the step generation
code has been flushed.  This fixes an "internal error in stepcompress"
error during a SYNC_STEPPER_TO_EXTRUDER command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-26 20:11:39 -05:00
Marco D'Alessio c7688c6bca tmc2130: Add spi daisy chain support
This patch adds the ability to daisy-chain multiple tmc2130 and
tmc5160 drivers.

Signed-off-by: Marco D'Alessio <marco@wrecklab.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-26 10:54:47 -05:00
Kevin O'Connor a8742e982d tmc: Improve error message on missing microsteps config
If microsteps is missing, warn about it in the stepper config section,
not the tmc config section.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-23 12:00:08 -05:00
Kevin O'Connor 4d2adddb20 stepper: Improve error messages on missing rotation_distance
If neither rotation_distance nor step_distance is present, then
generate an error saying rotation_distance is needed (instead of an
error about step_distance).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-23 11:58:17 -05:00
Kevin O'Connor 2aa2e91f2c Revert "bme280: Rename sensor_type from BME280 to bme280"
This reverts commit ac61f8b726.

Many temperature sensors are capitalized, so don't make this chaneg to
the bme280.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-20 15:39:03 -05:00
Janar Sööt 92cc286159
menu: Default menu should check extruders have heaters (#3969)
For the hotend targets check also available heaters.
It'll solve crash when using shared heaters.

Signed-off-by: Janar Sööt <janar.soot@gmail.com>
2021-02-20 11:33:34 -05:00
Janar Sööt 5a7fbe671e
menu: redesigned name scroller & menu rendering (#3837)
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
2021-02-20 11:31:03 -05:00
Kevin O'Connor ac61f8b726 bme280: Rename sensor_type from BME280 to bme280
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-20 09:23:39 -05:00
Kevin O'Connor c29585f7f3 temperature_host: Rename "path" config to "sensor_path"
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-20 09:23:13 -05:00
Kevin O'Connor 227d9bdbcf temperature_host: Improve backwards compatibility check
Don't register two names for the same instance of the sensor.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-19 18:51:42 -05:00
Evgenii 3d35c003db temperature_host: Rename rpi_temperature and add support for custom paths
Signed-off-by: Evgenii Shavrin <shavrin0591@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-19 18:44:28 -05:00
Christian S bc2f6faa17
probe: Add last_z_result to get the latest z result in an Macro (#3835)
Signed-off-by: Christian Schnellrieder <schnello.android@gmail.com>
2021-02-18 22:03:32 -05:00
Arjan Mels b2cbb9aa96
idle_timeout: Add help to SET_IDLE_TIMEOUT (#3945)
Signed-off-by: Arjan Mels <github@mels.email>
2021-02-18 20:32:46 -05:00
Kevin O'Connor ba940da9b5 stepper: Don't cache ffi_lib object in the stepper
It's easier to just call chelper.get_ffi() if the ffi_lib object is
needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-18 15:39:55 -05:00
Kevin O'Connor 81da5379d4 buildcommands: Extend number of available mcu messages from 96 to 128
Some internal code treats the message ids as encoded "variable length
quantities", while other internal code assumes the message id is
always one byte long.  Continue using this scheme, but convert the VLQ
users to use the name "msgtag" while the 1-byte users use "msgid".
Increase the number of available msgids from 96 to 127 - the higher
values get encoded as negative "msgtags".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-18 15:21:32 -05:00
Kevin O'Connor efa497dfd8 msgproto: Avoid peeking into the msgproto class members
Update callers to only use exported methods of the msgproto objects.
This makes it easier to make internal changes to the code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-18 14:33:44 -05:00
Kevin O'Connor c5968a0830 serialqueue: Batch multiple message blocks in a single write()
Some communication protocols are more efficient if fewer write() calls
are invoked.  If multiple message blocks can be sent at the same time
then batch them into a single write() call.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-12 13:59:57 -05:00
Kevin O'Connor 730ef9d347 serialqueue: Improve timing of sleep durations
If any callback is invoked from the pollreactor then obtain a new
eventtime before calculating a sleep duration.  This improves the
timing of events.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-12 13:57:51 -05:00
Kevin O'Connor 1049282eec chelper: Fix check for failed code build
Commit 73b78af6 inadvertently removed the check for a successful gcc
compilation.  Add the check back in.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-07 20:48:21 -05:00
Alan Lord 7d4df65920
ds18b20: new module for 1-wire temperature sensor (#3462)
Initial commit of code to support 1-wire (Dallas) sensors such
as the DS18B20. Requires Linux kernel drivers to create a file
in /sysfs which is read by this module, and temperature
typically returned to a temperature_fan.

Signed-off-by: Alan Lord <alanslists@gmail.com>
Signed-off-by: Josh Headapohl <joshhead@gmail.com>
2021-02-02 14:34:56 -05:00
Lane Roberts 19397a0a2b
temperature_fan: Add MAX_SPEED and MIN_SPEED to SET_TEMPERATURE_FAN_TARGET command (#3873)
Allows setting min_speed and max_speed at runtime, rather than updating the config and restarting.

Signed-off-by Lane Roberts <nolatari@vandarin.net>
2021-02-02 14:30:04 -05:00
Dmitry Butyugin d136b1e41a resonance_tester: Increase test max_accel to 10K and max_freq to 133 Hz
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2021-02-02 14:13:24 -05:00
Dmitry Butyugin a8b282d67a resonance_tester: Disable input shaping for resonance testing
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2021-02-02 14:13:24 -05:00
Dmitry Butyugin 0fb2449be0 adxl345: Add accelerometer chip name to the raw data file name
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2021-02-02 14:13:24 -05:00
Kevin O'Connor 6a3f4c7ae6 serialqueue: Improve checking of out-of-order messages
Consider any message block that acks a message never sent as an
out-of-order block and discard it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-01 19:16:23 -05:00
Kevin O'Connor 6e79152f47 htu21d: Implement support for min_temp/max_temp checks
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-01 11:30:27 -05:00
Kevin O'Connor a15952770b bme280: Implement support for min_temp/max_temp checks
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-01 11:27:16 -05:00
Kevin O'Connor 74244ab0eb spi_temperature: Improve handling of min_temp/max_temp overflows
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-01 10:37:19 -05:00
Kevin O'Connor 333f8c210f lm75: Implement support for min_temp/max_temp checks
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-01 10:37:19 -05:00
Kevin O'Connor 7775e0ed54 lm75: Use getfloat() for reading the lm75_report_time parameter
Reported by @theopensourcer.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-01 10:26:14 -05:00
Thomas Kroll 60e4cddf36 hd44780: Add hd44780 protocol init config
LDO OLED needs a different init string.

Fixes: #3722
Signed-off-by: Thomas Kroll <t.kroll@outlook.com>
2021-01-31 19:35:40 -05:00
Kevin O'Connor 5d960aef37 htu21d: Fix time reporting of temperature measurements
The temperature callback takes a "print time" not a "system time".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-24 15:38:16 -05:00
Kevin O'Connor 8de86ad51f rpi_temperature: Fix time reporting of temperature measurements
The temperature callback takes a "print time" not a "system time".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-24 15:37:37 -05:00
Kevin O'Connor bded15b743 temperature_mcu: Improve handling when in debug output mode
Call mcu_adc.setup_minmax() even in debug output mode so that the
debugging output contains a more accurate configuration.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-24 15:28:16 -05:00
Kevin O'Connor 04179f3eae bme280: Disable bme280 when using debug output
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-24 15:19:43 -05:00
Kevin O'Connor c3e3b2280a rpi_temperature: Fix missing get_report_time_delta() callback
Reported by @ronald5555.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-24 14:00:41 -05:00
Kevin O'Connor cf8d5a6606 rpi_temperature: Disable rpi_temperature when using debug output
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-24 13:59:09 -05:00
Kevin O'Connor 29831a2f69 rpi_temperature: Minor formatting changes
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-24 13:58:54 -05:00
Kevin O'Connor db86a4edcb temperature_mcu: Disable the temperature_mcu when using debug output
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-24 13:56:57 -05:00
Chip b9899a23a3
menu: Update menu.cfg sd_card menu enable condition (#3826)
Change SD card enable condition and add Cancel printing option.

Signed-off-by: John Smith <login721@gmail.com>
2021-01-24 10:35:05 -05:00
Pascal P 1e2eb9a4de
hall_filament_width_sensor: Fix race condition (#3790)
Fix race condition of filament width sensor
Added fix to similar code of TSL1401CL filament width sensor

Signed-off-by: Pascal Pieper <accounts@pascalpieper.de>
2021-01-22 13:41:34 -05:00
Kevin O'Connor 8cc1d84180 configfile: Add printer.configfile.settings command template parameter
Make available the parsed value (or default value) for config options
to command templates and to the api server.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-20 16:25:25 -05:00
Kevin O'Connor 023a985bfc gcode_macro: Use deepcopy() on get_status() results
If a get_status() method returns a mutable object (such as a list or
dict) then it would be possible for a gcode command template to
incorrectly alter the program's internal state.  Perform a deepcopy()
operation on all get_status() return results to avoid that.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-20 16:25:25 -05:00
Kevin O'Connor 8a6619d18e mcu: Add a get_status() callback with micro-controller info and stats
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-19 23:12:41 -05:00
Kevin O'Connor 611b76369f winch: Improve python3 compatibility
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-17 22:54:16 -05:00
Kevin O'Connor 0e9cb2abac save_variables: Import ConfigParser as configparser for better Python3 support
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-17 22:46:04 -05:00
Alex Zellner dac0fba50d
menu: Update menu.cfg (#3778)
Update min/max in move menu to printer variables.

Signed-off-by: Alex Zellner <alexander.zellner@googlemail.com>
2021-01-17 22:39:54 -05:00
Maël Kerbiriou 9278f56e36
webhooks: Fix use of deprecated Exception.message attribute (#3781)
Since Python 2.6, the BaseException.message attribute is deprecated (PEP-352[1])
in favor of e.args[0] or str(e). This commit replaces e.message with str(e).

[1] https://www.python.org/dev/peps/pep-0352/

Signed-off-by: Maël Kerbiriou <m431.kerbiriou@gmail.com>
2021-01-17 22:37:41 -05:00
Kevin O'Connor c57352a336 homing: Fix references to CommandError()
Commit ea85d419 moved CommandError from homing.py to gcode.py, but
failed to fix the references to CommandError within homing.py.  Fix
that.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-11 10:01:14 -05:00
Kevin O'Connor 8260a3a0c3 homing: Make homing.py an "extras" module
Move klippy/homing.py to klippy/extras/homing.py and convert the code
to an "extras" modules.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-08 14:01:34 -05:00
Kevin O'Connor ea85d419de gcode: Move definition of CommandError and Coord from homing.py to gcode.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-08 12:07:45 -05:00
Kevin O'Connor c8434ec54b kinematics: Calculate axis_minimum/axis_maximum in advance
Calculate the get_status() axis_minimum and axis_maximum fields in
advance so that they don't need to be calculated on each get_status()
call.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-08 11:52:28 -05:00
Janar Sööt e68cf08d15 kinematics: report all axis limits (min/max)
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
2020-12-28 10:19:57 -05:00
Justin Schuh a5ebe5825a
heaters: Make MINIMUM optional for TEMPERATURE_WAIT command (#3674)
Signed-off-by: Justin Schuh <code@justinschuh.com>
2020-12-24 11:34:26 -05:00
Justin Schuh 1a9218532b heaters: Add MAXIMUM option to TEMPERATURE_WAIT command
Signed-off-by: Justin Schuh <code@justinschuh.com>
2020-12-23 18:16:46 -05:00
Kevin O'Connor 16963a8e1a configfile: Improve error message when a required option is missing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-22 20:07:39 -05:00
Kevin O'Connor ca8e6ad89b configfile: Minor line wrapping changes
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-22 20:06:15 -05:00
Dmitry Butyugin 1b1a97e8bd shaper_calibrate: Choose input shapers accounting smoothing
Improved algorithm to choose the 'optimal' shaper frequency taking
shaper smoothing into account. This may choose a frequency with
slightly more vibrations but less smoothing. Also allow users to
limit the maximum input shaper smoothing.

Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2020-12-22 18:37:41 -05:00
Kevin O'Connor a637c2f110 heaters: Fix TEMPERATURE_WAIT command with extruder and heater_bed
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-22 15:22:13 -05:00
Kevin O'Connor f84a570dde temperature_mcu: Fix slope on stm32f070
The stm32f070 has a negative temperature slope.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-19 11:19:44 -05:00