Skip to content

Commit 584da5d

Browse files
committed
README improvements.
1 parent 3a86c1d commit 584da5d

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

README.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ The Plot module: Cartesian and polar graphs.
9494
8. [Fonts](./README.md#8-fonts)
9595
8.1 [External fonts](./README.md#81-external-fonts)
9696
8.2 [Internal fonts: Class IFont](./README.md#82-internal-fonts-class-ifont)
97-
9. [Issues](./README.md#9-issues) A problem encountered with old firmware
97+
9. [Issues](./README.md#9-issues) A problem encountered with old LCD160CR firmware
98+
10. [Application design note](./README.md#10-Application design note) Touch application design
9899

99100
# 1. Pre requisites
100101

@@ -419,13 +420,13 @@ These do nothing, and may be defined in subclasses if required.
419420

420421
## 4.4 Method
421422

422-
* `reg_task` args `task`, `on_change=False`. The first arg may be a `Task`
423-
instance or a coroutine. It is a convenience method which provides for the
424-
automatic cancellation of tasks. If a screen runs independent coros it can opt
425-
to register these. On shudown, any registered tasks of the base screen are
426-
cancelled. On screen change, registered tasks with `on_change` `True` are
427-
cancelled. For finer control applications can ignore this method and handle
428-
cancellation explicitly in code.
423+
* `reg_task` args `task`, `on_change=False`. This is a convenience method for
424+
applications which use `uasyncio` and provides for the automatic cancellation
425+
of tasks. The first arg may be a `Task` instance or a coroutine. If a `Screen`
426+
runs associated coros it can opt to register these. On shudown, any registered
427+
tasks of the base screen are cancelled. On screen change, registered tasks
428+
with `on_change` `True` are cancelled. For finer control applications can
429+
ignore this method and handle cancellation explicitly in code.
429430

430431
###### [Jump to Contents](./README.md#contents)
431432

@@ -736,7 +737,9 @@ Optional keyword only arguments:
736737
* `callback` Callback function which runs when button is pressed.
737738
* `args` A list/tuple of arguments for the above callback. Default `[]`.
738739
* `onrelease` Default `True`. If `True` the callback will occur when the
739-
button is released otherwise it will occur when pressed. See note below.
740+
button is released otherwise it will occur when pressed. See
741+
[Application design note](./README.md#10-Application design note) for the
742+
reason for this default.
740743
* `lp_callback` Callback to be used if button is to respond to a long press.
741744
Default `None`.
742745
* `lp_args` A list/tuple of arguments for above callback. Default `[]`.
@@ -750,10 +753,6 @@ Class variables:
750753
* `lit_time` Period in seconds the `litcolor` is displayed. Default 1.
751754
* `long_press_time` Press duration for a long press. Default 1 second.
752755

753-
Note: if button callbacks change screens, `onrelease` should be set `False`.
754-
This avoids multiple screen changes if more than one such button is pressed
755-
simultaneously.
756-
757756
###### [Jump to Contents](./README.md#contents)
758757

759758
## 6.5 Class ButtonList emulate a button with multiple states
@@ -1061,3 +1060,20 @@ Optional args:
10611060
There was a problem with detection of long button presses (MicroPython issue
10621061
#2879). This was resolved in early 2017 by an upgrade to the LCD160CR firmware.
10631062
If running an old display device you may need to request an upgrade.
1063+
1064+
# 10. Application design note
1065+
1066+
There is an issue in a touch application where a control causes a new screen
1067+
to overlay the current screen, or closes a screen to reveal the one below.
1068+
Consider a `X` screen close button at the top right hand corner of each screen.
1069+
If touched, the screen closes revealing the one below with its `X` button: the
1070+
touch causes this immediately to be activated closing that screen too.
1071+
1072+
For this reason the [Button class](./README.md#64-class-button) defaults to
1073+
running the callback on release. While this fixes the problem of close buttons,
1074+
it can introduce problems where buttons open screens: if multiple buttons are
1075+
pressed at once, unexpected screen changes can occur. Either set such buttons
1076+
to run the callback on press or use a control such as a listbox.
1077+
1078+
The general point, where screens change, is to consider how continuing touch
1079+
will affect the new screen.

0 commit comments

Comments
 (0)