Skip to content

Commit 6f201a9

Browse files
TinyuZhaolbuque
authored andcommitted
libs/unit: Add Unit Cat1 docs and examples.
Signed-off-by: tinyu <tinyu.zhao@gmail.com>
1 parent 13a614c commit 6f201a9

10 files changed

Lines changed: 499 additions & 20 deletions

File tree

docs/en/refs/unit.cat1cn.ref

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.. |Cat1CNUnit| image:: https://m5stack-doc.oss-cn-shenzhen.aliyuncs.com/1189/U204_CAT1-CN_main_pictures_01.webp
2+
:target: https://docs.m5stack.com/en/atom/atom_dtu_nb
3+
:height: 200px
4+
:width: 200px
5+
6+
.. |init.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/cat1_cn/init.png
7+
8+
.. |http_example.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/cat1_cn/http_example.png
9+
.. |mqtt_example.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/cat1_cn/mqtt_example.png
10+
11+
12+
.. |cat1cn_core2_mqtt_example.m5f2| raw:: html
13+
14+
<a
15+
href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/examples/unit/cat1cn/cat1cn_core2_mqtt_example.m5f2"
16+
target="_blank"
17+
>
18+
cat1cn_core2_mqtt_example.m5f2
19+
</a>
20+
21+
22+
.. |cat1cn_core2_http_example.m5f2| raw:: html
23+
24+
<a
25+
href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/examples/unit/cat1cn/cat1cn_core2_http_example.m5f2"
26+
target="_blank"
27+
>
28+
cat1cn_core2_http_example.m5f2
29+
</a>

docs/en/units/cat1cn.rst

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
Cat1CN Unit
2+
====================
3+
4+
.. sku: U204
5+
6+
.. include:: ../refs/unit.cat1cn.ref
7+
8+
This is the driver library for the Cat1CN Unit to accept and send data.
9+
10+
Support the following products:
11+
12+
|Cat1CNUnit|
13+
14+
UiFlow2 Example
15+
---------------
16+
HTTP Example
17+
^^^^^^^^^^^^^^^^^^^
18+
19+
Open the |cat1cn_core2_http_example.m5f2| project in UiFlow2.
20+
21+
This example shows how to send HTTP request.
22+
23+
UiFlow2 Code Block:
24+
25+
|http_example.png|
26+
27+
Example output:
28+
29+
None
30+
31+
MicroPython Example
32+
-------------------
33+
HTTP Example
34+
^^^^^^^^^^^^^^^^^^^^
35+
36+
This example shows how to send HTTP request.
37+
38+
MicroPython Code Block:
39+
40+
.. literalinclude:: ../../../examples/unit/cat1cn/cat1cn_core2_http_example.py
41+
:language: python
42+
:linenos:
43+
44+
Example output:
45+
46+
None
47+
48+
MQTT Example
49+
^^^^^^^^^^^^^^
50+
51+
Open the |cat1cn_core2_mqtt_example.m5f2| project in UiFlow2.
52+
53+
This example shows how to send MQTT message.
54+
55+
UiFlow2 Code Block:
56+
57+
|mqtt_example.png|
58+
59+
Example output:
60+
61+
None
62+
63+
MicroPython Example
64+
-------------------
65+
66+
MQTT Example
67+
^^^^^^^^^^^^^^^^^^^^
68+
69+
This example shows how to send MQTT message.
70+
71+
MicroPython Code Block:
72+
73+
.. literalinclude:: ../../../examples/unit/cat1cn/cat1cn_core2_mqtt_example.py
74+
:language: python
75+
:linenos:
76+
77+
Example output:
78+
79+
None
80+
81+
**API**
82+
-------
83+
84+
Cat1Unit
85+
^^^^^^^^^^^^
86+
87+
.. autoclass:: unit.cat1.Cat1Unit
88+
:members:
89+
90+
See :ref:`unit.NBIOTUnit.Methods <unit.NBIOTUnit.Methods>` for more details.

docs/en/units/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Unit
2222
byteswitch.rst
2323
can.rst
2424
cardkb.rst
25+
cat1cn.rst
2526
catch.rst
2627
co2.rst
2728
co2l.rst
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
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 15:24+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/units/cat1cn.rst:2 d090baa3e4c745deaa9f99632eb582b7
24+
msgid "Cat1CN Unit"
25+
msgstr ""
26+
27+
#: ../../en/units/cat1cn.rst:8 1c266de4c39a4dabbc8cf268d9efd8ca
28+
msgid "This is the driver library for the Cat1CN Unit to accept and send data."
29+
msgstr "这是用于 Cat1CN Unit收发数据的驱动库。"
30+
31+
#: ../../en/units/cat1cn.rst:10 1935cbed7b70489faaebfae6e52ae3d4
32+
msgid "Support the following products:"
33+
msgstr "支持如下产品:"
34+
35+
#: ../../en/units/cat1cn.rst:12 1a753e0704c44641a037e75ce0693d54
36+
msgid "|Cat1CNUnit|"
37+
msgstr ""
38+
39+
#: ../../en/refs/unit.cat1cn.ref 370fa4b905c84ad095a1885927d8159c
40+
msgid "Cat1CNUnit"
41+
msgstr "Cat1CNUnit"
42+
43+
#: ../../en/units/cat1cn.rst:15 02e45146365041fea576d357e7c75743
44+
msgid "UiFlow2 Example"
45+
msgstr "UiFlow2 示例"
46+
47+
#: ../../en/units/cat1cn.rst:17 ../../en/units/cat1cn.rst:34
48+
#: 04da42b42d2a45e4a254d4ec3e06ad26 d6f0ceaf9a264e6ea12a0c737b1388bb
49+
msgid "HTTP Example"
50+
msgstr "HTTP 示例"
51+
52+
#: ../../en/units/cat1cn.rst:19 ccd6209e855740c28fae0f31e80086d3
53+
msgid "Open the |cat1cn_core2_http_example.m5f2| project in UiFlow2."
54+
msgstr "在 UiFlow2 中打开 |cat1cn_core2_http_example.m5f2| 项目。"
55+
56+
#: ../../en/units/cat1cn.rst:21 ../../en/units/cat1cn.rst:36
57+
#: 05014c1a5fb746a8a833da497b001340 50fa61d957c04cd5af53dc8decd3ea6c
58+
msgid "This example shows how to send HTTP request."
59+
msgstr "本示例演示如何发送 HTTP 请求。"
60+
61+
#: ../../en/units/cat1cn.rst:23 ../../en/units/cat1cn.rst:55
62+
#: 24e0ae0ab0604f8883296614b9160d64 6d73b5da19054b4c82754afaeb7d5ce3
63+
#: 6fd2fa227e0d4bc5b790cbb693178f00 of unit.cat1.Cat1Unit:8
64+
msgid "UiFlow2 Code Block:"
65+
msgstr "UiFlow2 代码块:"
66+
67+
#: ../../en/units/cat1cn.rst:25 2e1674ae9f2e4879a8a8b64312643669
68+
msgid "|http_example.png|"
69+
msgstr ""
70+
71+
#: ../../en/refs/unit.cat1cn.ref:8 639f1f7bf7ef4a14bdbbaea77f98f8e3
72+
msgid "http_example.png"
73+
msgstr ""
74+
75+
#: ../../en/units/cat1cn.rst:27 ../../en/units/cat1cn.rst:44
76+
#: ../../en/units/cat1cn.rst:59 ../../en/units/cat1cn.rst:77
77+
#: 93a6ca9191154a1580840ac585fe43a7 98cef784eacd448c8418af325fcb619e
78+
#: cc2b7c9f43fe466bbd888f1e90900a99 fdb4f55914db4941b7982a547109cfd2
79+
msgid "Example output:"
80+
msgstr "示例输出:"
81+
82+
#: ../../en/units/cat1cn.rst:29 ../../en/units/cat1cn.rst:46
83+
#: ../../en/units/cat1cn.rst:61 ../../en/units/cat1cn.rst:79
84+
#: 4b03c061b1ff4d4d8a2d5ffa5992a319 815827aeb6e842ca80173750822db14a
85+
#: 88c605de8fe24fdf9b54d5aa942ea55c e4475aead4654c549142bfac536ecd70
86+
msgid "None"
87+
msgstr ""
88+
89+
#: ../../en/units/cat1cn.rst:32 ../../en/units/cat1cn.rst:64
90+
#: 813c90ee606148aca448ade17b6bdeca e5f0f00806b74ee5a3cbbd897447ba9f
91+
msgid "MicroPython Example"
92+
msgstr "MicroPython 示例"
93+
94+
#: ../../en/units/cat1cn.rst:38 ../../en/units/cat1cn.rst:71
95+
#: b2ac2f25bc3c4c82a7ff378cbeb95319 babf39bfaf7b45a4aaaaca4b6c1ed1b4
96+
#: ef7abd146b7546ccba00ba82c0c2a4b1 of unit.cat1.Cat1Unit:12
97+
msgid "MicroPython Code Block:"
98+
msgstr "MicroPython 代码块:"
99+
100+
#: ../../en/units/cat1cn.rst:49 ../../en/units/cat1cn.rst:67
101+
#: d66c76573c3c4f50aa27106c70c43d28 d68eaae436ce48b880b104aa2c706718
102+
msgid "MQTT Example"
103+
msgstr "MQTT 示例"
104+
105+
#: ../../en/units/cat1cn.rst:51 3dce062a869441a6807f7cde2a8fb4c4
106+
msgid "Open the |cat1cn_core2_mqtt_example.m5f2| project in UiFlow2."
107+
msgstr "在 UiFlow2 中打开 |cat1cn_core2_mqtt_example.m5f2| 项目。"
108+
109+
#: ../../en/units/cat1cn.rst:53 ../../en/units/cat1cn.rst:69
110+
#: 016ba7d60a644618b84765c927df58a7 47434b71ff4c4fc99ca0e6d19a1cf02f
111+
msgid "This example shows how to send MQTT message."
112+
msgstr "本示例演示如何发送 MQTT 消息。"
113+
114+
#: ../../en/units/cat1cn.rst:57 787547af45254b3897699d879821005f
115+
msgid "|mqtt_example.png|"
116+
msgstr ""
117+
118+
#: ../../en/refs/unit.cat1cn.ref:9 1d93e206984a46c0b5d07bd3a9c26f18
119+
msgid "mqtt_example.png"
120+
msgstr ""
121+
122+
#: ../../en/units/cat1cn.rst:82 d2b821232007472eb7d0096ddc77ceae
123+
msgid "**API**"
124+
msgstr ""
125+
126+
#: ../../en/units/cat1cn.rst:85 e643e111b7864cce909d195ab0d01cf5
127+
msgid "Cat1Unit"
128+
msgstr "Cat1Unit"
129+
130+
#: 55d352613e374cb5abaf63efaec54b67 of unit.cat1.Cat1Unit:1
131+
msgid ""
132+
"Bases: :py:class:`~driver.simcom.ml307r.ML307R`, "
133+
":py:class:`~driver.simcom.common.Modem`"
134+
msgstr ""
135+
136+
#: b65f377e9f014b98a8d880375b1fdb37 of unit.cat1.Cat1Unit:1
137+
msgid "Create an Cat1Unit object"
138+
msgstr "创建一个 Cat1Unit 对象"
139+
140+
#: 3c9f42a905ef40fcb80bd1cfb2b090ad of unit.cat1.Cat1Unit
141+
msgid "Parameters"
142+
msgstr "参数"
143+
144+
#: a1753a8ae172459f9af3309d2815e7a8 of unit.cat1.Cat1Unit:3
145+
msgid "The UART ID to use (0, 1, or 2). Default is 2."
146+
msgstr "要使用的 UART ID(0、1 或 2),默认值为 2。"
147+
148+
#: 1149d99befd048b48278040fee4325de of unit.cat1.Cat1Unit:4
149+
msgid "A list or tuple containing the TX and RX pin numbers."
150+
msgstr "包含 TX 和 RX 引脚编号的列表或元组。"
151+
152+
#: 456dd282a6944dfcbc189ab7e36b26b2 of unit.cat1.Cat1Unit:6
153+
msgid "Enable verbose output for debugging. Default is False."
154+
msgstr "启用详细调试输出。默认值为 False。"
155+
156+
#: 3680f5f00c2b4c808af64aaa0635997e of unit.cat1.Cat1Unit:10
157+
msgid "|init.png|"
158+
msgstr ""
159+
160+
#: ../../en/refs/unit.cat1cn.ref:6 7009ec890dc34621addc10de518785b3
161+
msgid "init.png"
162+
msgstr ""
163+
164+
#: ../../en/units/cat1cn.rst:90 c4c3b8980b424b0e813ab68e8a4f3814
165+
msgid ""
166+
"See :ref:`unit.NBIOTUnit.Methods <unit.NBIOTUnit.Methods>` for more "
167+
"details."
168+
msgstr "更多细节请参见 :ref:`unit.NBIOTUnit.Methods <unit.NBIOTUnit.Methods>`。"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"V2.0","versionNumber":"V2.3.8","type":"core2","components":[{"name":"page0","type":"lvgl_page","layer":0,"screenId":"builtin","screenName":"","id":"fxbyvm5Euy@ay`X-","createTime":1764226026862,"backgroundColor":"#ffffff","isLVGL":true,"isSelected":true},{"name":"button0","type":"lvgl_button","layer":1,"screenId":"builtin","screenName":"","id":"t3CkoVemTI4z1eIO","createTime":1764226079779,"x":82,"y":104,"width":0,"height":0,"color":"#ffffff","backgroundColor":"#2196f3","text":"Send HTTP POST","font":"lv.font_montserrat_14","pageId":"fxbyvm5Euy@ay`X-","isLVGL":true,"isSelected":false},{"name":"label0","type":"lvgl_label","layer":2,"screenId":"builtin","screenName":"","id":"u3$*Il__IJlL@CRb","createTime":1764226323950,"x":3,"y":8,"color":"#000000","backgroundColor":"#ffffff","bg_opacity":0,"text":"Data content:","font":"lv.font_montserrat_14","pageId":"fxbyvm5Euy@ay`X-","isLVGL":true,"isSelected":false,"width":96,"height":15},{"name":"label1","type":"lvgl_label","layer":3,"screenId":"builtin","screenName":"","id":"rJ1RcJL2oA1_@qMp","createTime":1764226326933,"x":4,"y":35,"color":"#000000","backgroundColor":"#ffffff","bg_opacity":0,"text":"Response status code:","font":"lv.font_montserrat_14","pageId":"fxbyvm5Euy@ay`X-","isLVGL":true,"isSelected":false,"width":39,"height":15}],"resources":[{"hardware":["hardware_button","hardware_pin_button","imu","speaker","touch","mic","sdcard"]},{"unit":["unit_cat1cn"]}],"units":[{"type":"unit_cat1cn","name":"cat1cn_0","portList":["A","B","C","Custom"],"portType":"A","userPort":[22,21],"id":"pF@&6kdyXqtP!Zw@","createTime":1764226041336,"initBlockId":"F^WppPbCV)W~/a$DZIXi"}],"hats":[],"caps":[],"chains":[],"bases":[],"plcmodules":[],"i2cs":[],"chainBus":[],"blockly":"<block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"50\" y=\"50\"><mutation isBegin=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_begin\" id=\"rVe2)p#A87,?=oM)9fT~\"><next><block type=\"unit_cat1cn_init\" id=\"F^WppPbCV)W~/a$DZIXi\"><mutation isCustom=\"False\"></mutation><field name=\"NAME\">cat1cn_0</field><field name=\"OPTION\">False</field><next><block type=\"lvgl_page_screen_load\" id=\"@3.27}+FbuW/U9?OBf1j\"><field name=\"NAME\">page0</field></block></next></block></next></block></statement></block><block type=\"basic_on_loop\" id=\"loop_block\" deletable=\"false\" x=\"450\" y=\"50\"><mutation isUpdate=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_update\" id=\"5R^RlL=76]5eZ1#1Tj!i\"></block></statement></block><block type=\"lvgl_button_event\" id=\":Bm?XyDtbbWJk;r4e_mZ\" x=\"50\" y=\"270\"><field name=\"NAME\">button0</field><field name=\"OPTION\">CLICKED</field><statement name=\"FUNC\"><block type=\"unit_cat1cn_http_request\" id=\"QV(=DQUn16K_[tqmOEM,\"><field name=\"NAME\">cat1cn_0</field><field name=\"METHOD\">1</field><value name=\"URL\"><shadow type=\"text\" id=\"TKvPl5R@=@GzrQ^M6_ls\"><field name=\"TEXT\">http://httpbin.org/post</field></shadow></value><value name=\"HEADERS\"><block type=\"map_on_loop\" id=\"MpIu*8oEE@eI={!m@az,\"><statement name=\"LOOP\"><block type=\"create_map_key\" id=\"jf8v5GL~P;g{rY#Yv6*)\"><value name=\"key\"><shadow type=\"text\" id=\"$Tp$p?AiHVx]lFqZR*!S\"><field name=\"TEXT\">Content-Type</field></shadow></value><value name=\"value\"><shadow type=\"text\" id=\"?EM+@/:?a[1mE2]=*[D7\"><field name=\"TEXT\">application/json</field></shadow></value><next><block type=\"create_map_key\" id=\"~6oUKY#@guG::|q0AN1E\"><value name=\"key\"><shadow type=\"text\" id=\"YyOD%[I44:~/w239AbXI\"><field name=\"TEXT\">Custom-Header</field></shadow></value><value name=\"value\"><shadow type=\"text\" id=\"d@TDjy6ObRm!+PRIa0?[\"><field name=\"TEXT\">MyHeaderValue</field></shadow></value></block></next></block></statement></block></value><value name=\"DATA\"><block type=\"map_on_loop\" id=\":!%Z0rOi,?@hNc_L6v{C\"><statement name=\"LOOP\"><block type=\"create_map_key\" id=\"sK}ZPdScTzZ{o5hoASDm\"><value name=\"key\"><shadow type=\"text\" id=\"!v:m.LFR=.Qxt/)mbh-N\"><field name=\"TEXT\">message</field></shadow></value><value name=\"value\"><shadow type=\"text\" id=\"S`E@Vcp#2J[S3Gx.d7fM\"><field name=\"TEXT\">Hello from M5Stack!</field></shadow></value><next><block type=\"create_map_key\" id=\"/%^wiVa*)){Gilg9naD6\"><value name=\"key\"><shadow type=\"text\" id=\"6`!41!8_kz]A!K2)qy2L\"><field name=\"TEXT\">status</field></shadow></value><value name=\"value\"><shadow type=\"text\" id=\".z^@?g(Un9{ku2U5:_u?\"><field name=\"TEXT\">active</field></shadow></value></block></next></block></statement></block></value><next><block type=\"lvgl_label_set_text\" id=\"MX@Z|Xt}9pK5PA(yCS0J\"><field name=\"NAME\">label0</field><value name=\"VALUE\"><shadow type=\"text\" id=\"9pYc9JA)4R=c)Gre;c)n\"><field name=\"TEXT\">hello M5</field></shadow><block type=\"text_add_str\" id=\"dujVW#XFND;.~j|DtX;`\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"S`[E-L+u|}X#KOV+l_=H\"><field name=\"TEXT\">Data content:</field></shadow></value><value name=\"VALUE2\"><block type=\"unit_cat1cn_http_data_content\" id=\"2{bI,ku#LT%Gv;^3:7_O\"><field name=\"NAME\">cat1cn_0</field></block></value></block></value><next><block type=\"lvgl_label_set_text\" id=\"T}}3zGA/xgH[n(q;QZ(o\"><field name=\"NAME\">label1</field><value name=\"VALUE\"><shadow type=\"text\" id=\"a{H+%h|iIF^8PI{#?m_x\"><field name=\"TEXT\">hello M5</field></shadow><block type=\"text_add_str\" id=\"SO}Cm$]}XoLu91;3F-~m\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"RC_tlUZM[YDzvTAVPK^J\"><field name=\"TEXT\">Response status code:</field></shadow></value><value name=\"VALUE2\"><block type=\"unit_cat1cn_http_response_code\" id=\"n/mC+BxPx(-D|f~Wr=K|\"><field name=\"NAME\">cat1cn_0</field></block></value></block></value></block></next></block></next></block></statement></block>","screen":[{"simulationName":"Built-in","type":"builtin","width":320,"height":240,"scale":0.77,"screenName":"","blockId":"","screenColorType":0,"rotation":1,"id":"builtin","createTime":1764226026859}],"logicWhenNum":0,"customList":[]}

0 commit comments

Comments
 (0)