Skip to content

Commit c458754

Browse files
committed
Add op90 unit
1 parent 2c58eab commit c458754

File tree

6 files changed

+240
-0
lines changed

6 files changed

+240
-0
lines changed

docs/en/refs/unit.op90.ref

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. |OP90| image:: https://static-cdn.m5stack.com/resource/docs/products/unit/OP.90/img-103a3854-fbc1-43a3-9ebe-88cf6051e273.webp
2+
:target: https://docs.m5stack.com/en/unit/OP.90
3+
:height: 200px
4+
:width: 200 px
5+
6+
7+
.. |example.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/op90/example.svg
8+
9+
.. |init.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/op90/init.svg
10+
11+
.. |get_switch_value.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/op90/get_switch_value.svg
12+
13+
.. |get_count_value.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/op90/get_counter_value.svg
14+
15+
.. |reset_count_value.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/op90/reset_counter_value.svg
16+
17+
18+
19+
.. |op90_core_example.m5f2| raw:: html
20+
21+
<a href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/m5f2_examples/unit/op90/op90_core_example.m5f2" target="_blank">op90_core_example.m5f2</a>
22+

docs/en/units/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ Unit
1717
pir.rst
1818
ncir.rst
1919
relay.rst
20+
op90.rst

docs/en/units/op90.rst

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
OP90 Unit
2+
==================
3+
4+
.. include:: ../refs/unit.OP90.ref
5+
6+
The following products are supported:
7+
8+
9+
|OP90|
10+
11+
12+
Micropython Example::
13+
14+
import os, sys, io
15+
import M5
16+
from M5 import *
17+
from hardware import *
18+
import time
19+
from unit import *
20+
21+
i2c0 = None
22+
op90_0 = None
23+
24+
def setup():
25+
global i2c0, op90_0
26+
27+
i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000)
28+
op90_0 = OPUnit((8, 9), type=1)
29+
M5.begin()
30+
Widgets.fillScreen(0x222222)
31+
32+
print(op90_0.get_value)
33+
time.sleep(1)
34+
print(op90_0.count_value)
35+
time.sleep(1)
36+
op90_0.count_reset()
37+
time.sleep(1)
38+
39+
40+
41+
UIFLOW2 Example:
42+
43+
|example.svg|
44+
45+
.. only:: builder_html
46+
47+
|op90_core_example.m5f2|
48+
49+
class OPUnit
50+
-----------------
51+
52+
Constructors
53+
--------------
54+
55+
.. class:: OPUnit(io)
56+
57+
Create an OPUnit object.
58+
59+
The parameters is:
60+
- ``io`` is the detection pin.
61+
62+
63+
UIFLOW2:
64+
65+
|init.svg|
66+
67+
68+
Methods
69+
-------
70+
71+
.. method:: OPUnit.get_value()
72+
73+
74+
Gets the switch status.
75+
76+
UIFLOW2:
77+
78+
|get_switch_value.svg|
79+
80+
.. method:: OPUnit.count_value()
81+
82+
Get the count value.
83+
84+
UIFLOW2:
85+
86+
|get_count_value.svg|
87+
88+
.. method:: OPUnit.count_reset()
89+
90+
Reset the meter value.
91+
92+
UIFLOW2:
93+
94+
|reset_count_value.svg|
95+
96+
97+

docs/zh_CN/refs/unit.op90.ref

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. |OP90| image:: https://static-cdn.m5stack.com/resource/docs/products/unit/OP.90/img-103a3854-fbc1-43a3-9ebe-88cf6051e273.webp
2+
:target: https://docs.m5stack.com/zh_CN/unit/OP.90
3+
:height: 200px
4+
:width: 200 px
5+
6+
7+
.. |example.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/op90/example.svg
8+
9+
.. |init.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/op90/init.svg
10+
11+
.. |get_switch_value.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/op90/get_switch_value.svg
12+
13+
.. |get_count_value.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/op90/get_counter_value.svg
14+
15+
.. |reset_count_value.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/op90/reset_counter_value.svg
16+
17+
18+
19+
.. |op90_core_example.m5f2| raw:: html
20+
21+
<a href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/m5f2_examples/unit/op90/op90_core_example.m5f2" target="_blank">op90_core_example.m5f2</a>
22+

docs/zh_CN/unit/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ Unit
1717
pir.rst
1818
ncir.rst
1919
relay.rst
20+
op90.rst

docs/zh_CN/unit/op90.rst

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
OP90 Unit
2+
==================
3+
4+
.. include:: ../refs/unit.OP90.ref
5+
6+
支持以下产品:
7+
8+
9+
|OP90|
10+
11+
12+
Micropython Example::
13+
14+
import os, sys, io
15+
import M5
16+
from M5 import *
17+
from hardware import *
18+
import time
19+
from unit import *
20+
21+
i2c0 = None
22+
op90_0 = None
23+
24+
def setup():
25+
global i2c0, op90_0
26+
27+
i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000)
28+
op90_0 = OPUnit((8, 9), type=1)
29+
M5.begin()
30+
Widgets.fillScreen(0x222222)
31+
32+
print(op90_0.get_value)
33+
time.sleep(1)
34+
print(op90_0.count_value)
35+
time.sleep(1)
36+
op90_0.count_reset()
37+
time.sleep(1)
38+
39+
40+
41+
UIFLOW2 Example:
42+
43+
|example.svg|
44+
45+
.. only:: builder_html
46+
47+
|op90_core_example.m5f2|
48+
49+
class OPUnit
50+
-----------------
51+
52+
Constructors
53+
--------------
54+
55+
.. class:: OPUnit(io)
56+
57+
创建一个OPUnit对象.
58+
59+
参数如下:
60+
- ``io`` 为检测引脚。
61+
62+
63+
UIFLOW2:
64+
65+
|init.svg|
66+
67+
68+
Methods
69+
-------
70+
71+
.. method:: OPUnit.get_value()
72+
73+
74+
获取开关状态。
75+
76+
UIFLOW2:
77+
78+
|get_switch_value.svg|
79+
80+
.. method:: OPUnit.count_value()
81+
82+
获取计数值。
83+
84+
UIFLOW2:
85+
86+
|get_count_value.svg|
87+
88+
.. method:: OPUnit.count_reset()
89+
90+
重置计数值。
91+
92+
UIFLOW2:
93+
94+
|reset_count_value.svg|
95+
96+
97+

0 commit comments

Comments
 (0)