Repository navigation
feat: add DBS refinement option; prepare images off the event loop - #170
Merged
Merged
Conversation
upload_image() called _prepare_image() (rotate, fit, dither, encode, compress) synchronously inside the coroutine, so the CPU work ran on the caller's event loop. In Home Assistant that stalls every integration for the duration of the dither. Run it via asyncio.to_thread instead; the dither call already releases the GIL, so the loop stays responsive.
prepare_image() and upload_image() accept dbs=None | True | DbsParams, passed through to epaper-dithering's Direct Binary Search refinement (opt-in, slower). dbs=True fills in the panel's real pixel density from its physical size via the new DisplayConfig.ppi (measured along the diagonal, so it is orientation-independent), so the eye model matches the hardware; panels without a known size fall back to the library defaults. Requires epaper-dithering 6.1.0 (pin bumped).
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Adds the Direct Binary Search refinement from epaper-dithering 6.1.0 to the upload path, and moves image preparation off the event loop.
fix: prepare images off the event loop in upload_imageupload_image()called_prepare_image()(rotate → fit → dither → encode → compress) synchronously inside the coroutine, so all of that CPU work ran on the caller's event loop. In Home Assistant, that blocks every integration for the duration of the dither:It now runs via
asyncio.to_thread.dither_imagealready releases the GIL, so the loop stays responsive. A new test asserts_prepare_imagenever runs on the event-loop thread; it failed before the change.feat: add DBS refinement option to image preparation and uploadprepare_image()andupload_image()takedbs: DbsParams | bool | None = None:None/False: off (the default, so existing behaviour is unchanged).True: on, with the panel's real pixel density filled in from its physical size via a newDisplayConfig.ppi. It's measured along the diagonal, so it doesn't depend on orientation; e.g. 800×480 px on a 160×96 mm active area gives 127 ppi. Panels without a known size fall back to the library defaults.DbsParams(...): passed through unchanged, e.g. for a custom viewing distance.The
epaper-ditheringpin goes from 6.0.0 to 6.1.0; theuv.lockchange is only that package.Tests
DisplayConfig.ppiwith known and unknown sizes;dbsresolution (on, off, explicit params, missing size); forwarding throughprepare_imageandupload_image.dither_imagewith a stub that lists every argument, sodbswas added to that list.Downstream
py-opendisplayand add an opt-in service field that passesdbs=True. Its directdevice.upload_image()call also gets the off-loop fix for free.prepare_image()in an executor for its sleeping-device queue; it only needs to passdbs=through.