Skip to content

Commit 78fb276

Browse files
committed
docs: Add PLC I/O docs.
Signed-off-by: lbuque <[email protected]>
1 parent 147e9a2 commit 78fb276

18 files changed

+1231
-97
lines changed

docs/en/controllers/stampplc.rst

Lines changed: 0 additions & 96 deletions
This file was deleted.

docs/en/hardware/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Hardware
1212
ir.rst
1313
mic.rst
1414
pin.rst
15+
plcio.rst
1516
rotary.rst
1617
scd40.rst
1718
sen55.rst
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
Digital Input
2+
=============
3+
4+
.. include:: ../refs/hardware.plcio.digitalinput.ref
5+
6+
Digital Input is used to read the digital input of host devices.
7+
8+
9+
UiFlow2 Example
10+
---------------
11+
12+
Get the digital input status
13+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
15+
Open the |stamplc_digital_input_example.m5f2| project in UiFlow2.
16+
17+
This example demonstrates how to get the status of a digital input and display the status on the screen.
18+
19+
UiFlow2 Code Block:
20+
21+
|stamplc_digital_input_example.png|
22+
23+
Example output:
24+
25+
None
26+
27+
28+
MicroPython Example
29+
-------------------
30+
31+
Get the digital input status
32+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33+
34+
This example demonstrates how to get the status of a digital input and display the status on the screen.
35+
36+
MicroPython Code Block:
37+
38+
.. literalinclude:: ../../../examples/hardware/plcio/digital_input/stamplc_digital_input_example.py
39+
40+
Example output:
41+
42+
None
43+
44+
45+
**API**
46+
-------
47+
48+
DigitalInput
49+
^^^^^^^^^^^^
50+
51+
.. class:: DigitalInput(id: int)
52+
53+
Initialize a digital input object.
54+
55+
:param int id: The ID of the digital input. The range of ID is 1-8.
56+
57+
UiFlow2 Code Block:
58+
59+
|init.png|
60+
61+
MicroPython Code Block:
62+
63+
.. code-block:: python
64+
65+
from hadrware import DigitalInput
66+
67+
in1 = DigitalInput(1)
68+
69+
70+
.. method:: DigitalInput.get_status() -> bool
71+
72+
Get the status of the digital input.
73+
74+
:return: The status of the digital input.
75+
:rtype: bool
76+
77+
UiFlow2 Code Block:
78+
79+
|get_status.png|
80+
81+
MicroPython Code Block:
82+
83+
.. code-block:: python
84+
85+
in1.get_status()
86+
87+
88+
.. method:: DigitalInput.value() -> int
89+
90+
Get the value of the digital input.
91+
92+
:return: The value of the digital input.
93+
:rtype: int
94+
95+
UiFlow2 Code Block:
96+
97+
|value.png|
98+
99+
MicroPython Code Block:
100+
101+
.. code-block:: python
102+
103+
in1.value()
104+
105+
.. method:: DigitalInput.irq(handler=None, trigger=IRQ_FALLING | IRQ_RISING) -> None
106+
107+
Enable interrupt for the pin.
108+
109+
:param function handler: The interrupt handler function.
110+
:param int trigger: The interrupt trigger mode, DigitalInput.IRQ_FALLING or DigitalInput.IRQ_RISING.
111+
112+
UiFlow2 Code Block:
113+
114+
|irq.png|
115+
116+
MicroPython Code Block:
117+
118+
.. code-block:: python
119+
120+
def handler(pin):
121+
print('interrupt triggered')
122+
123+
in1.irq(handler, DigitalInput.IRQ_FALLING)

docs/en/hardware/plcio.relay.rst

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
Relay
2+
=====
3+
4+
.. include:: ../refs/hardware.plcio.relay.ref
5+
6+
Relay is used to control the relay of host devices.
7+
8+
9+
UiFlow2 Example
10+
---------------
11+
12+
Relay control
13+
^^^^^^^^^^^^^
14+
15+
Open the |stamplc_relay_example.m5f2| project in UiFlow2.
16+
17+
This example demonstrates how to use a button to control the state of a relay and display the relay's state value on the screen.
18+
19+
UiFlow2 Code Block:
20+
21+
|stamplc_relay_example.png|
22+
23+
Example output:
24+
25+
None
26+
27+
28+
MicroPython Example
29+
-------------------
30+
31+
Relay control
32+
^^^^^^^^^^^^^
33+
34+
This example demonstrates how to use a button to control the state of a relay and display the relay's state value on the screen.
35+
36+
MicroPython Code Block:
37+
38+
.. literalinclude:: ../../../examples/hardware/plcio/relay/stamplc_relay_example.py
39+
40+
Example output:
41+
42+
None
43+
44+
45+
**API**
46+
-------
47+
48+
Relay
49+
^^^^^
50+
51+
.. class:: Relay(id: int)
52+
53+
Initialize a relay object.
54+
55+
:param int id: The ID of the relay. The range of ID is 1-4.
56+
57+
UiFlow2 Code Block:
58+
59+
|init.png|
60+
61+
MicroPython Code Block:
62+
63+
.. code-block:: python
64+
65+
from hadrware import Relay
66+
67+
relay = Relay(1)
68+
69+
70+
.. method:: Relay.on() -> None
71+
72+
Turn on the relay.
73+
74+
UiFlow2 Code Block:
75+
76+
|on.png|
77+
78+
MicroPython Code Block:
79+
80+
.. code-block:: python
81+
82+
relay.on()
83+
84+
85+
.. method:: Relay.off() -> None
86+
87+
Turn off the relay.
88+
89+
UiFlow2 Code Block:
90+
91+
|off.png|
92+
93+
MicroPython Code Block:
94+
95+
.. code-block:: python
96+
97+
relay.off()
98+
99+
100+
.. method:: Relay.value() -> int
101+
102+
Get the value of the relay.
103+
104+
:return: The value of the relay.
105+
:rtype: int
106+
107+
UiFlow2 Code Block:
108+
109+
|set_value.png|
110+
111+
|get_value.png|
112+
113+
MicroPython Code Block:
114+
115+
.. code-block:: python
116+
117+
relay.value(1)
118+
relay.value()
119+
120+
121+
.. method:: Relay.get_status() -> bool
122+
123+
Get the status of the relay.
124+
125+
:return: The status of the relay.
126+
:rtype: bool
127+
128+
UiFlow2 Code Block:
129+
130+
|get_status.png|
131+
132+
MicroPython Code Block:
133+
134+
.. code-block:: python
135+
136+
relay.get_status()
137+
138+
.. method:: Relay.set_status(status: bool) -> None
139+
140+
Set the status of the relay.
141+
142+
:param bool status: The status of the relay.
143+
144+
UiFlow2 Code Block:
145+
146+
|set_status.png|
147+
148+
MicroPython Code Block:
149+
150+
.. code-block:: python
151+
152+
relay.set_status(True)

0 commit comments

Comments
 (0)