kopia lustrzana https://github.com/peterhinch/micropython-micro-gui
Porównaj commity
2 Commity
11b9ab655e
...
4117ddf230
Autor | SHA1 | Data |
---|---|---|
Peter Hinch | 4117ddf230 | |
Peter Hinch | a5cdc85562 |
18
README.md
18
README.md
|
@ -312,17 +312,17 @@ runtime. A disabled `active` widget is shown "greyed-out" and cannot accept the
|
||||||
|
|
||||||
### 1.4.1 Encoder only mode
|
### 1.4.1 Encoder only mode
|
||||||
|
|
||||||
This uses a rotary encoder with a pushbutton as the sole means of navigation, a
|
This uses a rotary encoder with a built-in pushbutton as the sole means of
|
||||||
mode suggested by @eudoxos. By default, turning the dial moves the currency
|
navigation, a mode suggested by @eudoxos. By default, turning the dial moves
|
||||||
between widgets. Clicking the button selects a widget; the widget with the
|
the currency between widgets; the widget with the focus has a white border.
|
||||||
focus has a white border. Supporting widgets such as sliders and dropdown lists
|
Widgets for numeric entry such as sliders and scales may be put into "adjust"
|
||||||
enter "adjust" mode such that turning the dial adjusts the widget.
|
mode with a double click. In that mode turning the dial adjusts the widget.
|
||||||
[Floating Point Widgets](./README.md#112-floating-point-widgets) can enter
|
[Floating Point Widgets](./README.md#112-floating-point-widgets) can enter
|
||||||
precision adjustment mode with a long press of the button. "Adjust" mode is
|
"precision" adjustment mode with a long press of the button. "Adjust" and
|
||||||
cleared with a short button press.
|
"precision" modes are cleared with a short button press.
|
||||||
|
|
||||||
This mode works well and its use is quite intuitive. The rapid navigation makes
|
This mode works well and its use is quite intuitive. Navigation by turning a
|
||||||
it particularly useful when a screen has a large number of widgets.
|
dial makes it particularly useful when a screen has a large number of widgets.
|
||||||
|
|
||||||
###### [Contents](./README.md#0-contents)
|
###### [Contents](./README.md#0-contents)
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,8 @@ class Input:
|
||||||
# nxt and prev are Pin instances corresponding to encoder X and Y.
|
# nxt and prev are Pin instances corresponding to encoder X and Y.
|
||||||
# sel is a Pin for the encoder's pushbutton.
|
# sel is a Pin for the encoder's pushbutton.
|
||||||
# encoder is the division ratio.
|
# encoder is the division ratio.
|
||||||
|
# Note that using a single click for adjust mode failed because the mode changed when
|
||||||
|
# activating pushbuttons, checkboxes etc.
|
||||||
class InputEnc:
|
class InputEnc:
|
||||||
def __init__(self, nxt, sel, prev, encoder):
|
def __init__(self, nxt, sel, prev, encoder):
|
||||||
from gui.primitives import Encoder
|
from gui.primitives import Encoder
|
||||||
|
@ -132,18 +134,19 @@ class InputEnc:
|
||||||
self._sel = Pushbutton(sel, suppress=True)
|
self._sel = Pushbutton(sel, suppress=True)
|
||||||
self._sel.release_func(self.release) # Widgets are selected on release.
|
self._sel.release_func(self.release) # Widgets are selected on release.
|
||||||
self._sel.long_func(self.precision, (True,)) # Long press -> precision mode
|
self._sel.long_func(self.precision, (True,)) # Long press -> precision mode
|
||||||
|
self._sel.double_func(self.adj_mode, (True,)) # Double press -> adjust mode
|
||||||
|
|
||||||
# Screen.adjust: adjust the value of a widget. In this case 1st button arg
|
# Screen.adjust: adjust the value of a widget. In this case 1st button arg
|
||||||
# is an int (discarded), val is the delta. (With button interface 1st arg
|
# is an int (discarded), val is the delta. (With button interface 1st arg
|
||||||
# arg is the button, delta is +1 or -1).
|
# is the button, delta is +1 or -1).
|
||||||
def enc_cb(self, position, delta): # Default encoder callback
|
def enc_cb(self, position, delta): # Eencoder callback
|
||||||
if self._adj:
|
if self._adj:
|
||||||
Screen.adjust(0, delta)
|
Screen.adjust(0, delta)
|
||||||
else:
|
else:
|
||||||
Screen.ctrl_move(_NEXT if delta > 0 else _PREV)
|
Screen.ctrl_move(_NEXT if delta > 0 else _PREV)
|
||||||
|
|
||||||
def release(self):
|
def release(self):
|
||||||
self.adj_mode() #False) # Cancel adjust and precision
|
self.adj_mode(False) # Cancel adjust and precision
|
||||||
Screen.sel_ctrl()
|
Screen.sel_ctrl()
|
||||||
|
|
||||||
def precision(self, val): # Also called by Screen.ctrl_move to cancel mode
|
def precision(self, val): # Also called by Screen.ctrl_move to cancel mode
|
||||||
|
|
Ładowanie…
Reference in New Issue