Move bdpressure_check.py and bdp_guard.py to the bd_pressure repo

Both now live in the fork https://github.com/MangaValk/bd_pressure
(klipper/, branch main, upstream PR markniu/bd_pressure#13), installed by
its klipper/install.sh and its own Moonraker update_manager entry. The fork's
bdpressure_check.py also reads the v2 firmware diagnostics. bdp_touch.py
stays here. Docs and comments point to the bd_pressure repo.

install.sh only links the files it has, so after this update it no longer
overwrites the bd_pressure links. Run ~/bd_pressure/klipper/install.sh
before updating, or the two links are left dangling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-11-07 16:52:36 +01:00
1 parent cd1cd7ca47
commit dae8afac20
7 files changed
+19 -424

No files matched your search

+5 -3
View File
@@ -10,8 +10,10 @@ Voron 2.4 350, Klipper + Moonraker + Mainsail on a Raspberry Pi 4
(`http://mainsailos.local`, Moonraker API on port 80). AFC Box Turtle with
5 lanes, Blobifier purge bucket, Beacon (Z homing and probing), Nitehawk-SB
toolboard (USB), Leviathan mainboard as USB-CAN bridge, bd_pressure
(load-check firmware, branch `load-check-extension` in
`D:\Claude\bd_pressure-load-check\bd_pressure`), bdwidth (CCD width/motion sensor on USB; switched off: its motion reading
(load-check firmware; `bdpressure.py`, `bdpressure_check.py` and `bdp_guard.py`
come from the fork `https://github.com/MangaValk/bd_pressure`, local clone
`D:\Claude\bd_pressure`, branch `main`, installed on the Pi in `~/bd_pressure`),
bdwidth (CCD width/motion sensor on USB; switched off: its motion reading
stays at 0, its width compensation made the flow jump 77-119% and a USB
dropout once shut down Klipper. The macros work with or without
`[bdwidth fila_width_0]`; clogs and breaks are caught by AFC's buffer fault
@@ -85,7 +87,7 @@ detection, `filament_error_sensitivity`), iHeater chamber heater.
not `action_raise_error` / `RESPOND TYPE=error`, so they also show on the
display. `action_raise_error` aborts while rendering, so an `M117` in the
same macro would never run. No double quotes in `MSG`/`DISPLAY`.
- Nozzle guard (`print/nozzle_guard.cfg`, `extras/bdp_guard.py`): wrap only
- Nozzle guard (`print/nozzle_guard.cfg`, `bdp_guard.py` in the bd_pressure repo): wrap only
moves where nothing may touch the nozzle in `_GUARD_ON PHASE=x` /
`_GUARD_OFF`. Never leave it on across contact homing, extrusion, purges,
the Blobifier park or AFC cuts and loads: in `mode: stop` that is an
+9 -4
View File
@@ -25,7 +25,7 @@ everything below, grouped by topic. Comment out what you do not use there.
| `pause_resume.cfg` | `PAUSE`, `RESUME`, `CANCEL_PRINT`, `M600` (RESUME also handles a running `HEAT_SOAK`, and after a PAUSE purges 40 mm with `BLOBIFIER_CHECKED` first: a failed check keeps the print paused, `RESUME PURGE=0` skips the purge; CANCEL_PRINT runs the same cleanup as `PRINT_END`) | `heating/heat_soak.cfg`, `leds/`, `blobifier/`, `afc/purge_check.cfg` |
| `filament.cfg` | `LOAD_FILAMENT`, `UNLOAD_FILAMENT` | — |
| `homing.cfg` | `HOME`: X/Y, then Z always with Beacon contact (also when already homed); `_Z_CHECK`: stops the print when Klipper's Z and the Beacon reading differ (run in `PRINT_START` after the soak) | Beacon |
| `nozzle_guard.cfg` | `[bdp_guard]`, `_GUARD_ON PHASE=<name>`, `_GUARD_OFF`: bd_pressure watches the nozzle force during print-start moves where nothing should touch it (QGL, Z homing, mesh); `mode: stop` shuts Klipper down on a touch (the brush runs log-only), `mode: log` only reports the peak per phase | `extras/bdp_guard.py` + bd_pressure load-check firmware |
| `nozzle_guard.cfg` | `[bdp_guard]`, `_GUARD_ON PHASE=<name>`, `_GUARD_OFF`: bd_pressure watches the nozzle force during print-start moves where nothing should touch it (QGL, Z homing, mesh); `mode: stop` shuts Klipper down on a touch (the brush runs log-only), `mode: log` only reports the peak per phase | `bdp_guard.py` from the bd_pressure repo + its load-check firmware |
| `test_speed.cfg` | `TEST_SPEED`: skipped-steps test for speed and acceleration | — |
| `idle_timeout.cfg` | `[idle_timeout]`: heaters, chamber heater and motors off | iHeater macros |
| **heating/** | | |
@@ -37,7 +37,7 @@ everything below, grouped by topic. Comment out what you do not use there.
| **afc/** | | |
| `xy_safety_check.cfg` | `AFC_XY_SAFETY_CHECK`, `_AFC_STORE_HOME_REFERENCE`, `AFC_XY_RESUME`: lost-step check around tool changes | `extras/xy_drift.py` (CoreXY) |
| `lane_tools.cfg` | `LANE_FEED_UNTIL_HUB_OPEN`, `LANE_FEED_ABORT` | AFC |
| `purge_check.cfg` | `BLOBIFIER_CHECKED`: checks every AFC purge with bd_pressure (and optionally bdwidth motion); a bd_pressure that does not answer fails the check, `PURGE_CHECK_IGNORE_SENSOR` lets the current print finish without it; when the previous filament (saved `nozzle_last_temp`) needs more than 10°C above the new one, the purge runs at the previous filament's temperature and the nozzle cools back afterwards, so its leftover melts out | Blobifier, AFC, `extras/bdpressure_check.py` + bd_pressure load-check firmware, `extras/bdwidth_status.py` |
| `purge_check.cfg` | `BLOBIFIER_CHECKED`: checks every AFC purge with bd_pressure (and optionally bdwidth motion); a bd_pressure that does not answer fails the check, `PURGE_CHECK_IGNORE_SENSOR` lets the current print finish without it; when the previous filament (saved `nozzle_last_temp`) needs more than 10°C above the new one, the purge runs at the previous filament's temperature and the nozzle cools back afterwards, so its leftover melts out | Blobifier, AFC, `bdpressure_check.py` from the bd_pressure repo + its load-check firmware, `extras/bdwidth_status.py` |
| `flex_lanes.cfg` | Lanes holding TPU/TPE (material from Spoolman) get slower long moves (50 mm/s, AFC's minimum) through the tube; back to the configured speed when the lane holds something else. Polls every 5 s, reapplies after a restart. The last stretch into the extruder (`tool_load_speed`) stays as configured | AFC |
| `purge_until_empty.cfg` | `PURGE_UNTIL_EMPTY`: purges a snapped filament out until there is no more nozzle pressure | same as `purge_check.cfg` |
| **pressure_advance/** | | |
@@ -61,11 +61,16 @@ everything below, grouped by topic. Comment out what you do not use there.
|---|---|
| `xy_drift.py` | `AFC_XY_SAFETY_CHECK`: measures lost XY steps from the stepper step counts at the endstop triggers (CoreXY). The toolhead position after homing cannot show lost steps. |
| `bdwidth_status.py` | exposes bdwidth's motion counter and width to macros (`present: False` with neutral values when no bdwidth is configured, so the macros also work without it), and keeps a USB dropout of bdwidth (port: usb) from shutting down Klipper: the read is retried every 10 s and the port reopened |
| `bdpressure_check.py` | bd_pressure load check (`BDP_CHECK_START/STOP/QUERY`). Needs the load-check firmware from the bd_pressure `load-check-extension` branch; on stock firmware it reports "not available" and does nothing. Also reports how many readings the last `PA_CALIBRATE` got (`pa_points`, `pa_distinct`), used to reject runs with a silent or stuck sensor. |
| `bdp_guard.py` | nozzle collision guard: while armed (`BDP_GUARD_ARM/DISARM/QUERY`) reads the bd_pressure force every 20 ms over I2C and, in stop mode, shuts Klipper down when it stays above the threshold. Reports reads, peak and errors per phase in the console and klippy.log. When it arms and finds the sensor still in PA mode (an emergency stop during `PA_CALIBRATE`; `FIRMWARE_RESTART` does not reset the sensor), it switches it to probe mode and takes a new zero first. Puts a lock on the sensor's I2C connection that `bdpressure.py` and `bdpressure_check.py` also go through (Klipper allows one I2C request at a time per device). Needs the load-check firmware. |
| `bdp_touch.py` | `BDP_TOUCH`: lowers the nozzle in one slow continuous move (drip mode, like a homing move) while reading the bd_pressure force as fast as I2C allows (its endstop output is not wired), stops at a force limit (default 60) or 0.5 mm below the start, then lifts back; it must be one quick press, because the sensor re-zeros itself while the force looks steady; reports the height where the force reaches the threshold and the zero-force height from a line fit, and logs the whole curve to klippy.log. `_TOUCH_COMPARE`: alternates that with Beacon's contact probe. Refuses while the bdp_guard is armed or the sensor is in PA mode. Needs the load-check firmware. |
| `mesh_check.py` | `BED_MESH_CHECK`: fits a smooth surface to the loaded mesh and reports the height range and every area further from it than the limit, with its position. Only reads the mesh. Needs numpy (Beacon needs it too). |
The bd_pressure load check (`bdpressure_check.py`: `BDP_CHECK_START/STOP/QUERY`,
`pa_points`/`pa_distinct`) and nozzle guard (`bdp_guard.py`: `BDP_GUARD_ARM/DISARM/QUERY`)
moved to the bd_pressure repo (`https://github.com/MangaValk/bd_pressure`, folder
`klipper/`, docs in `klipper/load_check/README.md`). Install that repo with its
`klipper/install.sh` and its own `[update_manager bd_pressure]` entry; the macros
here (`purge_check.cfg`, `nozzle_guard.cfg`, `bd_pa_spoolman.cfg`) still use them.
### Scripts (`scripts/`)
Firmware update scripts for all MCUs (Klipper and Katapult). They contain
-283
View File
@@ -1,283 +0,0 @@
# Nozzle collision guard with bd_pressure (load-check firmware extension).
#
# The bd_pressure strain gauge sees the force on the nozzle. The load-check
# firmware keeps the current force minus its baseline in register 64-65
# (chk_delta), also outside a load check; it is the same value the endstop
# output switches on (|delta| >= thrhold). While the guard is armed this
# module reads it every INTERVAL seconds. In stop mode, SAMPLES reads in a
# row at or above THRESHOLD shut Klipper down at once (like M112, without
# waiting for the running macro to finish).
#
# Every ARM (also a phase switch) first sets a new zero (register 52), so
# slow pressure changes before the guarded moves do not count (TPU in a
# nozzle that heats up keeps changing pressure for minutes).
#
# Arm it only around moves where the nozzle must not touch anything: not
# around contact homing, extrusion, purges or AFC cuts and loads, which
# press on the nozzle on purpose. ARM and DISARM act immediately, not in
# the move queue: put an M400 before them (the _GUARD_ON/_GUARD_OFF macros
# do this).
#
# Install: copy to ~/klipper/klippy/extras/bdp_guard.py and add
#
# [bdp_guard]
# sensor: bd_pa # name after "bdpressure" in [bdpressure bd_pa]
# mode: log # log: only measure; stop: shut down on a touch
# threshold: 30 # |delta| that counts as a touch
# samples: 3 # reads in a row at or above threshold
# interval: 0.02 # seconds between reads while armed
# timeout: 600 # disarm by itself when a phase runs this long
# # (a macro that failed before its DISARM)
#
# Commands:
# BDP_GUARD_ARM PHASE=<name> [MODE=log|stop] start (or switch phase)
# BDP_GUARD_DISARM stop and report the phase
# BDP_GUARD_QUERY report without stopping
#
# Each phase reports (console and klippy.log, "bdp_guard:") the reads, the
# peak |delta|, the longest run of reads at or above threshold and the
# read errors, so a log-mode print start shows what each phase normally
# measures before stop mode is switched on.
#
# Status (printer.bdp_guard): armed, mode, phase, threshold, samples, peak,
# longest_run, reads, errors, available
import logging
REG_MODE = 48 # status_clk: 7 = PA mode, 2 = probe (endstop) mode
REG_RESET_PROBE = 52 # set_normal: write 1 = take the current reading as zero
MODE_PA = 7
REG_EXT = 54 # extension marker 0xBD + version
REG_DELTA = 64 # chk_delta, int16 little-endian
EXT_MAGIC = 0xBD
MODES = ('log', 'stop')
# Klipper allows only one I2C request at a time per device: a second one
# while the first waits for its answer raises KeyError ('i2c_response', oid)
# and shuts Klipper down. The guard reads from a timer while G-code runs,
# and bdpressure.py writes the probe mode at every homing move (seen: G28
# during an armed guard), so all transfers of the sensor take this lock.
# The guard puts it on the sensor object at connect; bdpressure and
# bdpressure_check use sensor.i2c and so get it too.
class LockedI2C:
def __init__(self, i2c, mutex):
self._i2c = i2c
self._mutex = mutex
def i2c_read(self, *args, **kwargs):
with self._mutex:
return self._i2c.i2c_read(*args, **kwargs)
def i2c_write(self, *args, **kwargs):
with self._mutex:
return self._i2c.i2c_write(*args, **kwargs)
def i2c_write_wait_ack(self, *args, **kwargs):
with self._mutex:
return self._i2c.i2c_write_wait_ack(*args, **kwargs)
def i2c_transfer(self, *args, **kwargs):
with self._mutex:
return self._i2c.i2c_transfer(*args, **kwargs)
def __getattr__(self, name):
return getattr(self._i2c, name)
class BDPGuard:
def __init__(self, config):
self.printer = config.get_printer()
self.reactor = self.printer.get_reactor()
self.sensor_name = 'bdpressure ' + config.get('sensor', 'bd_pa')
self.mode = config.getchoice('mode', {m: m for m in MODES}, 'log')
self.threshold = config.getint('threshold', 30, minval=1)
self.samples = config.getint('samples', 3, minval=1)
self.interval = config.getfloat('interval', 0.02, minval=0.005)
self.timeout = config.getfloat('timeout', 600., minval=10.)
self.armed_until = 0.
self.sensor = self.i2c = None
self.available = False
self.timer = None
self.zeroing = False
self.phase_mode = self.mode
self._reset_phase('')
self.printer.register_event_handler('klippy:connect',
self._handle_connect)
self.printer.register_event_handler('klippy:shutdown',
self._handle_shutdown)
gcode = self.printer.lookup_object('gcode')
gcode.register_command('BDP_GUARD_ARM', self.cmd_ARM,
desc="Arm the bd_pressure nozzle collision guard")
gcode.register_command('BDP_GUARD_DISARM', self.cmd_DISARM,
desc="Disarm the bd_pressure nozzle collision guard")
gcode.register_command('BDP_GUARD_QUERY', self.cmd_QUERY,
desc="Report the bd_pressure guard values")
def _handle_connect(self):
self.sensor = self.printer.lookup_object(self.sensor_name, None)
i2c = getattr(self.sensor, 'i2c', None)
if i2c is not None and not isinstance(i2c, LockedI2C):
# Every user of the sensor (bdpressure, bdpressure_check, this
# guard) now goes through one lock, see LockedI2C
i2c = LockedI2C(i2c, self.reactor.mutex())
self.sensor.i2c = i2c
self.i2c = i2c
def _handle_shutdown(self):
self._stop_timer()
def _reset_phase(self, phase):
self.phase = phase
self.peak = self.longest_run = self.run = 0
self.reads = self.errors = 0
def _check_available(self):
if self.i2c is None:
return False
try:
data = bytearray(self.i2c.i2c_read([REG_EXT], 2)['response'])
except Exception:
logging.exception("bdp_guard: reading the extension marker failed")
return False
return len(data) == 2 and data[0] == EXT_MAGIC and data[1] >= 1
def _ensure_probe_mode(self, gcmd):
# An emergency stop during PA_CALIBRATE leaves the sensor in PA mode
# (FIRMWARE_RESTART does not reset it); bdpressure.py only switches
# it back at the next homing move, after the guard is armed. In PA
# mode the delta means nothing and could trip the guard. Register 48
# is the mode: 7 = PA, 2 = probe.
if getattr(self.sensor, 'last_state', 0):
return # a calibration runs, leave the sensor alone
try:
mode = bytearray(self.i2c.i2c_read([REG_MODE], 1)['response'])
if len(mode) != 1 or mode[0] != MODE_PA:
return
self.sensor.set_probe_mode()
# new samples at the probe sample rate, then a fresh baseline
self.reactor.pause(self.reactor.monotonic() + 0.5)
self.i2c.i2c_write([REG_RESET_PROBE, 1])
self.reactor.pause(self.reactor.monotonic() + 0.3)
except Exception:
logging.exception("bdp_guard: switching the sensor to probe mode failed")
return
msg = ("BDP_GUARD: bd_pressure was still in PA mode (stopped "
"calibration?), switched to probe mode")
logging.info(msg)
gcmd.respond_info(msg)
def _rezero(self):
# A fresh zero at every ARM: only force that appears during the
# guarded moves counts, not slow changes before them. Seen with TPU
# in a nozzle heating to 150C: the pressure kept rising (+43) or
# falling as it oozed (-56) for minutes, faster than the sensor's
# own baseline update (only when steady, about every 7 s), and
# stopped the printer at the start of a phase with the nozzle in
# the air. ARM comes after M400, with the nozzle clear of
# everything, so this does not hide a real touch.
self.zeroing = True
try:
self.i2c.i2c_write([REG_RESET_PROBE, 1])
self.reactor.pause(self.reactor.monotonic() + 0.2)
except Exception:
logging.exception("bdp_guard: setting a new zero failed")
self.zeroing = False
def _stop_timer(self):
if self.timer is not None:
self.reactor.unregister_timer(self.timer)
self.timer = None
def _poll(self, eventtime):
# Never raise here: an exception in a timer shuts Klipper down.
try:
if self.printer.is_shutdown():
return self.reactor.NEVER
if eventtime > self.armed_until:
logging.info("bdp_guard: %s armed longer than %.0f s, "
"disarmed (%d reads, peak %d)", self.phase,
self.timeout, self.reads, self.peak)
self._stop_timer()
self.phase = ''
return self.reactor.NEVER
# PA mode (SET_BDPRESSURE START): the delta means nothing then;
# while ARM sets a new zero the readings are in between
if self.zeroing or getattr(self.sensor, 'last_state', 0):
return eventtime + self.interval
data = bytearray(self.i2c.i2c_read([REG_DELTA], 2)['response'])
if len(data) != 2:
self.errors += 1
return eventtime + self.interval
delta = data[0] | (data[1] << 8)
if delta & 0x8000:
delta -= 0x10000
mag = abs(delta)
self.reads += 1
self.peak = max(self.peak, mag)
self.run = self.run + 1 if mag >= self.threshold else 0
self.longest_run = max(self.longest_run, self.run)
if self.run >= self.samples and self.phase_mode == 'stop':
# klippy:shutdown unregisters this timer
self.printer.invoke_shutdown(
"bd_pressure guard: nozzle touched something during %s "
"(delta %d, threshold %d)"
% (self.phase or 'an armed move', delta, self.threshold))
return self.reactor.NEVER
except Exception:
self.errors += 1
if self.errors == 1: # 50 reads/s: only the first per phase
logging.exception("bdp_guard: read failed")
return eventtime + self.interval
def _report(self, gcmd, prefix):
msg = ("%s %s (%s): %d reads, peak %d, longest run >= %d: %d reads, "
"%d errors" % (prefix, self.phase or '-', self.phase_mode,
self.reads, self.peak, self.threshold,
self.longest_run, self.errors))
logging.info("bdp_guard: %s", msg)
gcmd.respond_info(msg)
def cmd_ARM(self, gcmd):
phase = gcmd.get('PHASE', 'armed')
mode = gcmd.get('MODE', self.mode).lower()
if mode not in MODES:
raise gcmd.error("BDP_GUARD_ARM: MODE must be log or stop")
if self.timer is not None:
self._report(gcmd, "BDP_GUARD")
else:
self.available = self._check_available()
if not self.available:
gcmd.respond_info("BDP_GUARD_ARM: bd_pressure load-check "
"extension not found, guard not armed")
return
self._ensure_probe_mode(gcmd)
self._rezero()
self.phase_mode = mode
self._reset_phase(phase)
self.armed_until = self.reactor.monotonic() + self.timeout
if self.timer is None:
self.timer = self.reactor.register_timer(
self._poll, self.reactor.monotonic() + self.interval)
def cmd_DISARM(self, gcmd):
if self.timer is None:
return
self._stop_timer()
self._report(gcmd, "BDP_GUARD")
self.phase = ''
def cmd_QUERY(self, gcmd):
self._report(gcmd, "BDP_GUARD_QUERY" + (" armed" if self.timer
else " not armed"))
def get_status(self, eventtime):
return {'armed': self.timer is not None, 'mode': self.phase_mode,
'phase': self.phase, 'threshold': self.threshold,
'samples': self.samples, 'peak': self.peak,
'longest_run': self.longest_run, 'reads': self.reads,
'errors': self.errors, 'available': self.available}
def load_config(config):
return BDPGuard(config)
-130
View File
@@ -1,130 +0,0 @@
# Load check using the bd_pressure firmware extension (bdp_check_ext.patch).
#
# Uses the I2C connection the existing [bdpressure <name>] section already
# set up. Before writing anything it reads the extension marker (bytes
# 54-55 = 0xBD + version 1 or 2). On stock firmware the marker is missing and every
# command only reports "not available": nothing is written, because
# writing past the stock register table would land in the sensor's RAM.
#
# Install: copy to ~/klipper/klippy/extras/bdpressure_check.py
#
# Config:
# [bdpressure_check]
# sensor: bd_pa # name after "bdpressure" in [bdpressure bd_pa]
#
# Commands (run them after M400, they act immediately, not in the move queue):
# BDP_CHECK_START freeze the baseline and start measuring
# BDP_CHECK_STOP stop measuring and read the result
# BDP_CHECK_QUERY read the current values without stopping
#
# Status (printer.bdpressure_check), updated by the commands above:
# available, running, peak, above_ms, longest_ms, delta
# pa_points, pa_distinct - readings the [bdpressure] module collected in
# its last PA_CALIBRATE, and how many of them differ (read
# from that module, not from the sensor). A sensor that
# stops answering gives few points; one that hangs repeats
# the same reading. LANE_CALIBRATE_PA rejects such runs.
REG_EXT = 54 # first byte of the extension
REG_CTRL = 56
EXT_LEN = 12 # bytes 54-65, the same in version 1 and 2
EXT_MAGIC = 0xBD
# Version 2 (load-check firmware 20261015 and later) only adds diagnostics
# at 66-71. Accepting only version 1 made the purge check report the sensor
# as not answering after the firmware update.
EXT_VERSIONS = (1, 2)
class BDPressureCheck:
def __init__(self, config):
self.printer = config.get_printer()
self.sensor_name = 'bdpressure ' + config.get('sensor', 'bd_pa')
self.sensor = None
self.status = {'available': False, 'running': False, 'peak': 0,
'above_ms': 0, 'longest_ms': 0, 'delta': 0}
self.printer.register_event_handler('klippy:connect',
self._handle_connect)
gcode = self.printer.lookup_object('gcode')
gcode.register_command('BDP_CHECK_START', self.cmd_START,
desc="Start a bd_pressure load check")
gcode.register_command('BDP_CHECK_STOP', self.cmd_STOP,
desc="Stop the bd_pressure load check and read it")
gcode.register_command('BDP_CHECK_QUERY', self.cmd_QUERY,
desc="Read the bd_pressure load check values")
def _handle_connect(self):
self.sensor = self.printer.lookup_object(self.sensor_name)
@property
def i2c(self):
# Looked up at every use: bdp_guard replaces the sensor's i2c with a
# locked wrapper at connect, possibly after this module's connect.
return getattr(self.sensor, 'i2c', None)
def _read(self):
if self.i2c is None:
self.status['available'] = False
return False
data = bytearray(self.i2c.i2c_read([REG_EXT], EXT_LEN)['response'])
if (len(data) < EXT_LEN or data[0] != EXT_MAGIC
or data[1] not in EXT_VERSIONS):
self.status['available'] = False
return False
u16 = lambda i: data[i] | (data[i + 1] << 8)
delta = u16(10)
self.status.update({
'available': True,
'running': bool(data[3] & 1),
'peak': u16(4),
'above_ms': u16(6),
'longest_ms': u16(8),
'delta': delta - 0x10000 if delta & 0x8000 else delta,
})
return True
def _respond(self, gcmd, prefix):
s = self.status
if not s['available']:
gcmd.respond_info("%s: bd_pressure check extension not found "
"(stock firmware?), nothing done" % prefix)
return
gcmd.respond_info("%s: running=%d peak=%d above=%d ms longest=%d ms "
"delta=%d" % (prefix, s['running'], s['peak'],
s['above_ms'], s['longest_ms'],
s['delta']))
def cmd_START(self, gcmd):
# The values read here are still the previous check's, so only
# confirm the start instead of printing them.
if self._read():
self.i2c.i2c_write([REG_CTRL, 1])
self.status.update({'running': True, 'peak': 0, 'above_ms': 0,
'longest_ms': 0})
gcmd.respond_info("BDP_CHECK_START: started")
return
self._respond(gcmd, "BDP_CHECK_START")
def cmd_STOP(self, gcmd):
if self._read():
self.i2c.i2c_write([REG_CTRL, 0])
self._read()
self._respond(gcmd, "BDP_CHECK_STOP")
def cmd_QUERY(self, gcmd):
self._read()
self._respond(gcmd, "BDP_CHECK_QUERY")
def get_status(self, eventtime):
status = dict(self.status)
# [val, res, lk, rk, Hk, Ha] per reading, see bdpressure.py
try:
data = list(getattr(self.sensor, 'PA_data', None) or [])
status['pa_points'] = len(data)
status['pa_distinct'] = len(set(tuple(d[1:]) for d in data))
except Exception:
status['pa_points'] = status['pa_distinct'] = -1
return status
def load_config(config):
return BDPressureCheck(config)
+2 -1
View File
@@ -12,7 +12,8 @@
#
# Needs: bdwidth_status.py in ~/klipper/klippy/extras/
# bdpressure_check.py in ~/klipper/klippy/extras/ (optional)
# (klipper/install.sh links both; guide: klipper/load_check/afc_blobifier/README.md)
# (this repo's install.sh links bdwidth_status.py; bdpressure_check.py
# comes from the bd_pressure repo, its klipper/install.sh links it)
# Hook: in [AFC] (AFC/AFC.cfg) change poop_cmd: BLOBIFIER
# to poop_cmd: BLOBIFIER_CHECKED
#
+1 -1
View File
@@ -20,7 +20,7 @@
# Printing
[include print/pause_resume.cfg]
[include print/filament.cfg]
[include print/nozzle_guard.cfg] # bd_pressure nozzle collision guard (needs extras/bdp_guard.py)
[include print/nozzle_guard.cfg] # bd_pressure nozzle collision guard (needs bdp_guard.py, bd_pressure repo)
[include print/homing.cfg]
[include print/idle_timeout.cfg]
[include print/print_start_end.cfg]
+2 -2
View File
@@ -1,6 +1,6 @@
# Nozzle collision guard: bd_pressure watches the nozzle force during moves
# that must not touch anything (needs extras/bdp_guard.py and the bd_pressure
# load-check firmware). See extras/bdp_guard.py.
# that must not touch anything (needs bdp_guard.py from the bd_pressure repo,
# klipper/, and its load-check firmware). See klipper/load_check/README.md there.
#
# mode: stop shuts Klipper down on a touch; log only measures and reports
# each phase (console and klippy.log, "bdp_guard:"). A phase can override it