Skip to content

Commit f151100

Browse files
Tinyu-Zhaolbuque
authored andcommitted
lib/m5ui: Add LVGL Spinner widget docs and example.
Signed-off-by: tinyu <[email protected]>
1 parent c6bcb71 commit f151100

File tree

7 files changed

+593
-3
lines changed

7 files changed

+593
-3
lines changed

docs/en/m5ui/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Classes
7777
scale.rst
7878
slider.rst
7979
spinbox.rst
80+
spinner.rst
8081
switch.rst
8182
textarea.rst
8283
win.rst

docs/en/m5ui/spinner.rst

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
.. currentmodule:: m5ui
2+
3+
M5Spinner
4+
==========
5+
6+
.. include:: ../refs/m5ui.spinner.ref
7+
8+
M5Spinner is a spinning arc over a ring, typically used to show some type of activity is in progress.
9+
10+
UiFlow2 Example
11+
---------------
12+
13+
spinner
14+
^^^^^^^^^^^^^^
15+
16+
Open the |core2_spinner_example.m5f2| project in UiFlow2.
17+
18+
This example shows a spinning arc over a ring.
19+
20+
UiFlow2 Code Block:
21+
22+
|example.png|
23+
24+
Example output:
25+
26+
None
27+
28+
29+
MicroPython Example
30+
-------------------
31+
32+
spinner
33+
^^^^^^^^^^^^^
34+
35+
This example shows a spinning arc over a ring.
36+
37+
MicroPython Code Block:
38+
39+
.. literalinclude:: ../../../examples/m5ui/spinner/core2_spinner_example.py
40+
:language: python
41+
:linenos:
42+
43+
Example output:
44+
45+
None
46+
47+
48+
**API**
49+
-------
50+
51+
M5Spinner
52+
^^^^^^^^^
53+
54+
.. autoclass:: m5ui.spinner.M5Spinner
55+
:members:
56+
:member-order: bysource
57+
58+
.. py:method:: set_flag(flag, value)
59+
60+
Set a flag on the object. If ``value`` is True, the flag is added; if False, the flag is removed.
61+
62+
:param int flag: The flag to set.
63+
:param bool value: If True, the flag is added; if False, the flag is removed.
64+
:return: None
65+
66+
UiFlow2 Code Block:
67+
68+
|set_flag.png|
69+
70+
MicroPython Code Block:
71+
72+
.. code-block:: python
73+
74+
spinner_0.set_flag(lv.obj.FLAG.HIDDEN, True)
75+
76+
.. py:method:: set_pos(x, y)
77+
78+
Set the position of the spinner.
79+
80+
:param int x: The x-coordinate of the spinner.
81+
:param int y: The y-coordinate of the spinner.
82+
83+
UiFlow2 Code Block:
84+
85+
|set_pos.png|
86+
87+
MicroPython Code Block:
88+
89+
.. code-block:: python
90+
91+
spinner_0.set_pos(100, 100)
92+
93+
.. py:method:: set_x(x)
94+
95+
Set the x-coordinate of the spinner.
96+
97+
:param int x: The x-coordinate of the spinner.
98+
99+
UiFlow2 Code Block:
100+
101+
|set_x.png|
102+
103+
MicroPython Code Block:
104+
105+
.. code-block:: python
106+
107+
spinner_0.set_x(100)
108+
109+
.. py:method:: set_y(y)
110+
111+
Set the y-coordinate of the spinner.
112+
113+
:param int y: The y-coordinate of the spinner.
114+
115+
UiFlow2 Code Block:
116+
117+
|set_y.png|
118+
119+
MicroPython Code Block:
120+
121+
.. code-block:: python
122+
123+
spinner_0.set_y(100)
124+
125+
.. py:method:: set_size(width, height)
126+
127+
Set the size of the spinner.
128+
129+
:param int width: The width of the spinner.
130+
:param int height: The height of the spinner.
131+
132+
UiFlow2 Code Block:
133+
134+
|set_size.png|
135+
136+
MicroPython Code Block:
137+
138+
.. code-block:: python
139+
140+
spinner_0.set_size(100, 50)
141+
142+
.. py:method:: align_to(obj, align, x, y)
143+
144+
Align the spinner to another object.
145+
146+
:param lv.obj obj: The object to align to.
147+
:param int align: The alignment type.
148+
:param int x: The x-offset from the aligned object.
149+
:param int y: The y-offset from the aligned object.
150+
151+
UiFlow2 Code Block:
152+
153+
|align_to.png|
154+
155+
MicroPython Code Block:
156+
157+
.. code-block:: python
158+
159+
spinner_0.align_to(page_0, lv.ALIGN.CENTER, 0, 0)
160+
161+
.. py:method:: set_anim_params(anim_t, angle)
162+
163+
Set the animation parameters of the spinner.
164+
165+
:param int anim_t: The animation time in milliseconds.
166+
:param int angle: The angle of the spinner in degrees.
167+
168+
UiFlow2 Code Block:
169+
170+
|set_anim_params.png|
171+
172+
MicroPython Code Block:
173+
174+
.. code-block:: python
175+
176+
spinner_0.set_anim_params(1000, 180)

docs/en/refs/m5ui.spinner.ref

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. |align_to.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/spinner/align_to.png
2+
.. |set_bg_color.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/spinner/set_bg_color.png
3+
.. |set_indicator_color.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/spinner/set_indicator_color.png
4+
.. |set_pos.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/spinner/set_pos.png
5+
.. |set_size.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/spinner/set_size.png
6+
.. |set_x.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/spinner/set_x.png
7+
.. |set_y.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/spinner/set_y.png
8+
.. |set_flag.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/spinner/set_flag.png
9+
.. |set_anim_params.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/spinner/set_anim_params.png
10+
11+
.. |example.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/spinner/example.png
12+
13+
.. |core2_spinner_example.m5f2| raw:: html
14+
15+
<a
16+
href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/examples/m5ui/spinner/core2_spinner_example.m5f2"
17+
target="_blank"
18+
>
19+
core2_spinner_example.m5f2
20+
</a>

0 commit comments

Comments
 (0)