@@ -22,54 +22,21 @@ is the detailed Rotary support for the host:
22
22
.. |S | unicode :: U+2714
23
23
24
24
25
- Micropython Example::
25
+ Micropython Example:
26
26
27
- import os, sys, io
28
- import M5
29
- from M5 import *
30
- from hardware import *
27
+ .. literalinclude :: ../../../examples/hardware/rotary/dial_rotary_example.py
28
+ :language: python
29
+ :linenos:
31
30
32
- label0 = None
33
- rotary = None
34
31
35
- def btnA_wasClicked_event(state):
36
- global label0, rotary
37
- rotary.reset_rotary_value()
38
- label0.setText(str(rotary.get_rotary_value()))
39
-
40
- def setup():
41
- global label0, rotary
42
-
43
- M5.begin()
44
- Widgets.fillScreen(0x222222)
45
- label0 = Widgets.Label("0", 96, 80, 1.0, 0xffa000, 0x222222, Widgets.FONTS.DejaVu72)
46
-
47
- BtnA.setCallback(type=BtnA.CB_TYPE.WAS_CLICKED, cb=btnA_wasClicked_event)
48
-
49
- rotary = Rotary()
50
-
51
- def loop():
52
- global label0, rotary
53
- M5.update()
54
- if rotary.get_rotary_status():
55
- label0.setText(str(rotary.get_rotary_value()))
32
+ UIFLOW2 Example:
56
33
57
- if __name__ == '__main__':
58
- try:
59
- setup()
60
- while True:
61
- loop()
62
- except (Exception, KeyboardInterrupt) as e:
63
- try:
64
- from utility import print_error_msg
65
- print_error_msg(e)
66
- except ImportError:
67
- print("please update to latest firmware")
34
+ |example.png |
68
35
69
36
70
- UIFLOW2 Example:
37
+ .. only :: builder_html
71
38
72
- |example.svg |
39
+ |dial_rotary_example.m5f2 |
73
40
74
41
75
42
class Rotary
@@ -84,7 +51,7 @@ Constructors
84
51
85
52
UIFLOW2:
86
53
87
- |init.svg |
54
+ |init.png |
88
55
89
56
Methods
90
57
-------
@@ -95,7 +62,7 @@ Methods
95
62
96
63
UIFLOW2:
97
64
98
- |get_rotary_status.svg |
65
+ |get_rotary_status.png |
99
66
100
67
101
68
.. method :: Rotary.get_rotary_value() -> int
@@ -106,7 +73,7 @@ Methods
106
73
107
74
UIFLOW2:
108
75
109
- |get_rotary_value.svg |
76
+ |get_rotary_value.png |
110
77
111
78
112
79
.. method :: Rotary.get_rotary_increments() -> int
@@ -118,7 +85,7 @@ Methods
118
85
119
86
UIFLOW2:
120
87
121
- |get_rotary_increments.svg |
88
+ |get_rotary_increments.png |
122
89
123
90
124
91
.. method :: Rotary.reset_rotary_value() -> None
@@ -127,7 +94,7 @@ Methods
127
94
128
95
UIFLOW2:
129
96
130
- |reset_rotary_value.svg |
97
+ |reset_rotary_value.png |
131
98
132
99
133
100
.. method :: Rotary.set_rotary_value() -> None
@@ -136,4 +103,4 @@ Methods
136
103
137
104
UIFLOW2:
138
105
139
- |set_rotary_value.svg |
106
+ |set_rotary_value.png |
0 commit comments