Commit Graph

1993 Commits

Author SHA1 Message Date
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