6409 Commits
Author SHA1 Message Date
Kevin O'Connor c63b29510b docs: Minor wording improvement to PID_CALIBRATE notice in Config_Changes.md
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-10-18 22:58:12 -04:00
Kevin O'Connor e81223416c docs: Add more context to PID_CALIBRATE change in Config_Changes.md
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-10-18 22:53:30 -04:00
Timofey Titovets 3ce421bae5 pid_calibrate: Reduce hysteresis 5 -> 2.5
With corrected calculations, the new PID values are a bit loose
in comparison to the old calculations.
Hysteresis in general shifts the output from "real" value towards
some imaginary numbers.
Regardless, for some heaters, large hysteresis can screw up results.
Towards much larger Kd then actually necessary.

Trade it back with reduced hysteresis in half.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-10-18 22:40:40 -04:00
Timofey Titovets f2c06289b7 pid_calibrate: Store peaks in same format as other samples
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-10-18 22:40:40 -04:00
Timofey Titovets c7eb62e0fe pid_calibrate: Use register_mux_command
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-10-18 22:40:40 -04:00
Timofey Titovets e761a2c762 pid_calibrate: Fix Ku formula
Ku = 4d/pi*a
Where `d` and `a` is an amplitude
For power change of 0 -> 1 -> 0
Amplitude is 0.5

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-10-18 22:40:40 -04:00
Uriah Kessman 2d9c7feff2 tmc5262: Add TMC5262 stepper driver
Add SPI access, internal-clock PLL setup, integrated-current-sense
current control, SpreadCycle, temperature reporting, and standard TMC
fault and status helpers. Check the PLL whenever registers are restored
and clear the phase offset when reinitializing the PLL.

Document the new configuration and include a Klippy regression case.
Derived from the GPLv3 TMC5262 driver by Rogerio Goncalves in Kalico.

Signed-off-by: Rogerio Goncalves <rogerlz@gmail.com>
Signed-off-by: Uriah Kessman <fishyfabspnw@gmail.com>
2026-10-18 22:27:41 -04:00
Uriah Kessman 5f031bb9ae tmc: Add a driver initialization callback
Run an optional callback before restoring registers on connect, enable,
and INIT_TMC. Export clear_mcu_phase_offset() so drivers that reset their
phase counter can invalidate the offset without accessing helper state.

Signed-off-by: Uriah Kessman <fishyfabspnw@gmail.com>
2026-10-18 22:27:41 -04:00
Uriah Kessman 1e0f0bd16c tmc: Add driver-specific temperature conversion
Move the TMC2240 ADC conversion into its driver and pass it explicitly
through the common helpers. Extract the ADC field before conversion so
drivers with packed temperature registers can use the same status path.

Signed-off-by: Uriah Kessman <fishyfabspnw@gmail.com>
2026-10-18 22:27:41 -04:00
Maksim Bolgov 9cb99754c0 mcu: Report a normal CommandError if CommandWrapper fails
Signed-off-by: Maksim Bolgov <maksim8024@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-10-13 19:14:19 -04:00
Maksim Bolgov 530a3560e2 serialhdl: Fail pending ack waits on mcu communication timeout
A command waiting for an ack from an mcu that stopped responding never
completes and may hold the gcode mutex. On a communication timeout fail
all current and future raw_send_wait_ack() calls with an error instead.

Signed-off-by: Maksim Bolgov <maksim8024@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-10-13 19:14:19 -04:00
shinanca ede50bafea axis_twist_compensation: fix zeros at the extreme points
Fix zeroes at extreme points.

Signed-off-by: Maxim Sychevoy <maxrainster@gmail.com>
2026-10-13 15:00:47 -04:00
Maksim Bolgov c7d572441f temperature_probe: Store tap params only after calibration starts
_gcode_params was set before the checks, so a rejected command could
change the params of a running or a later calibration.

Signed-off-by: Maksim Bolgov <maksim8024@gmail.com>
2026-10-12 22:07:10 -04:00
Maksim Bolgov cc0bdc1326 temperature_probe: Fix max_temp index in finish_calibration()
cal_samples[-1][0] is the first sample of the last height, equal to
min_temp. Use the last sample so validation covers the calibrated range.

Signed-off-by: Maksim Bolgov <maksim8024@gmail.com>
2026-10-12 22:07:10 -04:00
Maksim Bolgov 9e8e10b93f temperature_probe: Catch errors from auto TEMPERATURE_PROBE_NEXT
An error in the auto-started TEMPERATURE_PROBE_NEXT reached the reactor and
shut down the printer. Log it instead, run_script() already reports it.

Signed-off-by: Maksim Bolgov <maksim8024@gmail.com>
2026-10-12 22:07:10 -04:00
Maksim Bolgov 605dd4aedd temperature_probe: Report an error on a degenerate drift calibration fit
Polynomial2d.fit() raised TypeError when the solver returned None, which
shut down the printer. Raise a gcode error instead.

Signed-off-by: Maksim Bolgov <maksim8024@gmail.com>
2026-10-12 22:07:10 -04:00
Maksim Bolgov 96c476e6d0 temperature_probe: Fix sample count check in finish_calibration()
The check used the number of heights, which is always 9, so it never
fired. Count the collected samples instead.

Signed-off-by: Maksim Bolgov <maksim8024@gmail.com>
2026-10-12 22:07:10 -04:00
Maksim Bolgov bf4806b86a temperature_probe: Fix inverted bulk client return in collect_sample()
The bulk callback returned True after the last sample window, so it was never unregistered.

Signed-off-by: Maksim Bolgov <maksim8024@gmail.com>
2026-10-12 22:07:10 -04:00
Maksim Bolgov 5771e00602 temperature_probe: Abort drift sample collection on sensor outage
Add a timeout for waiting for sensor data. Without it, a sensor outage or
mcu shutdown left collect_sample() waiting forever with the gcode mutex
held, so RESTART and FIRMWARE_RESTART were blocked.

Signed-off-by: Maksim Bolgov <maksim8024@gmail.com>
2026-10-12 22:07:10 -04:00
Lev Voronov 6ea0b349e6 stm32: add PB4/PB5 hardware pwm pins on the stm32f1
TIM3 channels 1 and 2 are available on PB4 and PB5 through the timer's
partial remap.  gpio_peripheral() already programs TIM3_REMAP_PARTIALREMAP
for those two pins, but they were missing from the stm32f1 hardware pwm
table, so a config naming them was rejected as "Not a valid PWM pin".
The stm32f0 and stm32h7 tables already list them.

Signed-off-by: Lev Voronov <minicx@disroot.org>
2026-10-12 20:46:48 -04:00
Timofey Titovets d0a1e275d8 i2c_software: Optimize sda state transitions
We know the SDA state for each write byte.
So, it is possible to set it beforehand.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-10-12 20:24:29 -04:00
Satvik Mishra 6c8e313283 docs: Fix broken internal links and anchors
Several links pointed at heading anchors that no longer exist (renamed
or moved sections), so they did not jump to the intended section.
Update them to the current anchors, and use a relative path for the
sample-pwm-tool.cfg link so it resolves like the other config links.

Signed-off-by: Satvik Mishra <Satvikmishra.ipu146183@maims.ac.in>
2026-10-12 20:15:44 -04:00
Kevin O'Connor e2b99a9159 ar100: Verify SERIAL_BAUD is set correctly
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-10-01 11:31:08 -04:00
Elias Bakken 461c4e3722 ar100: Use serial_irq instead of console_task for processsing messages (#7399)
Utilize the generic code.  The previous code could possibly busy wait
for a long time during console_sendf().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Elias Bakken <elias@iagent.no>
2026-09-30 18:38:23 -04:00
Kevin O'Connor f3897efa43 pru: Utilize timer_dispatch_many_polling()
Convert to timer_dispatch_many_polling() and check for command
activity in the dispatch loop.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-09-30 15:28:36 -04:00
Kevin O'Connor ffde3b27d7 ar100: Utilize timer_dispatch_many_polling()
Convert to timer_dispatch_many_polling() and check for serial activity
in the dispatch loop.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-09-30 15:28:36 -04:00
Kevin O'Connor e562a6db3a timer_irq: Add new timer_dispatch_many_polling()
Add a new variant of timer_dispatch_many() for chips that do not
support hardware irqs, or do not support hardware irqs being enabled
during timer dispatch.  This new variant allows the boards to poll for
events if many timers are run back to back.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-09-30 15:28:36 -04:00
Lev Voronov a9eb1dc980 stm32: run the n32g45x at 144Mhz
The n32g45x defaulted to 128Mhz, which is not reachable from a 12Mhz or
24Mhz crystal: the PLL takes the crystal or half of it, so only exact
multiples of crystal / 2 can be generated, and the build time check in
clock_setup_n32g45x() rejects the rate.  CLOCK_FREQ has no prompt, so a
board with one of those crystals could not be built at all.

Run it at 144Mhz instead, the chip's rated maximum, which is an exact
multiple of half of each of the 8, 12, 16 and 24Mhz crystals.  That
includes usb builds: at 144Mhz the usb prescaler divides by 3 to give
the 48Mhz the peripheral needs, so the separate 96Mhz usb rate is no
longer required.  20Mhz and 25Mhz crystals, which do not give 72Mhz on
an stm32f103 either, still fail at build time.

Signed-off-by: Lev Voronov <minicx@disroot.org>
2026-09-30 15:15:48 -04:00
Florian Hofer ce2ddbab09 hd44780: Make command delay configurable
Add an hd44780_delay config option so the minimum wait time after
sending a command or data byte to the hd44780 chip can be tuned.
Some displays need more than the default 40us. The value is limited
to a maximum of 60us, as the mcu busy-waits for this delay.

Signed-off-by: Florian Hofer <SirDeath81_github@outlook.com>
2026-09-30 15:13:04 -04:00
Koshik Oleg f11a7a5449 sensor_cs1237: fold cs1237_clock_pulses() into the read/write helpers
The bare clock pulses in cs1237_write_config() are indistinguishable
from reading a bit with the result ignored, and the command and config
bytes are always written back to back with the direction-change clock
between them.  Dropping cs1237_clock_pulses() and passing a bit count to
cs1237_write_bits() lets the whole 16 clock command be written in one
call, which makes the bit-banged sequence easier to follow.

No functional change: the same 46 clocks are issued in the same order.

Suggested-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Koshik Oleg <qwertyboy58@gmail.com>
2026-09-30 15:11:08 -04:00
Koshik OlegandAhmed Sheikh eefd197ac5 sensor_cs1237: don't sample the 27th clock as data
The 27th SCLK pulse of a CS1237 conversion frame does not carry
conversion data - per the datasheet it forces DOUT high until the next
conversion is ready.  Its sampled level therefore depends on when the
chip drives the line rather than on the conversion result.

Sampling it as a data bit and requiring it to read back as 1 produces
spurious SERIAL_DATA_DESYNCHRONISED errors on MCUs under load, where
the bit-banged read can be preempted between clocks.  On a toolhead MCU
running the CS1237 at 640sps this yields roughly 30 errors per second,
which makes load_cell_probe unusable - every probe aborts with "Load
cell sensor reported errors while probing".

Still clock all 27 pulses, but discard the last one and base the desync
check on the reserved bit instead.  The update1 bit used for config
verification is preserved.

This is the approach used by the out-of-tree QIDI Q2 driver in
MisterSheikh/Qidi_Q2_Mainline_Klipper, where the 27th clock has been
issued without sampling since f9f6cf0 (Feb 2026) and the reserved-bit
desync check was added in 1ee516d (Aug 2026).  That driver ran reliably
on the same hardware for months, which is what identified the 27th bit
as the difference once the in-tree driver started reporting desyncs.

Co-authored-by: Ahmed Sheikh <ahmed.ali.sheikh1998@gmail.com>
Signed-off-by: Ahmed Sheikh <ahmed.ali.sheikh1998@gmail.com>
Signed-off-by: Koshik Oleg <qwertyboy58@gmail.com>
2026-09-30 15:11:08 -04:00
Elias Bakken 738441794e ar100: Build with -O2 and fix the image size check
Klipper on ar100 is currently built with -O3 optimizations.
-O2 is a reasonable compromise between size and speed. -O3 does
not give any meaningful improvements.

Regarding the size difference, Allwinner A64 has 64 KB of SRAM A2,
and we can use all of it for Klipper. The previous size check
capped the size at 48 KB instead of the 64 KB that is available.

Signed-off-by: Elias Bakken <elias@iagent.no>
2026-09-30 15:08:39 -04:00
Timofey Titovets 7bc4d09465 queuelogger: workaround infinite rollover printing
TimedRotatingFileHandler.doRollover() internally
checks if the name already exists; if it does
it does not advance the rolloverAt
So, the function gets triggered for every emitted log line

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-09-28 14:23:39 -04:00
Thijs Triemstra b413d3abcb docs: fix typos and formatting in Load_Cell.md (#7374)
Corrected typos and formatting inconsistencies in Load_Cell documentation.

Signed-off-by: Thijs Triemstra <info@collab.nl>
2026-09-28 13:08:36 -04:00
Lev Voronov 19ca09d6ee stm32: only calibrate each n32g45x adc block once
gpio_adc_setup() enabled and calibrated an adc block every time one of
its channels was configured.  The n32g455 puts PA0 and PA1 on the same
block, so configuring the second pin recalibrated an adc that was
already running: from then on that block could no longer complete a
conversion for the newly added channel, and the mcu spent its time
polling an adc that never signalled completion.

On a FlashForge AD5M toolhead this left the hotend thermistor reading
0C while the mcu busy time reported in the periodic stats grew by more
than a factor of two.

Enable the clock of the block that is actually needed rather than all
four, and use that clock enable bit to tell whether the block still
needs to be initialised, the way stm32/adc.c uses is_enabled_pclock().

Signed-off-by: Lev Voronov <minicx@disroot.org>
2026-09-28 13:04:28 -04:00
Lev Voronov 781a7ce1d9 stm32: configure the n32g45x adc clocks
The n32g45x adc runs from two clocks: ADCHCLK, divided down from HCLK,
and a separate 1Mhz reference clock, ADC1M.  The driver hardcoded
ADCHCLK to HCLK/16, which its comment shows was picked for a 64Mhz
HCLK, and left ADC1M entirely alone.  At the 144Mhz this chip can run
at that leaves ADCHCLK at 9Mhz, and ADC1M at whatever the reset default
happens to be rather than the 1Mhz the vendor code selects.

Derive the ADCHCLK divisor from CONFIG_CLOCK_FREQ so the adc clock
stays within range at every supported system clock rate, and divide
ADC1M down from the oscillator the pll already uses, so it lands on
1Mhz for any of the supported crystals.

Also match the vendor sequence when starting the adc: select the HCLK
sourced clock mode explicitly instead of relying on the reset value of
CKMOD, and set AD_ON and CAL as individual bits rather than assigning
CTRL2, which discarded the trigger and alignment configuration
ADC_Init() had just written.  Let the adc settle after leaving power
down mode before polling it, as ADC_Enable() does.

Signed-off-by: Lev Voronov <minicx@disroot.org>
2026-09-28 13:04:28 -04:00
Lev Voronov 4bdd32de67 stm32: enable ex mode on the n32g45x
The n32g45x keeps its adc, sdio, qspi, rng, crypto engine, opamp, comp
and can2 behind the "ex mode" bit in PWR_CTRL3.  While that bit is
clear the peripherals stay unclocked and their RCC enable bits do not
even latch: writing all ones to RCC_AHBPCLKEN reads back 0x57, without
any of the ADC1-4 bits, and writing all ones to RCC_APB1PCLKEN leaves
opamp, comp and can2 clear.

Klipper never set it, so gpio_adc_setup() spun forever waiting for the
ADC_FLAG_RDY of an unclocked adc.  The mcu went silent in the middle of
the host's configuration and the host waited for a reply that never
came, which makes this look like a dead board rather than a missing
clock.

Set the bit before configuring any clock, the way the vendor
SystemInit() in system_n32g45x.c does.  The stm32f103 headers Klipper
builds the n32g45x against describe a PWR block with two registers
only, so address the third one directly.

Signed-off-by: Lev Voronov <minicx@disroot.org>
2026-09-28 13:04:28 -04:00
Timofey Titovets 214fdb2877 bed_mesh: fix zero_ref for direct mode
zero_reference_position updates every point in the bed mesh
With direct mode z_matrix is used directly for probe_matrix
and mesh_matrix
Which, in turn, makes compensation applied twice

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-09-27 20:46:35 -04:00
Timofey Titovets cd1b291955 bed_mesh: always verify algorithm
With config like:

[bed_mesh]
mesh_pps: 0,0
algorithm: bicubic

The algorithm direct should be "always" chosen
But it only gets applied/enabled if `need_cfg_update = True`
is triggered

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-09-27 20:46:35 -04:00
Timofey Titovets ce7002bedf docs: Describe TAP errors
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-09-18 22:31:31 -04:00
沐枫 8cdfdd98c0 load_cell: add CS1237 support (#7370)
Signed-off-by: Xiaoyue Cui <2508041672@qq.com>
2026-09-18 22:30:57 -04:00
Kevin O'Connor ad425fc22e docs: Fix spelling error in FAQ.md
Reported by @reitermarkus.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-09-17 12:26:59 -04:00
Timofey Titovets 72b3cdb4e4 probe_eddy_current: Print tap threshold limit
Sometimes it can be necessary to tune the threshold
but it is obscure knowledge that contact_slope_delta
Is basically about the maximum safe value

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-09-16 17:54:23 -04:00
Timofey Titovets e116e6fc86 probe_eddy_current: Update tap guess constant
Guess can fail for specific users and
often outputs about 60% of refine value

Bump it a bit to increase the success probability

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-09-16 17:54:23 -04:00
Timofey Titovets 20ce4f0aae probe_eddy_current: Remove not possible error
Detection of a too-early trigger is defined as a time window size
but because we require at least an end_time - start_time window
It is always true as long as there are no lost samples

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-09-16 17:52:38 -04:00
Timofey Titovets ec188e0ba3 probe_eddy_current: Output Z value if tap failed
Insufficient slope: a bit of an obscure error.
Add a slightly friendlier output with Z where
tap failed

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-09-16 17:52:38 -04:00
Timofey Titovets 683ab828f0 temperature_probe: Forward gcmd params to probe
After implementation of tap over retraction data
Tap only uses args passed to the gcmd
It is not viable to write and pass every possible arg
So, encode and pass args used in the calibration start

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-09-16 17:46:08 -04:00
Kevin O'Connor 9871eeef13 docs: Note TEMPERATURE_PROBE_CALIBRATE MANUAL_METHOD in Config_Changes.md
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2026-09-15 11:14:11 -04:00
Timofey Titovets 8576d75511 manual_probe: Handle probe/finalize callback exceptions
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-09-15 11:10:06 -04:00
Timofey Titovets 7597e2bd6a temperature_probe: Use new MANUAL_METHOD instead of METHOD
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2026-09-15 11:10:06 -04:00