Porównaj commity

...

2 Commity

Autor SHA1 Wiadomość Data
Peter Hinch 4117ddf230 Fix bug in encoder-only mode. 2023-09-18 10:33:08 +01:00
Peter Hinch a5cdc85562 Fix bug in encoder-only mode. 2023-09-18 09:27:31 +01:00
2 zmienionych plików z 15 dodań i 12 usunięć

Wyświetl plik

@ -312,17 +312,17 @@ runtime. A disabled `active` widget is shown "greyed-out" and cannot accept the
### 1.4.1 Encoder only mode
This uses a rotary encoder with a pushbutton as the sole means of navigation, a
mode suggested by @eudoxos. By default, turning the dial moves the currency
between widgets. Clicking the button selects a widget; the widget with the
focus has a white border. Supporting widgets such as sliders and dropdown lists
enter "adjust" mode such that turning the dial adjusts the widget.
This uses a rotary encoder with a built-in pushbutton as the sole means of
navigation, a mode suggested by @eudoxos. By default, turning the dial moves
the currency between widgets; the widget with the focus has a white border.
Widgets for numeric entry such as sliders and scales may be put into "adjust"
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
precision adjustment mode with a long press of the button. "Adjust" mode is
cleared with a short button press.
"precision" adjustment mode with a long press of the button. "Adjust" and
"precision" modes are cleared with a short button press.
This mode works well and its use is quite intuitive. The rapid navigation makes
it particularly useful when a screen has a large number of widgets.
This mode works well and its use is quite intuitive. Navigation by turning a
dial makes it particularly useful when a screen has a large number of widgets.
###### [Contents](./README.md#0-contents)

Wyświetl plik

@ -122,6 +122,8 @@ class Input:
# nxt and prev are Pin instances corresponding to encoder X and Y.
# sel is a Pin for the encoder's pushbutton.
# 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:
def __init__(self, nxt, sel, prev, encoder):
from gui.primitives import Encoder
@ -132,18 +134,19 @@ class InputEnc:
self._sel = Pushbutton(sel, suppress=True)
self._sel.release_func(self.release) # Widgets are selected on release.
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
# is an int (discarded), val is the delta. (With button interface 1st arg
# arg is the button, delta is +1 or -1).
def enc_cb(self, position, delta): # Default encoder callback
# is the button, delta is +1 or -1).
def enc_cb(self, position, delta): # Eencoder callback
if self._adj:
Screen.adjust(0, delta)
else:
Screen.ctrl_move(_NEXT if delta > 0 else _PREV)
def release(self):
self.adj_mode() #False) # Cancel adjust and precision
self.adj_mode(False) # Cancel adjust and precision
Screen.sel_ctrl()
def precision(self, val): # Also called by Screen.ctrl_move to cancel mode