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>
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>
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>
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>
Temporarily postpone loading the CAN module so that moonraker (and
similar) can improve upgrade scripts.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Add support for automatically calculating the internal step_distance
from new config parameters - rotation_distance, microsteps,
full_steps_per_rotation, and gear_ratio.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The previous init sequence relied on the display ignoring commands if
they are sent faster than 40us. Some displays may not have this
limit.
Rework the init to make it more robust to command transmission times.
The new init should still transition the display into 4-bit mode even
if the display processes commands faster than 40us.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The digital output commands implement a subset of the software pwm
commands. Change the host code to just use the software pwm commands
and simplify the micro-controller code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
- remove lot of helper methods
- differentiate class instantiate from config or directly
- don't use 'enable' template rendering when static value is used.
- new element 'disabled'
- other internal adjustments
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
Don't use the reactor eventtime to schedule micro-controller commands
as that time may have low accuracy.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't use the reactor eventtime to schedule micro-controller commands
as that time may have low accuracy.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Writes to the max31856 chip use "burst mode", so only one address
during the initialization sequence can be sent. This fixes erroneous
"Cold Junction Fault" errors.
Reported by @NBouquain.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add an 'mcu' option to the board_pins config and use that to specify
the name of the mcu to apply the aliases to. Support applying the
aliases to multiple mcus.
Add support for any number of options starting with an "aliases_"
prefix.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move all the config reference information from files in the config/
directory to a new Config_Reference.md document.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Queue updates so that delays between updates are properly applied.
This fixes macros that would blink LEDs by pausing between update
commands.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Users may use this action to call methods registered by a webhooks client from a command template.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The previous code calculates each step time via an "exponential
search" followed by a "false position with Illinois algorithm" search.
Replace with a "secant method" with "bounds check" search. This
simplifies the code, improves the performance, and does a better job
of finding steps near a direction change.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
When in debug output mode, make sure to register the fd correctly.
Otherwise, the poll() call will use the 0 fd which could cause random
results.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If the mcu config section is omitted, it leads to confusing error
messages. Don't default the serial config option to /dev/ttyS0 to
improve the error reporting.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It is only valid to call raise_probe() when the toolhead is not
moving. Make sure to call sync_print_time() from multi_probe_end() to
ensure that. This fixes a bug that could cause the Z axis steppers to
lose their position when "stow_on_each_sample=False".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Avoid using the absolute E position when calculating pressure advance
as that position can grow arbitrarily large, which can result in
"numerical stability" problems. That instability could eventually
lead to internal errors during step compression.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some RPi0 users were reporting "timer too close" errors due to pwm pin
resets - increase the time the host has to complete the startup to
avoid this.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
On a reset, the mcu.py code may have sent an initialization message to
the bltouch, which needs time to complete. Add additional time during
the bltouch setup to avoid a race with these two times. This avoids
some "timer too close" errors that users of fast host machines were
reporting.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The M117 command parser discards the last character of the message
whenever the M117 command does not begin the line and there is no *xx
checksum, e.g.
N0 M117 Look at me
causes the banner area of the printer screen to display "Look at m".
This patch only trims the checksum when one is found to trim.
Signed-Off-By: Jonathan Pickard <jhp@adjustablelabs.info>
Add support for performing Python gc work only from the main reactor
thread and only when it appears the main thread is idle.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Explicitly run the python garbage collector on a restart. This cleans
up memory from the previous session.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make sure to terminate any greenlets that are in a pause() state.
This is necessary to ensure the reactor can be deallocated.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The existence of a __del__() method prevents deallocation on python2
if there are circular references. Replace the __del__() method with a
new finalize() call and arrange for it to be called when the main
reactor is released.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The existence of a __del__() method prevents deallocation on python2
if there are circular references. Just remove the method as
disconnect() should already be called directly.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The existence of a __del__() method prevents deallocation on python2
if there are circular references. Just remove the method as
disconnect() should already be called directly.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>