Commit Graph

3643 Commits

Author SHA1 Message Date
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 ddb795bccc logextract: Improve handling of TMC UART read/write register commands
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-28 17:15:29 -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 a1a7b5e480 logextract: Add helper to decode tmcuart messages
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-28 16:18:09 -05:00
Oleksii Zelivianskyi 9a0e1e9bd4
config: fan pin number correction for Robin Nano 3 (#4005)
There are two fan pins on Robin Nano 3 and the fan1 pin is PC14, not PB1.
PB1 pin that was in config example is used for the fan2 output.

Signed-off-by: Oleksii Zelivianskyi <alexeyzel@gmail.com>
2021-02-28 16:17:21 -05:00
FrY Sennberg 1c1c517913
confifg: Update printer-flsun-q5-2020.cfg (#4000)
we just found a small problem: Some people have slightly higher endstop positions, which caused them to have a move out of range during probe calibrate. 

Signed-off-by: Christoph Frei <fryakatkop@gmail.com>
2021-02-28 09:59:20 -05:00
Oleksii Zelivianskyi 9df07530c6
config: EXP2 header pin correction in Robin Nano 3 (#3997)
According to Robin Nano v3 pinout the correct pins for:
- EXP2_4 is PE10
- EXP2_6 is PA7

Signed-off-by: Oleksii Zelivianskyi <alexeyzel@gmail.com>
2021-02-28 09:57:53 -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
Stefan Dej 6b6ab45bac
docs: Use BME280 (uppercase) in Config_Reference.md (#3896)
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2021-02-22 15:42:14 -05:00
Kevin O'Connor a1072be7eb test: Add printer-flsun-q5-2020.cfg to printers.test and minor changes
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-22 15:29:34 -05:00
FrY Sennberg 8f52816419
config: add Flsun Q5 config (#3915)
In cooperation with chaosdrucker

Signed-off-by:  Christoph Frei <fryakatkop@gmail.com>
2021-02-22 15:26:03 -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 7e21350989 config: Rename generic-mks-robin-nano.cfg to generic-mks-robin-nano-v1.cfg
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-20 10:17:16 -05:00
Kevin O'Connor 83552f6ea6 config: Add example generic-mks-robin-nano-v2.cfg config
Reported by @mks-viva.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-20 10:17:16 -05:00
Kevin O'Connor 023eeceb2a config: Add example generic-mks-robin-nano-v3.cfg config
Reported by @mks-viva.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-20 10:17:16 -05:00
Kevin O'Connor c4edc7d946 stm32: Add support for 48KiB bootloaders
Reported by @mks-viva.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-20 09:37:43 -05:00
Kevin O'Connor 0a813f2805 scripts: Fix typo in install-centos.sh
Reported by @fishbone222.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-20 09:27:45 -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
Kevin O'Connor 267a2f3a38 stm32: Optimize stm32f401 peripheral clock
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-19 12:19:32 -05:00
Arkadiusz Raj 90ffa0685f stm32: stm32f401 pll_freq updates
Signed-off-by: Arkadiusz Raj <arek.raj@gmail.com>
2021-02-19 12:15:44 -05:00