Repository navigation
Conversation
On macOS, rev A displays (1a86:5722, "UsbMonitor") draw corrupted images through the CDC serial device (issue mathoudebine#7). The firmware handles pixel data per 64-byte USB packet: short packets are drawn padded with stale bytes, and the zero-length packet macOS sends after a write that is a multiple of 64 bytes is drawn as a duplicate packet, so the pixel stream falls out of step. Add LcdCommRevAUsb, which writes to the bulk OUT endpoint 0x03 with pyusb/libusb (as the vendor Windows app does). Each command is its own transfer, and bitmaps are widened to the 32-px grid from a framebuffer copy of the screen so pixel data is always whole 64-byte packets of exactly w*h*2 bytes. On macOS, claiming the interface works without root even though detaching the kernel driver does not. Opt-in with display.USB_BULK in config.yaml (default false); falls back to the serial port if the device cannot be opened over USB. Reset is a logged no-op on this transport. Approach from issue mathoudebine#7 (findings by marcelors27 and amarok30). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AJosYpRiBzMfZgig6BxiN3
This was referenced Nov 19, 2026
eaglstun
added a commit
to eaglstun/turing-smart-screen-python
that referenced
this pull request
Nov 19, 2026
Takes the PR's standalone lcd_comm_rev_a_usb.py (Reset is a no-op over USB, clearer header). Keeps main's display.py (serial fallback uses PACKET_FIX) and config.yaml (USB_BULK and PACKET_FIX enabled for this Mac). USB transfers verified byte-identical to the tested build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AJosYpRiBzMfZgig6BxiN3
This branch has not been deployed
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.
Addresses #7 (corrupted images on macOS with rev. A displays).
Problem
On macOS, rev. A displays (
1a86:5722, serialUSB35INCHIPSV2, product "UsbMonitor") draw corrupted images through the CDC serial device/dev/cu.usbmodem*: staircases, slanted rows, repeated passes, and a desync that persists until the display is unplugged.On my unit, test patterns showed that the firmware handles pixel data per 64-byte USB packet:
Flushes and delays change where the packet boundaries fall, not what the firmware does with them, which is why they never fully fixed this. The vendor Windows app writes straight to the USB bulk endpoint.
Change
library/lcd/lcd_comm_rev_a_usb.py(LcdCommRevAUsb), a subclass ofLcdCommRevAthat writes to bulk OUT endpoint0x03with pyusb/libusb instead of pyserial:DisplayPILImagekeeps a framebuffer copy of the screen and widens each update horizontally to the 32-px grid, so pixel data is always whole 64-byte packets and exactlyw*h*2bytes. Partial updates (text, bars, graphs) are packet-safe too, not just full frames;SET_ORIENTATIONis sent as 11 bytes;Reset()is a logged no-op on this transport. A desynced panel swallows RESET as pixel data, and I didn't validate reset behavior over USB.config.yaml: newdisplay.USB_BULKoption, defaultfalse, so nothing changes for existing users.library/display.py: usesLcdCommRevAUsbwhenUSB_BULK: true, and falls back to the serial port if the device can't be opened over USB (for example, libusb missing).pyusb is already in
requirements.txt. macOS needs libusb (brew install libusb). No root is needed:detach_kernel_driver()fails with "Access denied", butclaim_interface(1)succeeds with Apple's CDC driver still attached, and writes to0x03work.Testing
simple-program-style text and clock updates, andmain.pywith3.5inchTheme2,SimpleBlueGaugeandbash-dark-green. Images are clean with no artifacts. A full 320×480 frame takes about 1.9 s, and steady state is about 1.3% of one core.Possible follow-up, if wanted: enable
USB_BULKautomatically on macOS.Credit to marcelors27 and amarok30 in #7 for the bulk-endpoint approach.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AJosYpRiBzMfZgig6BxiN3