Fix epaper demo initial refresh.

encoder_driver
peterhinch 2023-06-01 12:16:35 +01:00
rodzic d886989f7e
commit 310957e518
3 zmienionych plików z 27 dodań i 11 usunięć

Wyświetl plik

@ -3090,26 +3090,40 @@ connecting to any host. The hardware_setup.py should be copied or adapted from
`setup_examples/pico_epaper_42_pico.py`. If using the socket, default args may `setup_examples/pico_epaper_42_pico.py`. If using the socket, default args may
be used (see code comment). be used (see code comment).
After an initial refresh to clear the screen the driver is put into partial Some attention to detail is required to handle the refresh characteristics.
mode. This provides a reasonably quick and visually satisfactory response to The application must wait for the initial full refresh (which occurs
user inputs such as button events. See the automatically) before putting the display into partial mode. This is done by
the screen constructor issuing
```python
asyncio.create_task(set_partial())
```
to run
```python
async def set_partial(): # Ensure 1st refresh is a full refresh
await Screen.rfsh_done.wait() # Wait for first refresh to end
ssd.set_partial()
```
The application then runs in partial mode with a reasonably quick and visually
satisfactory response to user inputs such as button events. See the
[epaper demo](https://github.com/peterhinch/micropython-micro-gui/blob/main/gui/demos/epaper.py). [epaper demo](https://github.com/peterhinch/micropython-micro-gui/blob/main/gui/demos/epaper.py).
This provides for a full refresh via the `reset` button. Provision of full
refresh is application dependent. It should be done as follows:
It is likely that applications will provide a full refresh method to clear any
ghosting. The demo provides for a full refresh via the `reset` button. A full
refresh should be done as follows:
```python ```python
async def full_refresh(): async def full_refresh():
Screen.rfsh_done.clear() # Enable completion flag Screen.rfsh_done.clear() # Enable completion flag
await Screen.rfsh_done.wait() # Wait for a refresh to end await Screen.rfsh_done.wait() # Wait for a refresh to end
ssd.set_full() ssd.set_full()
Screen.rfsh_done.clear() # Enable completion flag Screen.rfsh_done.clear() # Re-enable completion flag
await Screen.rfsh_done.wait() # Wait for a single full refresh to end await Screen.rfsh_done.wait() # Wait for a single full refresh to end
ssd.set_partial() ssd.set_partial() # Subsequent refreshes are partial
``` ```
The driver for the supported display uses 1-bit color mapping: this means that The driver for the supported display uses 1-bit color mapping: this means that
greying-out has no visible effect. Greyed-out controls cannot accept the focus greying-out has no visible effect. Greyed-out controls cannot accept the focus
and are therefore disabled but appearance is unchanged. and are therefore disabled but appearance is unchanged. `nano-gui` has a 2-bit
driver which supports greyscales, but there is no partial support so this is
unsuitable for `micro_gui`.
###### [Contents](./README.md#0-contents) ###### [Contents](./README.md#0-contents)

Wyświetl plik

@ -47,6 +47,9 @@ async def full_refresh():
await Screen.rfsh_done.wait() # Wait for a single full refresh to end await Screen.rfsh_done.wait() # Wait for a single full refresh to end
ssd.set_partial() ssd.set_partial()
async def set_partial(): # Ensure 1st refresh is a full refresh
await Screen.rfsh_done.wait() # Wait for first refresh to end
ssd.set_partial()
class FooScreen(Screen): class FooScreen(Screen):
def __init__(self): def __init__(self):
@ -161,6 +164,7 @@ class FooScreen(Screen):
Label(wri_large, lbl.mrow + 5, col, "y = sinc(x)") Label(wri_large, lbl.mrow + 5, col, "y = sinc(x)")
CloseButton(wri, bgcolor=BLACK) CloseButton(wri, bgcolor=BLACK)
asyncio.create_task(set_partial()) # After 1st full refresh
asyncio.create_task(run(dial, lbltim, m0, scale)) asyncio.create_task(run(dial, lbltim, m0, scale))
def callback(self, button, buttons, val): def callback(self, button, buttons, val):
@ -186,7 +190,6 @@ class FooScreen(Screen):
x += 0.05 x += 0.05
Curve(self.graph, None, populate()) Curve(self.graph, None, populate())
asyncio.create_task(full_refresh())
async def run(dial, lbltim, m0, scale): async def run(dial, lbltim, m0, scale):

Wyświetl plik

@ -56,4 +56,3 @@ decrease = Pin(17, Pin.IN, Pin.PULL_UP) # Decrease control's value
# display = Display(ssd, nxt, sel, prev) # 3-button mode # display = Display(ssd, nxt, sel, prev) # 3-button mode
display = Display(ssd, nxt, sel, prev, increase, decrease) # 5-button mode display = Display(ssd, nxt, sel, prev, increase, decrease) # 5-button mode
ssd.wait_until_ready() # Blocking wait ssd.wait_until_ready() # Blocking wait
ssd.set_partial() # Subsequent refreshes are partial