luma.core icon indicating copy to clipboard operation
luma.core copied to clipboard

Make refresh on viewport no-op if there's nothing to do

Open fstanis opened this issue 7 months ago • 0 comments

Looking at the code for refresh in viewport, it seems it will call self._device.display even when there's nothing to do:

https://github.com/rm-hull/luma.core/blob/6b69584e41a286ef09bab4a371b407120fb27f9b/luma/core/virtual.py#L113-L127

Since this function is usually called often (i.e. once per frame), would it make sense to skip this step if the image hasn't changed (i.e. should_wait == false)? I understand refresh is also called from display and set_position in which case it wouldn't be desirable to skip this step, but this could be mitigated by adding a flat to it, i.e. refresh(force = False) and calling it as refresh(True) from those two spots.

fstanis avatar Jul 03 '24 09:07 fstanis