Skip to content

Commit a270c78

Browse files
Tinyu-Zhaolbuque
authored andcommitted
lib/m5ui: Supplement the documentation and API of m5ui.line.
Signed-off-by: tinyu <tinyu@m5stack.com>
1 parent b12470a commit a270c78

File tree

4 files changed

+220
-127
lines changed

4 files changed

+220
-127
lines changed

docs/en/m5ui/line.rst

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,66 @@ M5Line
5353

5454
.. autoclass:: m5ui.line.M5Line
5555
:members:
56-
56+
57+
.. py:method:: set_line_color(color, opa, part)
58+
59+
Set the color of the line.
60+
61+
:param int color: The color to set.
62+
:param int opa: The opacity of the color.
63+
:param int part: The part of the object to apply the style to (e.g., lv.PART.MAIN).
64+
65+
UiFlow2 Code Block:
66+
67+
|set_line_color.png|
68+
69+
MicroPython Code Block:
70+
71+
.. code-block:: python
72+
73+
line_0.set_line_color(0xFF0000, 255, lv.PART.MAIN)
74+
75+
.. py:method:: set_style_line_width(width, part)
76+
77+
Set the width of the line.
78+
79+
:param int width: The width to set.
80+
:param int part: The part of the object to apply the style to (e.g., lv.PART.MAIN).
81+
82+
UiFlow2 Code Block:
83+
84+
|set_style_line_width.png|
85+
86+
MicroPython Code Block:
87+
88+
.. code-block:: python
89+
90+
line_0.set_style_line_width(2, lv.PART.MAIN)
91+
92+
.. py:method:: set_flag(flag, value)
93+
94+
Set a flag on the object. If ``value`` is True, the flag is added; if False, the flag is removed.
95+
96+
:param int flag: The flag to set.
97+
:param bool value: If True, the flag is added; if False, the flag is removed.
98+
:return: None
99+
100+
UiFlow2 Code Block:
101+
102+
|set_flag.png|
103+
104+
MicroPython Code Block:
105+
106+
.. code-block:: python
107+
108+
button_0.set_flag(lv.obj.FLAG.HIDDEN, True)
109+
57110
.. py:method:: set_pos(x, y)
58111
59-
Set the position of the switch.
112+
Set the position of the line.
60113

61-
:param int x: The x-coordinate of the switch.
62-
:param int y: The y-coordinate of the switch.
114+
:param int x: The x-coordinate of the line.
115+
:param int y: The y-coordinate of the line.
63116

64117
UiFlow2 Code Block:
65118

@@ -69,13 +122,13 @@ M5Line
69122

70123
.. code-block:: python
71124
72-
switch_0.set_pos(100, 100)
125+
line_0.set_pos(100, 100)
73126
74127
.. py:method:: set_x(x)
75128
76-
Set the x-coordinate of the switch.
129+
Set the x-coordinate of the line.
77130

78-
:param int x: The x-coordinate of the switch.
131+
:param int x: The x-coordinate of the line.
79132

80133
UiFlow2 Code Block:
81134

@@ -85,13 +138,13 @@ M5Line
85138

86139
.. code-block:: python
87140
88-
switch_0.set_x(100)
141+
line_0.set_x(100)
89142
90143
.. py:method:: set_y(y)
91144
92-
Set the y-coordinate of the switch.
145+
Set the y-coordinate of the line.
93146

94-
:param int y: The y-coordinate of the switch.
147+
:param int y: The y-coordinate of the line.
95148

96149
UiFlow2 Code Block:
97150

@@ -101,12 +154,12 @@ M5Line
101154

102155
.. code-block:: python
103156
104-
switch_0.set_y(100)
157+
line_0.set_y(100)
105158
106159
107160
.. py:method:: align_to(obj, align, x, y)
108161
109-
Align the switch to another object.
162+
Align the line to another object.
110163

111164
:param lv.obj obj: The object to align to.
112165
:param int align: The alignment type.
@@ -121,4 +174,4 @@ M5Line
121174

122175
.. code-block:: python
123176
124-
switch_0.align_to(page_0, lv.ALIGN.CENTER, 0, 0)
177+
line_0.align_to(page_0, lv.ALIGN.CENTER, 0, 0)

docs/en/refs/m5ui.line.ref

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
.. |set_line_color.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/line/set_line_color.png
77
.. |set_points.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/line/set_points.png
88
.. |add_point.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/line/add_point.png
9+
.. |set_style_line_width.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/line/set_style_line_width.png
10+
.. |set_flag.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/line/set_flag.png
911

1012
.. |cores3_line_example.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/line/example.png
1113

0 commit comments

Comments
 (0)