File tree Expand file tree Collapse file tree 6 files changed +240
-0
lines changed Expand file tree Collapse file tree 6 files changed +240
-0
lines changed Original file line number Diff line number Diff line change
1
+ .. |PIR| image:: https://static-cdn.m5stack.com/resource/docs/products/unit/PIR/img-4647c010-1e57-4cc9-85e3-cbd450882074.webp
2
+ :target: https://docs.m5stack.com/en/unit/PIR
3
+ :height: 200px
4
+ :width: 200 px
5
+
6
+
7
+ .. |example.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/pir/example.svg
8
+
9
+ .. |init.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/pir/init.svg
10
+
11
+ .. |get_status.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/pir/get_status.svg
12
+
13
+ .. |enable_irq.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/pir/enable_irq.svg
14
+
15
+ .. |disable_irq.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/pir/disable_irq.svg
16
+
17
+ .. |set_callback.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/pir/set_callback.svg
18
+
19
+
20
+ .. |pir_core_example.m5f2| raw:: html
21
+
22
+ <a href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/m5f2_examples/unit/pir/pir_core_example.m5f2" target="_blank">pir_core_example.m5f2</a>
23
+
Original file line number Diff line number Diff line change 14
14
light.rst
15
15
dlight.rst
16
16
ultrasonic.rst
17
+ pir.rst
Original file line number Diff line number Diff line change
1
+ PIR Unit
2
+ ==================
3
+
4
+ .. include :: ../refs/unit.pir.ref
5
+
6
+ Support the following products:
7
+
8
+
9
+ |PIR |
10
+
11
+
12
+ Micropython Example::
13
+
14
+ import os, sys, io
15
+ import M5
16
+ from M5 import *
17
+ from hardware import *
18
+ from unit import *
19
+
20
+ i2c0 = None
21
+ pir_0 = None
22
+
23
+ def setup():
24
+ global i2c0, pir_0
25
+
26
+ i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000)
27
+ pir_0 = PIR((8, 9))
28
+ M5.begin()
29
+ Widgets.fillScreen(0x222222)
30
+
31
+ print(pir_0.get_status())
32
+
33
+
34
+
35
+ UIFLOW2 Example:
36
+
37
+ |example.svg |
38
+
39
+ .. only :: builder_html
40
+
41
+ |pir_core_example.m5f2 |
42
+
43
+ class PIR
44
+ -----------------
45
+
46
+ Constructors
47
+ --------------
48
+
49
+ .. class :: PIR(IO1,IO2)
50
+
51
+ Create a PIR object.
52
+
53
+ The parameters are:
54
+ - ``IO1,IO2 `` I2C pin.
55
+
56
+
57
+ UIFLOW2:
58
+
59
+ |init.svg |
60
+
61
+
62
+ Methods
63
+ -------
64
+
65
+ .. method :: PIR.get_status()
66
+
67
+
68
+ Get detection status.
69
+
70
+ UIFLOW2:
71
+
72
+ |get_status.svg |
73
+
74
+ .. method :: PIR.enable_irq()
75
+
76
+ Enable Human detection function.
77
+
78
+ UIFLOW2:
79
+
80
+ |enable_irq.svg |
81
+
82
+ .. method :: PIR.disable_irq()
83
+
84
+ Disable Human detection function.
85
+
86
+ UIFLOW2:
87
+
88
+ |disable_irq.svg |
89
+
90
+ .. method :: PIR.set_callback()
91
+
92
+ Polling method, placed in the loop function, constantly check.
93
+
94
+ UIFLOW2:
95
+
96
+ |set_callback.svg |
Original file line number Diff line number Diff line change
1
+ .. |PIR| image:: https://static-cdn.m5stack.com/resource/docs/products/unit/PIR/img-4647c010-1e57-4cc9-85e3-cbd450882074.webp
2
+ :target: https://docs.m5stack.com/zh_CN/unit/PIR
3
+ :height: 200px
4
+ :width: 200 px
5
+
6
+
7
+ .. |example.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/pir/example.svg
8
+
9
+ .. |init.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/pir/init.svg
10
+
11
+ .. |get_status.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/pir/get_status.svg
12
+
13
+ .. |enable_irq.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/pir/enable_irq.svg
14
+
15
+ .. |disable_irq.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/pir/disable_irq.svg
16
+
17
+ .. |set_callback.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/pir/set_callback.svg
18
+
19
+
20
+ .. |pir_core_example.m5f2| raw:: html
21
+
22
+ <a href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/m5f2_examples/unit/pir/pir_core_example.m5f2" target="_blank">pir_core_example.m5f2</a>
23
+
Original file line number Diff line number Diff line change 14
14
light.rst
15
15
dlight.rst
16
16
ultrasonic.rst
17
+ pir.rst
Original file line number Diff line number Diff line change
1
+ PIR Unit
2
+ ==================
3
+
4
+ .. include :: ../refs/unit.pir.ref
5
+
6
+ Support the following products:
7
+
8
+
9
+ |PIR |
10
+
11
+
12
+ Micropython Example::
13
+
14
+ import os, sys, io
15
+ import M5
16
+ from M5 import *
17
+ from hardware import *
18
+ from unit import *
19
+
20
+ i2c0 = None
21
+ pir_0 = None
22
+
23
+ def setup():
24
+ global i2c0, pir_0
25
+
26
+ i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000)
27
+ pir_0 = PIR((8, 9))
28
+ M5.begin()
29
+ Widgets.fillScreen(0x222222)
30
+
31
+ print(pir_0.get_status())
32
+
33
+
34
+
35
+ UIFLOW2 Example:
36
+
37
+ |example.svg |
38
+
39
+ .. only :: builder_html
40
+
41
+ |pir_core_example.m5f2 |
42
+
43
+ class PIR
44
+ -----------------
45
+
46
+ Constructors
47
+ --------------
48
+
49
+ .. class :: PIR(IO1,IO2)
50
+
51
+ 创建一个PIR对象.
52
+
53
+ 参数是:
54
+ - ``IO1,IO2 `` I2C引脚。
55
+
56
+
57
+ UIFLOW2:
58
+
59
+ |init.svg |
60
+
61
+
62
+ Methods
63
+ -------
64
+
65
+ .. method :: PIR.get_status()
66
+
67
+
68
+ 获取检测状态
69
+
70
+ UIFLOW2:
71
+
72
+ |get_status.svg |
73
+
74
+ .. method :: PIR.enable_irq()
75
+
76
+ 使能人体检测功能。
77
+
78
+ UIFLOW2:
79
+
80
+ |enable_irq.svg |
81
+
82
+ .. method :: PIR.disable_irq()
83
+
84
+ 关闭人体检测功能。
85
+
86
+ UIFLOW2:
87
+
88
+ |disable_irq.svg |
89
+
90
+ .. method :: PIR.set_callback()
91
+
92
+ 轮询方法,放在loop函数里面,不断检测。
93
+
94
+ UIFLOW2:
95
+
96
+ |set_callback.svg |
You can’t perform that action at this time.
0 commit comments