Skip to content

Commit 8cc0ea7

Browse files
luoweiyuanlbuque
authored andcommitted
libs/stamplc: Add support for StamPLC AC.
Signed-off-by: luoweiyuan <luoweiyuan@m5stack.com>
1 parent 571c773 commit 8cc0ea7

15 files changed

Lines changed: 654 additions & 10 deletions

File tree

docs/en/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ UiFlow2 documentation and references
1414
hardware/index.rst
1515
module/index.rst
1616
units/index.rst
17+
stamplc/index.rst
1718
hats/index.rst
1819
base/index.rst
1920
cap/index.rst

docs/en/refs/stamplc.ac.ref

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. |StampPLC| image:: https://m5stack-doc.oss-cn-shenzhen.aliyuncs.com/1188/A160-main-pictures_01.webp
2+
:target: https://docs.m5stack.com/en/products/sku/A160
3+
:height: 200px
4+
:width: 200px
5+
6+
.. |init.png| image:: https://static-cdn.m5stack.com/mpy_docs/plc_module/ac/init.png
7+
.. |set_relay.png| image:: https://static-cdn.m5stack.com/mpy_docs/plc_module/ac/set_relay.png
8+
.. |set_red_led.png| image:: https://static-cdn.m5stack.com/mpy_docs/plc_module/ac/set_red_led.png
9+
.. |set_green_led.png| image:: https://static-cdn.m5stack.com/mpy_docs/plc_module/ac/set_green_led.png
10+
.. |set_blue_led.png| image:: https://static-cdn.m5stack.com/mpy_docs/plc_module/ac/set_blue_led.png
11+
.. |stamplc_ac_example.png| image:: https://static-cdn.m5stack.com/mpy_docs/plc_module/ac/example.png
12+
13+
.. |stamplc_ac_example.m5f2| raw:: html
14+
15+
<a
16+
href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/examples/stamplc/ac/stamplc_ac_example.m5f2"
17+
target="_blank"
18+
>
19+
stamplc_ac_example.m5f2
20+
</a>

docs/en/stamplc/ac.rst

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
StamPLC AC
2+
==========
3+
4+
.. sku: A160
5+
6+
.. include:: ../refs/stamplc.ac.ref
7+
8+
ACStamPLC is a class that drives the relay and RGB LED on the AC extension board.
9+
10+
Support the following products:
11+
12+
|StampPLC|
13+
14+
UiFlow2 Example
15+
---------------
16+
17+
Relay and RGB LED control
18+
^^^^^^^^^^^^^^^^^^^^^^^^^
19+
20+
Open the |stamplc_ac_example.m5f2| project in UiFlow2.
21+
22+
This example demonstrates interactive control of the AC relay and RGB LED. Press button A to toggle the relay state.
23+
When the relay is turned on, the red LED lights up; when turned off, the red LED turns off.
24+
25+
UiFlow2 Code Block:
26+
27+
|stamplc_ac_example.png|
28+
29+
Example output:
30+
31+
None
32+
33+
34+
MicroPython Example
35+
-------------------
36+
37+
Relay and RGB LED control
38+
^^^^^^^^^^^^^^^^^^^^^^^^^
39+
40+
This example demonstrates interactive control of the AC relay and RGB LED. Press button A to toggle the relay state.
41+
When the relay is turned on, the red LED lights up; when turned off, the red LED turns off.
42+
43+
MicroPython Code Block:
44+
45+
.. literalinclude:: ../../../examples/stamplc/ac/stamplc_ac_example.py
46+
:language: python
47+
:linenos:
48+
49+
Example output:
50+
51+
None
52+
53+
**API**
54+
-------
55+
56+
ACStamPLC
57+
^^^^^^^^^
58+
59+
.. class:: ACStamPLC()
60+
61+
Create a ACStamPLC object.
62+
63+
UiFlow2 Code Block:
64+
65+
|init.png|
66+
67+
MicroPython Code Block:
68+
69+
.. code-block:: python
70+
71+
from stamplc import ACStamPLC
72+
73+
ac = ACStamPLC()
74+
75+
.. method:: set_relay(state)
76+
77+
Switch the AC relay output.
78+
79+
:param bool state: ``True`` turns the relay on, ``False`` releases it.
80+
81+
UiFlow2 Code Block:
82+
83+
|set_relay.png|
84+
85+
MicroPython Code Block:
86+
87+
.. code-block:: python
88+
89+
ac.set_relay(state)
90+
91+
.. method:: set_red_led(state)
92+
93+
Control the red channel of the RGB LED.
94+
95+
:param bool state: ``True`` lights the LED, ``False`` turns it off.
96+
97+
UiFlow2 Code Block:
98+
99+
|set_red_led.png|
100+
101+
MicroPython Code Block:
102+
103+
.. code-block:: python
104+
105+
ac.set_red_led(state)
106+
107+
.. method:: set_green_led(state)
108+
109+
Control the green channel of the RGB LED.
110+
111+
:param bool state: ``True`` lights the LED, ``False`` turns it off.
112+
113+
UiFlow2 Code Block:
114+
115+
|set_green_led.png|
116+
117+
MicroPython Code Block:
118+
119+
.. code-block:: python
120+
121+
ac.set_green_led(state)
122+
123+
.. method:: set_blue_led(state)
124+
125+
Control the blue channel of the RGB LED.
126+
127+
:param bool state: ``True`` lights the LED, ``False`` turns it off.
128+
129+
UiFlow2 Code Block:
130+
131+
|set_blue_led.png|
132+
133+
MicroPython Code Block:
134+
135+
.. code-block:: python
136+
137+
ac.set_blue_led(state)
138+

docs/en/stamplc/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
StamPLC
2+
=======
3+
4+
.. toctree::
5+
:maxdepth: 1
6+
7+
ac.rst
8+
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
# SOME DESCRIPTIVE TITLE.
2+
# Copyright (C) 2016 - 2025 M5Stack Technology Co., Ltd
3+
# This file is distributed under the same license as the UIFlow2 Programming
4+
# Guide package.
5+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2025.
6+
#
7+
#, fuzzy
8+
msgid ""
9+
msgstr ""
10+
"Project-Id-Version: UIFlow2 Programming Guide \n"
11+
"Report-Msgid-Bugs-To: \n"
12+
"POT-Creation-Date: 2025-11-27 10:49+0800\n"
13+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
15+
"Language: zh_CN\n"
16+
"Language-Team: zh_CN <LL@li.org>\n"
17+
"Plural-Forms: nplurals=1; plural=0;\n"
18+
"MIME-Version: 1.0\n"
19+
"Content-Type: text/plain; charset=utf-8\n"
20+
"Content-Transfer-Encoding: 8bit\n"
21+
"Generated-By: Babel 2.16.0\n"
22+
23+
#: ../../en/stamplc/ac.rst:2 d873f99d33d649bf81b44776fd4290d1
24+
msgid "StamPLC AC"
25+
msgstr ""
26+
27+
#: ../../en/stamplc/ac.rst:8 d7d70e3911094b6993089dabd571bb81
28+
msgid ""
29+
"ACStamPLC is a class that drives the relay and RGB LED on the AC "
30+
"extension board."
31+
msgstr "ACStamPLC 是用于驱动 AC 扩展板上的继电器和 RGB LED 的类。"
32+
33+
#: ../../en/stamplc/ac.rst:10 626cc1ed316e4e0e93984d0686f1fbcf
34+
msgid "Support the following products:"
35+
msgstr "支持以下产品:"
36+
37+
#: ../../en/stamplc/ac.rst:12 b2c465c5faea483c9b9989584755ae32
38+
msgid "|StampPLC|"
39+
msgstr ""
40+
41+
#: ../../en/refs/stamplc.ac.ref a7771f573d224366b048b89e17ebb644
42+
msgid "StampPLC"
43+
msgstr ""
44+
45+
#: ../../en/stamplc/ac.rst:15 f3a1ab71316e468a8dede7058dfbee17
46+
msgid "UiFlow2 Example"
47+
msgstr "UiFlow2 应用示例"
48+
49+
#: ../../en/stamplc/ac.rst:18 ../../en/stamplc/ac.rst:38
50+
#: 79de04783e7d4a4eaa74ae9d846408f2
51+
msgid "Relay and RGB LED control"
52+
msgstr "继电器和 RGB LED 控制"
53+
54+
#: ../../en/stamplc/ac.rst:20 3c6bfe828dcc40da8a2b479f19dcd975
55+
msgid "Open the |stamplc_ac_example.m5f2| project in UiFlow2."
56+
msgstr "在 UiFlow2 中打开 |stamplc_ac_example.m5f2| 项目。"
57+
58+
#: ../../en/stamplc/ac.rst:22 ../../en/stamplc/ac.rst:40
59+
#: 9d3aca242c2a438894be1fa5f1aa70bb
60+
msgid ""
61+
"This example demonstrates interactive control of the AC relay and RGB "
62+
"LED. Press button A to toggle the relay state. When the relay is turned "
63+
"on, the red LED lights up; when turned off, the red LED turns off."
64+
msgstr ""
65+
"此示例演示了 AC 继电器和 RGB LED 的交互式控制。按下按钮 A 可切换继电器状态。当继电器打开时,红色 LED 亮起;当关闭时,红色 "
66+
"LED 熄灭。"
67+
68+
#: ../../en/stamplc/ac.rst:25 ../../en/stamplc/ac.rst:63
69+
#: ../../en/stamplc/ac.rst:81 ../../en/stamplc/ac.rst:97
70+
#: ../../en/stamplc/ac.rst:113 ../../en/stamplc/ac.rst:129
71+
#: 7183b313d7cd4706b5f6aba7ddc38d55
72+
msgid "UiFlow2 Code Block:"
73+
msgstr "UiFlow2 代码块:"
74+
75+
#: ../../en/stamplc/ac.rst:27 412154a228c54344b42f0b15936a1c61
76+
msgid "|stamplc_ac_example.png|"
77+
msgstr ""
78+
79+
#: ../../en/refs/stamplc.ac.ref:11 c50b4f150ba343d883615559c63575ed
80+
msgid "stamplc_ac_example.png"
81+
msgstr ""
82+
83+
#: ../../en/stamplc/ac.rst:29 ../../en/stamplc/ac.rst:49
84+
#: 344fd838e1984fedbb0f9cb020fa75b7
85+
msgid "Example output:"
86+
msgstr "示例输出:"
87+
88+
#: ../../en/stamplc/ac.rst:31 ../../en/stamplc/ac.rst:51
89+
#: 40fecac6951549f08685e7b1b6fc7cb4
90+
msgid "None"
91+
msgstr "无"
92+
93+
#: ../../en/stamplc/ac.rst:35 546fef68093647c2a738df5d534ed678
94+
msgid "MicroPython Example"
95+
msgstr "MicroPython 应用示例"
96+
97+
#: ../../en/stamplc/ac.rst:43 ../../en/stamplc/ac.rst:67
98+
#: ../../en/stamplc/ac.rst:85 ../../en/stamplc/ac.rst:101
99+
#: ../../en/stamplc/ac.rst:117 ../../en/stamplc/ac.rst:133
100+
#: 012b8de977504a8781e3679c11c25e2d
101+
msgid "MicroPython Code Block:"
102+
msgstr "MicroPython 代码块:"
103+
104+
#: ../../en/stamplc/ac.rst:54 25efe0280f834db6b54efe0b7cb6a226
105+
msgid "**API**"
106+
msgstr "**API**"
107+
108+
#: ../../en/stamplc/ac.rst:57 581afb63beb9449eac8f9329f54a7ae0
109+
msgid "ACStamPLC"
110+
msgstr "ACStamPLC"
111+
112+
#: ../../en/stamplc/ac.rst:61 4f495d777be84615a9de9c11c02850c6
113+
msgid "Create a ACStamPLC object."
114+
msgstr "创建一个 ACStamPLC 对象。"
115+
116+
#: ../../en/stamplc/ac.rst:65 2bde25404693407fa4b4c4ac1058532b
117+
msgid "|init.png|"
118+
msgstr ""
119+
120+
#: ../../en/refs/stamplc.ac.ref:6 b774410de36240e7b06409b4345362d2
121+
msgid "init.png"
122+
msgstr ""
123+
124+
#: ../../en/stamplc/ac.rst:77 71ee00f19b0a48de9c800aef7507ae40
125+
msgid "Switch the AC relay output."
126+
msgstr "切换 AC 继电器输出。"
127+
128+
#: ../../en/stamplc/ac.rst c19504a96f234527b2bc79e64d3467ae
129+
msgid "Parameters"
130+
msgstr ""
131+
132+
#: ../../en/stamplc/ac.rst:79 3004cdca520a4ada8b8683a15c8aa301
133+
msgid "``True`` turns the relay on, ``False`` releases it."
134+
msgstr "``True`` 闭合继电器,``False`` 断开继电器。"
135+
136+
#: ../../en/stamplc/ac.rst:83 2bde25404693407fa4b4c4ac1058532b
137+
msgid "|set_relay.png|"
138+
msgstr ""
139+
140+
#: ../../en/refs/stamplc.ac.ref:7 b774410de36240e7b06409b4345362d2
141+
msgid "set_relay.png"
142+
msgstr ""
143+
144+
#: ../../en/stamplc/ac.rst:93 8f9365842f814e9fa05cc5a692a2b914
145+
msgid "Control the red channel of the RGB LED."
146+
msgstr "控制 RGB LED 的红色通道。"
147+
148+
#: ../../en/stamplc/ac.rst:95 ../../en/stamplc/ac.rst:111
149+
#: ../../en/stamplc/ac.rst:127 5174678bdf98428d89c6635808c9499c
150+
msgid "``True`` lights the LED, ``False`` turns it off."
151+
msgstr "``True`` 点亮 LED,``False`` 熄灭 LED。"
152+
153+
#: ../../en/stamplc/ac.rst:99 21626e6bfb424b99888a3a226c51aa41
154+
msgid "|set_red_led.png|"
155+
msgstr ""
156+
157+
#: ../../en/refs/stamplc.ac.ref:8 b3fd71084fb54b229dd34ed537e009d5
158+
msgid "set_red_led.png"
159+
msgstr ""
160+
161+
#: ../../en/stamplc/ac.rst:109 dfb177213a5c42caace146fadf642e2c
162+
msgid "Control the green channel of the RGB LED."
163+
msgstr "控制 RGB LED 的绿色通道。"
164+
165+
#: ../../en/stamplc/ac.rst:115 21626e6bfb424b99888a3a226c51aa41
166+
msgid "|set_green_led.png|"
167+
msgstr ""
168+
169+
#: ../../en/refs/stamplc.ac.ref:9 0f899cde612d412eaa022fac4bdbb141
170+
msgid "set_green_led.png"
171+
msgstr ""
172+
173+
#: ../../en/stamplc/ac.rst:125 6b2398b6e6804e4e9e6d5688b9806552
174+
msgid "Control the blue channel of the RGB LED."
175+
msgstr "控制 RGB LED 的蓝色通道。"
176+
177+
#: ../../en/stamplc/ac.rst:131 3579219a0ae44601818f24e317cb0828
178+
msgid "|set_blue_led.png|"
179+
msgstr ""
180+
181+
#: ../../en/refs/stamplc.ac.ref:10 3dc8809ea8d94c10a3902bcc1440f356
182+
msgid "set_blue_led.png"
183+
msgstr ""
184+
185+
#~ msgid "default is None, will try to get from hardware.plcio."
186+
#~ msgstr ""
187+
188+
#~ msgid "default is 0x44, PI4IOE5V6408 slave address."
189+
#~ msgstr ""
190+
191+
#~ msgid "|stamplc_set_relay.png|"
192+
#~ msgstr ""
193+
194+
#~ msgid "stamplc_set_relay.png"
195+
#~ msgstr ""
196+
197+
#~ msgid "|stamplc_set_r_led.png|"
198+
#~ msgstr ""
199+
200+
#~ msgid "stamplc_set_r_led.png"
201+
#~ msgstr ""
202+
203+
#~ msgid "|stamplc_set_g_led.png|"
204+
#~ msgstr ""
205+
206+
#~ msgid "stamplc_set_g_led.png"
207+
#~ msgstr ""
208+
209+
#~ msgid "|stamplc_set_b_led.png|"
210+
#~ msgstr ""
211+
212+
#~ msgid "stamplc_set_b_led.png"
213+
#~ msgstr ""
214+

0 commit comments

Comments
 (0)