Repository navigation
Conversation
Add a transport for cutters that take their commands over a BLE GATT
service, such as the Silhouette Cameo 4. It uses bleak, running on the
application's asyncio event loop. Writes are serialized so commands
stay ordered, and status notifications are fed to protocol.data_received.
A BLE connect takes a while, and each jog asks to connect while one is
still running, so concurrent requests share the connect in progress;
otherwise two clients end up attached to one machine.
The service and characteristics are set by the transport config rather
than hard coded. Drivers provide them under
default_config['connection']['ble']: service_uuid and write_uuid are
required, notify_uuid is optional for machines that report status.
Nothing is detected from the device. They are not shown in the settings
view; the module docstring explains how to find the values for a new
cutter.
Cameo 4 gains 'ble' alongside 'printer' with its values, taken from a
GATT dump of a Cameo 4 Plus. Its service has two characteristics with
identical write/indicate properties; only testing showed which one
reports status.
Two settings are needed to make a Cameo respond, and the Cameo 4 driver
turns both on:
- writes must be made with a response. The machine ignores
write-without-response entirely.
- each write must end with ETX. The GPGL protocol puts ETX before each
command, so the latest one is not run until the next is sent.
The scan is filtered by name so the list shows cutters instead of every
phone and TV nearby. A BLE connection can only be made to a device that
is advertising, so connecting always finds the device by a scan first,
even with a saved address. A device connected elsewhere stops
advertising, and the error says so.
Tested against a Cameo 4 Plus: connects, homes, and reports busy/ready
status back.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Cameo 4 Plus is the 15" model of the Cameo 4. It takes the same commands and has the same BLE service and characteristics (checked on a Cameo 4 Plus, which is where the Cameo 4 values came from), so only the cutting width differs: 38.1cm. Rather than copy the Cameo 4 entry, it is moved into a Cameo4Driver enamldef that both models declare, the Plus overriding model and length. Overrides replace an attribute whole, so a variant that needs a different default_config has to restate it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Cameo answers queries (FG for its name, ESC ENQ for its state, ESC NAK for the tools loaded) on a different characteristic from the one it reports status on, and the transport only subscribed to the status one, so a protocol could send a query but never see the answer. Add read_uuid for the reply characteristic. Replies on it go to protocol.data_received and last_read, like a serial port's input. The status characteristic is still subscribed but now only logged: the machine sends "1" (busy) and "0"/"2" (ready, with or without media) unasked whenever it moves, and passing those on would let a protocol take an unrelated "busy" as the answer to its query. A protocol that wants the state asks with ESC ENQ, which works the same over USB. A machine with no read_uuid answers on notify_uuid, which then stays the reply stream as before. Cameo 4 gets read_uuid 8dcf199a-..., found by subscribing to both characteristics on a Cameo 4 Plus and sending each query. The docstring's GATT table and status values are corrected to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Terminating each command with ETX is a GPGL matter, not a BLE one, so it moves from the BLE transport config to a new GPGLConfig, with a checkbox in the protocol settings. The Cameo 4 driver sets it under protocol/gpgl, and it now also applies over USB. The ETX characters GPGL already puts before each command were raw control characters in the source; they are written as \x03 escapes now so they can be seen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On macOS a checkbox is laid out at a smaller size than it is drawn, leaving room for its focus ring, so in a container with no padding the widget runs past the container's edge and is clipped: 9 px at the right of both checkboxes here, and 4 px at the bottom of the last. Pad those containers by as much. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inkcut sends a job one command per write, with delays between them estimated from the speed setting. Over BLE each write takes ~60 ms to be acknowledged whatever its size, so a curve made of 0.5 mm steps stops after every step: the Cameo draws faster than single commands arrive. With flow control on, a job's commands go out in writes of up to 180 bytes, each ending with an FG query. The Cameo answers a query only once it reaches it in its queue, after the commands before it, so the answers show how far it has got. At most 8 batches are left unanswered, which keeps its buffer fed without overfilling it, and the estimated delays are turned off. At the end of a job the protocol waits for the last answer, since disconnecting clears what the machine has yet to run. Nothing is sent while the Cameo is paused, as it silently discards what arrives then. The protocol checks its state (ESC ENQ) before each batch and also stops as soon as the machine reports a pause unasked, which the BLE transport now passes to the protocol. Batches still unanswered once the machine sits idle are logged and no longer waited on, so a job cannot hang. Batching only applies during a job, so jogging still sends each move at once, and not on spooled connections, which never answer. It is off by default and the Cameo 4 driver turns it on. DeviceProtocol gains start_job(), controls_flow() and status_received() for this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Cameo 4's AutoBlade sets its own depth: selecting tool holder 1 (J1) and sending TF<depth> makes the machine tap the blade against a post until it turns to that depth. GPGLConfig gains autoblade, to do this at the start of each job, and autoblade_depth (0-10, as on the blade). Before setting it the protocol asks which tools are loaded (ESC NAK) and skips it if holder 1 holds something else; a machine that does not answer gets the commands anyway. GPGL machines take force and speed on their own scales rather than Inkcut's grams and in/s, so the config also gains a scale for each, which drivers set: the Cameo 4 takes force in 7 g units up to 33 and speed in 100 mm/s units up to 30 (per py_silhouette). Without a scale both go out unconverted, as before. A new Cut settings pane, docked on the left, shows the settings that change with the material: speed and force (the device's own config, also in the device dialog), and for GPGL machines the tools loaded and the AutoBlade depth, with buttons to refresh the tools and set the depth now. The Cameo 4 driver defaults to settings for standard vinyl: depth 1, force 70 g and speed 20 in/s, which it sends as 10 and 5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lagnat
force-pushed
the
cameo-autoblade
branch
from
November 27, 2026 20:55
0c00ff4 to
22ef6ee
Compare
lagnat
marked this pull request as draft
November 28, 2026 00:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #452 and #453. Until those are merged their commits show here too; only the last commit, Add AutoBlade depth and machine-unit force and speed for GPGL, is new.
Question for you: is a new pane OK?
This adds a Cut settings pane, docked on the left, for the settings that change with the material. Would you rather these went somewhere else, for example the device settings dialog (where speed and force already are) or the job settings? Happy to move them.
AutoBlade depth
The Silhouette AutoBlade sets its own depth: after
J1(tool holder 1),TF<depth>,1makes the machine tap the blade against a post until it turns to that depth (0–10, as marked on the blade).GPGLConfig.autobladesets the depth at the start of every job;autoblade_depthis the depth.ESC NAK, Cameo 4 and later) and skips it if holder 1 holds a different tool. A machine that does not answer gets the commands anyway.start_job()hook from Add flow control to the GPGL protocol #453, so connecting just to jog does not turn the blade.Force and speed in machine units
Inkcut's force is in grams and its speed in in/s, but GPGL machines take their own scales, which differ between models.
GPGLConfiggains a scale and maximum for each, which drivers set. The Cameo 4 takes force in 7 g units up to 33 and speed in 100 mm/s units up to 30, per py_silhouette. These scales are taken from py_silhouette and I haven't measured them. Without a scale, values go out unconverted as before, so other GPGL drivers are unaffected.The pane
Cameo 4 defaults
The driver now defaults to settings for standard vinyl: depth 1, force 70 g and speed 20 in/s, sent as 10 and 5 (close to Silhouette Studio's vinyl settings).
Tests
New tests in
tests/test_protocols.pycover setting the depth, skipping it when another tool is loaded, a machine that does not answer, clamping the depth, a reply split across packets, and force and speed with and without a scale.🤖 Generated with Claude Code