Repository navigation
Conversation
The display reads 249 data bytes from each 250-byte packet and treats the last byte as a separator; the "ef69" terminator belongs to that data stream. _generate_update_image chunked only the raw pixel records (and only when longer than 250 bytes) and appended the terminator afterwards, so updates whose length fell on certain residues (raw lengths 248/249 mod 249, and 248-250 unchunked) lost the terminator: the status reply was swallowed or the display answered needReSend:1 to every later update. Chunk the records and the terminator together. Also restart the render count at 0 after every full frame (the display expects that) and keep the count increment inside the update mutex. Claude-Session: https://claude.ai/code/session_015HUJhXMdZg27SVrwtSV3Dv
Run the real LcdCommRevC._generate_update_image over many raw lengths (including those that used to break: 248, 249, 250, 497, 498, 1992 and ~227 KB), for 2.1", 5" and 8" sub-revisions, with a model of the display packet parsing; check the render count restarts at 0 after a full frame. Claude-Session: https://claude.ai/code/session_015HUJhXMdZg27SVrwtSV3Dv
LcdCommRevCVideo extends LcdCommRevC for the 2.1" screen: video storage (list/size/upload/delete/play) with a size guard that runs before anything is deleted, full overlay init and incremental overlay updates using the corrected 249-byte framing, status parsing, and serial errors raised as DeviceError so the caller can back off and reconnect instead of the process exiting. Port detection and wake-up reuse LcdCommRevC.auto_detect_com_port(). The existing driver is not modified. Claude-Session: https://claude.ai/code/session_015HUJhXMdZg27SVrwtSV3Dv
Renders the seamless 8 s / 30 fps loop (navy background, flame ring, sparkles) and encodes it with ffmpeg, pre-rotated for the screen's native orientation. The video is re-encoded at a higher CRF until it fits the 1.2 MB storage of the screen; ffmpeg is checked before use, Popen is cleaned up on errors and no partial file is left behind. The result is cached in the per-user cache directory (not the source tree). Claude-Session: https://claude.ai/code/session_015HUJhXMdZg27SVrwtSV3Dv
video-face-rev-c.py runs an animated face on the 2.1" round rev C screen: the background loops in the screen's own video player and the host only sends small overlay updates with the CPU / GPU / RAM rows. Sensors come from library/sensors as selected by HW_SENSORS (GPU shows N/A when unavailable). The loop recovers from serial errors with backoff and reconnection, refuses unsupported screens/configs and oversized videos before touching the screen, and exits with distinct codes for errors that retrying cannot fix. Tunables live in a new optional video_face section of config.yaml, loaded with defaults by library/config.py. Claude-Session: https://claude.ai/code/session_015HUJhXMdZg27SVrwtSV3Dv
Cover status/hello parsing, the video size guard, overlay run/visibility/pixel encoding and framing, the driver's count handling and recovery with a scripted serial port, bar colour bands, settings validation, sampler N/A handling and the video cache / re-encode logic (without ffmpeg or a screen). Claude-Session: https://claude.ai/code/session_015HUJhXMdZg27SVrwtSV3Dv
Only a post-upload size mismatch is fatal; serial errors propagate as DeviceError into the reconnect loop. Upload is written in 32 KB chunks with a stop check, errors move to rev_c_errors.py, hello() no longer sleeps after the last attempt. Claude-Session: https://claude.ai/code/session_015HUJhXMdZg27SVrwtSV3Dv
Guard the video_face config merge, check the stop flag during startup, remove the duplicated build_background, unique temp file for the encoder, ffmpeg stderr to a temp file, cache dir fallback without a home directory. Claude-Session: https://claude.ai/code/session_015HUJhXMdZg27SVrwtSV3Dv
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.
Summary
This adds an optional animated "video face" for the Turing 2.1" round rev C screen. Instead of streaming animation frames over serial (a full 480×480 frame takes about 330 ms), it uses the screen's own storage and native H.264 playback:
/root/video/), and played natively at about 30 fps.The layout is CPU / GPU / RAM rows. Each row has a label, a history of bars centred on the row, and the value. Bar colours move from blue through yellow to red, with thresholds that can be configured.
What's added
Existing code paths are unchanged.
library/lcd/lcd_comm_rev_c_video.py:LcdCommRevCVideo, a subclass ofLcdCommRevC. It handles storage commands (list, file size, upload, delete), play/stop, full overlay init, incremental overlay updates and status parsing (needReSend/renderCnt), with recovery.auto_detect_com_port()and the fixed framing from Fix rev C partial update framing and render count reset #1149.library/lcd/rev_c_errors.py.library/video_face/: the app loop, the renderer, the sampler (throughlibrary/sensors, as selected byHW_SENSORS, so NVIDIA, AMD, Intel and LHM all work; a missing GPU shows "N/A"), settings and the video generator.video-face-rev-c.py: a standalone entry point, alongsidemain.pyandsimple-program.py.main.py, since both use the serial port.config.yaml: a new optionalvideo_face:section (rows, sample period, remote dir/prefix, bar colours and thresholds). All keys have defaults. If the section is missing or malformed,library/config.pyfalls back to the defaults, so older configs andmain.pyare unaffected.res/docs/rev-c-video-face.mdand a preview GIF, plus a 2-line README entry.tests/library/lcd/test_lcd_comm_rev_c_video.pyandtests/library/video_face/test_video_face.py.Robustness
renderCntstalls, the video is replayed and re-uploaded if it has gone missing.Testing
renderCntabout 29.5/s, overlay latency 10 ms on average.python -m unittest discover -s tests -t .passes for all new tests. The 8 errors intests/library/lcd/test_lcd_comm_rev_c.pyalready exist onmain(see Fix rev C partial update framing and render count reset #1149).Limitations / notes
REVISION: C.DISPLAY_REVERSE: false: the orientation for this setting is derived but not verified on a device.truewas verified visually.