Skip to content

Commit 91483bc

Browse files
TinyuZhaolbuque
authored andcommitted
docs: Add StamPLC PoE docs and example.
Signed-off-by: tinyu <tinyu.zhao@gmail.com>
1 parent cbccf25 commit 91483bc

7 files changed

Lines changed: 270 additions & 1 deletion

File tree

docs/en/module/lan.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Example output:
4646
**API**
4747
-------
4848

49+
.. _module.LAN.Methods:
50+
4951
class LANModule
5052
---------------
5153

docs/en/refs/stamplc.poe.ref

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

docs/en/stamplc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ StamPLC
55
:maxdepth: 1
66

77
ac.rst
8-
8+
poe.rst

docs/en/stamplc/poe.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
StamPLC PoE
2+
============
3+
4+
.. include:: ../refs/stamplc.poe.ref
5+
6+
Supported Products:
7+
8+
|StamPLC PoE|
9+
10+
UiFlow2 Example
11+
---------------
12+
13+
Get the weather
14+
^^^^^^^^^^^^^^^
15+
16+
This example connects to the network using the StamPLC PoE and sends an HTTP request to query the geographical location of the current public IP address.
17+
18+
UiFlow2 Code Block:
19+
20+
|stamplc_poe_example.png|
21+
22+
Example output:
23+
24+
None
25+
26+
MicroPython Example
27+
-------------------
28+
29+
Get the weather
30+
^^^^^^^^^^^^^^^
31+
32+
This example connects to the network using the StamPLC PoE and sends an HTTP request to query the geographical location of the current public IP address.
33+
34+
MicroPython Code Block:
35+
36+
.. literalinclude:: ../../../examples/stamplc/poe/poe_stamplc_example.py
37+
:language: python
38+
:linenos:
39+
40+
Example output:
41+
42+
None
43+
44+
**API**
45+
-------
46+
47+
StamPLC PoE
48+
^^^^^^^^^^^^
49+
50+
.. autoclass:: stamplc.poe.PoEStamPLC
51+
:members:
52+
53+
See :ref:`module.LAN.Methods <module.LAN.Methods>` for more APIs details.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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-12-16 15:35+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/refs/stamplc.poe.ref ../../en/stamplc/poe.rst:2
24+
#: ../../en/stamplc/poe.rst:48 870143ad11fe4d2e95e47c661ac1be5e
25+
#: 87dd1fdc11f74e8bb03a5958dfd073b4 ebb610598f204c899fc776604cb55e3a
26+
msgid "StamPLC PoE"
27+
msgstr "StamPLC PoE"
28+
29+
#: ../../en/stamplc/poe.rst:6 5a4f31d5116947a6adce692ee1cd49f6
30+
msgid "Supported Products:"
31+
msgstr "支持下列产品:"
32+
33+
#: ../../en/stamplc/poe.rst:8 ccb3845b4f8d49f19a030437a8cacf75
34+
msgid "|StamPLC PoE|"
35+
msgstr ""
36+
37+
#: ../../en/stamplc/poe.rst:11 983d1dd530dc4aabac52441053786c9a
38+
msgid "UiFlow2 Example"
39+
msgstr "UiFlow2 示例"
40+
41+
#: ../../en/stamplc/poe.rst:14 ../../en/stamplc/poe.rst:30
42+
#: 7d4b17401d074a80807d7a88eb80f219 889ad69b140849de9330901d0da51a8b
43+
msgid "Get the weather"
44+
msgstr "获取天气"
45+
46+
#: ../../en/stamplc/poe.rst:16 ../../en/stamplc/poe.rst:32
47+
#: 67d9bb0b3a71443e96e8d7c11267eb96 ac64dd9691d84bceb7a63a105ffae7f9
48+
msgid ""
49+
"This example connects to the network using the StamPLC PoE and sends an "
50+
"HTTP request to query the geographical location of the current public IP "
51+
"address."
52+
msgstr "本示例使用 StamPLC PoE 连接网络,并发送 HTTP 请求以查询当前公网 IP 地址的地理位置。"
53+
54+
#: ../../en/stamplc/poe.rst:18 c20589966a3c4897ad828ec86e993222
55+
#: e9ae4431b4d740a0a8b09e4e8eb27923 of stamplc.poe.PoEStamPLC:7
56+
msgid "UiFlow2 Code Block:"
57+
msgstr "UiFlow2 代码块:"
58+
59+
#: ../../en/stamplc/poe.rst:20 8903d1312e804de081a5c9fc90a3a64e
60+
msgid "|stamplc_poe_example.png|"
61+
msgstr ""
62+
63+
#: ../../en/refs/stamplc.poe.ref:7 60f9797602464bb19141647c366ddc8d
64+
msgid "stamplc_poe_example.png"
65+
msgstr ""
66+
67+
#: ../../en/stamplc/poe.rst:22 ../../en/stamplc/poe.rst:40
68+
#: 0ced811fee5e467cabda6b5ca13163a5 b638a82a95d34b749ccf81b667aa2210
69+
msgid "Example output:"
70+
msgstr "示例输出:"
71+
72+
#: ../../en/stamplc/poe.rst:24 ../../en/stamplc/poe.rst:42
73+
#: ac521701485e4b9fba54b88b4cf7857d fcab01960ad1470dae95b780cebb720e
74+
msgid "None"
75+
msgstr ""
76+
77+
#: ../../en/stamplc/poe.rst:27 d855378efec449d2a06b1a5989094f9f
78+
msgid "MicroPython Example"
79+
msgstr "MicroPython 示例"
80+
81+
#: ../../en/stamplc/poe.rst:34 63c385fc5cd342f28edaed5437ded40a
82+
#: bcdb8ad5fee143de87a14e4a2f9a3cd0 of stamplc.poe.PoEStamPLC:11
83+
msgid "MicroPython Code Block:"
84+
msgstr "MicroPython 代码块:"
85+
86+
#: ../../en/stamplc/poe.rst:45 cd2b256f6980431ab5cc691be00d1101
87+
msgid "**API**"
88+
msgstr ""
89+
90+
#: 62940af935a8497580783fbb6e721a14 of stamplc.poe.PoEStamPLC:1
91+
msgid "Bases: :py:class:`object`"
92+
msgstr ""
93+
94+
#: 38390bd3762b443a9ee146ced4599f52 of stamplc.poe.PoEStamPLC:1
95+
msgid "Create an PoEStamPLC object"
96+
msgstr "创建一个 PoEStamPLC 对象"
97+
98+
#: 17b084b413954e39bed6ed0603a4dc5a of stamplc.poe.PoEStamPLC
99+
msgid "Parameters"
100+
msgstr "参数"
101+
102+
#: 880377844baf43f89f3450b981979816 of stamplc.poe.PoEStamPLC:3
103+
msgid "The chip select pin number."
104+
msgstr "片选引脚编号。"
105+
106+
#: f334225eca4d4e24a6de4727c7ba0603 of stamplc.poe.PoEStamPLC:4
107+
msgid "The reset pin number."
108+
msgstr "复位引脚编号。"
109+
110+
#: bc6cb667247743c6896004dd0a2cb02a of stamplc.poe.PoEStamPLC:5
111+
msgid "The interrupt pin number."
112+
msgstr "中断引脚编号。"
113+
114+
#: 67e770f14b8b49308d414c1175f6c48b of stamplc.poe.PoEStamPLC:9
115+
msgid "|init.png|"
116+
msgstr ""
117+
118+
#: ../../en/refs/stamplc.poe.ref:6 3d175fad77364599841d58df739f6648
119+
msgid "init.png"
120+
msgstr ""
121+
122+
#: ../../en/stamplc/poe.rst:53 52529d9d8dd94b6aa009d53df6c6c6d3
123+
msgid "See :ref:`module.LAN.Methods <module.LAN.Methods>` for more APIs details."
124+
msgstr "更多 API 详情请参考 :ref:`module.LAN.Methods <module.LAN.Methods>`。"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"V2.0","versionNumber":"V2.4.0","type":"stamplc","components":[{"name":"screen","type":"screen","layer":0,"screenId":"builtin","screenName":"","id":"__stamplc_screen","createTime":1766025581179,"x":0,"y":0,"width":240,"height":135,"backgroundColor":"#000000","size":0,"isSelected":true},{"name":"title0","type":"title","layer":1,"screenId":"builtin","screenName":"","id":"esIzosI#n7q8nt5_","createTime":1766371403895,"x":0,"y":0,"color":"#ffffff","backgroundColor":"#0000FF","text":"StamPLC PoE Example","textOffset":3,"font":"Widgets.FONTS.DejaVu18","isSelected":false},{"name":"label0","type":"label","layer":2,"screenId":"builtin","screenName":"","id":"hvUYQ4Rdwrkb`C#*","createTime":1766371415324,"x":2,"y":33,"color":"#ffffff","backgroundColor":"#222222","text":"IP:","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false,"width":23,"height":21},{"name":"label1","type":"label","layer":3,"screenId":"builtin","screenName":"","id":"jjd8mhv#rolkLbkQ","createTime":1766372481421,"x":2,"y":65,"color":"#ffffff","backgroundColor":"#222222","text":"Status Code:","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false,"width":121,"height":21},{"name":"label2","type":"label","layer":4,"screenId":"builtin","screenName":"","id":"r0F!#X2oyPMYZusY","createTime":1766372485049,"x":2,"y":96,"color":"#ffffff","backgroundColor":"#222222","text":"Text:","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false,"width":44,"height":21}],"resources":[{"software":["http"]},{"hardware":["hardware_button","hardware_pin_button","speaker","hardware_plcio","hardware_pwr485","hardware_can","sdcard"]},{"plcmodule":["stamplc_poe"]}],"units":[],"hats":[],"caps":[],"chains":[],"bases":[],"plcmodules":[{"type":"stamplc_poe","name":"stamplc_poe_0","id":"y8!QAxN4gkG*%mqu","createTime":1766371382049,"initBlockType":"stamplc_poe_init","initBlockId":"B.dOatnov@``1EvH[72Y"}],"i2cs":[],"chainBus":[],"blockly":"<block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"50\" y=\"30\"><mutation isBegin=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_begin\" id=\"X-=khi?7k^pkL+AxNumN\"><next><block type=\"wlan_sta_init\" id=\"|DeJ1CR{M]8GJekO%H9%\"><next><block type=\"wlan_sta_set_active\" id=\"ykYyU7;(s$P}0b27qSwe\"><field name=\"ACTIVE\">False</field><next><block type=\"stamplc_poe_init\" id=\"B.dOatnov@``1EvH[72Y\"><field name=\"NAME\">stamplc_poe_0</field><next><block type=\"stamplc_poe_ifconfig_subnet\" id=\"VaiHZL-O@$;X@|=i|3`r\"><field name=\"NAME\">stamplc_poe_0</field><value name=\"IP\"><shadow type=\"text\" id=\"FMOMtBsE4o^DwO8rum44\"><field name=\"TEXT\">192.168.8.198</field></shadow></value><value name=\"SUBNET\"><shadow type=\"text\" id=\"{{P`v-jiG6hxbl=uAZ}H\"><field name=\"TEXT\">255.255.255.0</field></shadow></value><value name=\"GATEWAY\"><shadow type=\"text\" id=\"q4oDY$U7~9H{FrMdN#,(\"><field name=\"TEXT\">192.168.8.1</field></shadow></value><value name=\"DNS\"><shadow type=\"text\" id=\"=ezdEn{Oq;cw/D.3){=.\"><field name=\"TEXT\">8.8.8.8</field></shadow></value><next><block type=\"controls_whileUntil\" id=\"^$8m2JWSK}cS)_HU%DD*\"><field name=\"MODE\">WHILE</field><value name=\"BOOL\"><block type=\"logic_negate\" id=\"0,c$iKI:`_GWiM%BjZ+m\"><value name=\"BOOL\"><block type=\"stamplc_poe_isconnected\" id=\")%#C+?htV[GQb{n(X,4/\"><field name=\"NAME\">stamplc_poe_0</field></block></value></block></value><statement name=\"DO\"><block type=\"time_sleep_second\" id=\"3k7WZna?Dq:Z4Lrfhzy(\"><value name=\"SECOND\"><shadow type=\"math_number\" id=\"EqdK@gs`=srol*1Q0Jm4\"><mutation max=\"Infinity\" min=\"0\" precision=\"0\"></mutation><field name=\"NUM\">1</field></shadow></value><next><block type=\"text_print\" id=\"5_Wh.Sq-6n7/Shds{g;,\"><value name=\"TEXT\"><shadow type=\"text\" id=\"dl[CEHX^G9!h7rNy4rB)\"><field name=\"TEXT\">.</field></shadow></value></block></next></block></statement><next><block type=\"label_set_text\" id=\"n3JZ,4WYvt(|x(NdnEz7\"><field name=\"NAME\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"/y#I[O4*e3d{m#3,AC9m\"><field name=\"TEXT\">Label</field></shadow><block type=\"text_add_str\" id=\"MM$(}`k0%-{Am9/4-PUM\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"Fk7uH-:?g+I:7t!n1usB\"><field name=\"TEXT\">IP:</field></shadow></value><value name=\"VALUE2\"><block type=\"stamplc_poe_get_localip\" id=\"k:|L_%ywnBUSsP;5)}Gt\"><field name=\"NAME\">stamplc_poe_0</field></block></value></block></value><next><block type=\"text_print\" id=\"U]qJ1p2W+r1yh3Frxy|~\"><value name=\"TEXT\"><shadow type=\"text\" id=\"p_nCK6%j9vPSINi{FT((\"><field name=\"TEXT\">local network is connected</field></shadow></value><next><block type=\"text_print\" id=\"rTMEv_4|M|6m~YV:~4`N\"><value name=\"TEXT\"><shadow type=\"text\" id=\"O,VkZuMK[OHP,1/^mW~d\"><field name=\"TEXT\"></field></shadow><block type=\"text_add_str\" id=\"Pm.GRF%A|_.7$elpX^1W\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"T1pL}k}56+[Z.omCx2BX\"><field name=\"TEXT\">IP:</field></shadow></value><value name=\"VALUE2\"><block type=\"stamplc_poe_get_localip\" id=\"w0,BZS1CmJnKM]C)8Hi?\"><field name=\"NAME\">stamplc_poe_0</field></block></value></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block><block type=\"basic_on_loop\" id=\"loop_block\" deletable=\"false\" x=\"50\" y=\"570\"><mutation isUpdate=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_update\" id=\"gbK+lHb!nz%QM/=U$q#R\"><next><block type=\"controls_if\" id=\"b-I!u?_u`_^]D%~nxx*!\"><value name=\"IF0\"><block type=\"button_was_pressed\" id=\"dM/.da3#%yb#.rJ8KIP(\"><field name=\"NAME\">BtnA</field></block></value><statement name=\"DO0\"><block type=\"text_print\" id=\"/[U$P9R/,0M_|mb77zbj\"><value name=\"TEXT\"><shadow type=\"text\" id=\"sM4AJb3Gpg{{7ch`x,#+\"><field name=\"TEXT\">Btn Pressed</field></shadow></value><next><block type=\"label_set_text\" id=\"@9#x[xz2mLD$,A;!T}c$\"><field name=\"NAME\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"!7ZSv15v%cI;P/oh%m(L\"><field name=\"TEXT\">Label</field></shadow><block type=\"text_add_str\" id=\",3Hr%9|nJeobB*wY9Ghr\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"/,h[E{~T^^+{DC#xSU3(\"><field name=\"TEXT\">IP:</field></shadow></value><value name=\"VALUE2\"><block type=\"stamplc_poe_get_localip\" id=\"oo1_5(IKCK34HHB{6HT2\"><field name=\"NAME\">stamplc_poe_0</field></block></value></block></value><next><block type=\"label_set_text\" id=\"ww+rbDl4C)eYm{1i7/+l\"><field name=\"NAME\">label1</field><value name=\"TEXT\"><shadow type=\"text\" id=\"!7ZSv15v%cI;P/oh%m(L\"><field name=\"TEXT\">Status Code:</field></shadow></value><next><block type=\"label_set_text\" id=\"10wE/AU?uEgy)_|IMYH`\"><field name=\"NAME\">label2</field><value name=\"TEXT\"><shadow type=\"text\" id=\"omizL95USDhP2;?jLfu%\"><field name=\"TEXT\">Text:</field></shadow></value><next><block type=\"http_request\" id=\"hF4).e,[jF4pmO(`SL}[\"><mutation contentType=\"json\"></mutation><field name=\"METHOD\">GET</field><field name=\"TYPE\">json</field><value name=\"URL\"><shadow type=\"text\" id=\"#TiXnOs}cJ`XaW9)s_vp\"><field name=\"TEXT\">https://wttr.in/?format=%22%C,%20%t%22</field></shadow></value><value name=\"CONTENT_TYPE\"><shadow type=\"text\" id=\"8TT@pOKAy{.7a(Vy9g)%\"><field name=\"TEXT\">application/json</field></shadow></value><value name=\"HEADERS\"><block type=\"map_on_loop\" id=\"K6@}]{6w2J*K@J|]X3_;\"></block></value><value name=\"DATA\"><block type=\"map_on_loop\" id=\"eehcJ~i!bF|(SFMg{PXe\"></block></value><next><block type=\"text_print\" id=\"]4%wShsevb+nA_jP4a4B\"><value name=\"TEXT\"><shadow type=\"text\" id=\"vp@)8o%nLwps?#oE9R_O\"><field name=\"TEXT\">local network is connected</field></shadow><block type=\"text_add_str\" id=\"eXjU:7)Y.t|a`R++L5t{\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"D][5?bE+(tJ{?S`kgm`H\"><field name=\"TEXT\">Status Code:</field></shadow></value><value name=\"VALUE2\"><block type=\"http_get_status_code\" id=\"5/h*)NW#~ZDJoXO;|5eR\"></block></value></block></value><next><block type=\"text_print\" id=\":G#nkI,lUH3(v~vAB.;h\"><value name=\"TEXT\"><shadow type=\"text\" id=\"Mbr%{F__rcl4mYyAZ,fr\"><field name=\"TEXT\">local network is connected</field></shadow><block type=\"text_add_str\" id=\"attbV8b$+_Hr2QW_X6=*\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"KWzci0Uxx3lk:KoQ;u~~\"><field name=\"TEXT\">Text:</field></shadow></value><value name=\"VALUE2\"><block type=\"http_get_text\" id=\"+r/B}xGJU~v+EFa!^Fw2\"></block></value></block></value><next><block type=\"label_set_text\" id=\"^l)^;FS%v#RDQ#~4zB`j\"><field name=\"NAME\">label1</field><value name=\"TEXT\"><shadow type=\"text\" id=\"!7ZSv15v%cI;P/oh%m(L\"><field name=\"TEXT\">Label</field></shadow><block type=\"text_add_str\" id=\"8DX~`I$V%`Ng4ilbCSfO\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"Y#h?Vl8t89zS-|!lA2W@\"><field name=\"TEXT\">Status Code:</field></shadow></value><value name=\"VALUE2\"><block type=\"http_get_status_code\" id=\"-Cg1g0.;T?j)x1EEsPa6\"></block></value></block></value><next><block type=\"label_set_text\" id=\"aFNfl)|H`]9yu|CVrRbb\"><field name=\"NAME\">label2</field><value name=\"TEXT\"><shadow type=\"text\" id=\"!7ZSv15v%cI;P/oh%m(L\"><field name=\"TEXT\">Label</field></shadow><block type=\"text_add_str\" id=\"CgD/E0pXvq(MbHhKL|Gt\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"PPt~Ykamez4+RCPaj0m+\"><field name=\"TEXT\">Text:</field></shadow></value><value name=\"VALUE2\"><block type=\"http_get_text\" id=\"o*=S}OsEB(:]{Hc,}/(p\"></block></value></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></next></block></statement></block><block type=\"text_print\" id=\"@NX6C]lS(r5`Iu$ziik)\" disabled=\"true\" x=\"170\" y=\"1020\"><value name=\"TEXT\"><shadow type=\"text\" id=\"vp@)8o%nLwps?#oE9R_O\"><field name=\"TEXT\">local network is connected</field></shadow><block type=\"http_get_status_code\" id=\"CzoY6]o@t[?E,/_E6xp-\" disabled=\"true\"></block></value></block>","screen":[{"simulationName":"Built-in","type":"builtin","width":240,"height":135,"scale":0.49,"screenName":"","blockId":"","screenColorType":0,"id":"builtin","createTime":1766025581178}],"logicWhenNum":0,"customList":[]}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import os, sys, io
6+
import M5
7+
from M5 import *
8+
import network
9+
from stamplc import PoEStamPLC
10+
import time
11+
import requests2
12+
13+
14+
title0 = None
15+
label0 = None
16+
label1 = None
17+
label2 = None
18+
wlan_sta = None
19+
stamplc_poe_0 = None
20+
http_req = None
21+
22+
23+
def setup():
24+
global title0, label0, label1, label2, wlan_sta, stamplc_poe_0, http_req
25+
26+
M5.begin()
27+
Widgets.fillScreen(0x000000)
28+
title0 = Widgets.Title("StamPLC PoE Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18)
29+
label0 = Widgets.Label("IP:", 2, 33, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
30+
label1 = Widgets.Label("Status Code:", 2, 65, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
31+
label2 = Widgets.Label("Text:", 2, 96, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
32+
33+
wlan_sta = network.WLAN(network.STA_IF)
34+
wlan_sta.active(False)
35+
stamplc_poe_0 = PoEStamPLC()
36+
stamplc_poe_0.ifconfig(("192.168.8.198", "255.255.255.0", "192.168.8.1", "8.8.8.8"))
37+
while not (stamplc_poe_0.isconnected()):
38+
time.sleep(1)
39+
print(".")
40+
label0.setText(str((str("IP:") + str((stamplc_poe_0.ifconfig()[0])))))
41+
print("local network is connected")
42+
print((str("IP:") + str((stamplc_poe_0.ifconfig()[0]))))
43+
44+
45+
def loop():
46+
global title0, label0, label1, label2, wlan_sta, stamplc_poe_0, http_req
47+
M5.update()
48+
if BtnA.wasPressed():
49+
print("Btn Pressed")
50+
label0.setText(str((str("IP:") + str((stamplc_poe_0.ifconfig()[0])))))
51+
label1.setText(str("Status Code:"))
52+
label2.setText(str("Text:"))
53+
http_req = requests2.get(
54+
"https://wttr.in/?format=%22%C,%20%t%22", headers={"Content-Type": "application/json"}
55+
)
56+
print((str("Status Code:") + str((http_req.status_code))))
57+
print((str("Text:") + str((http_req.text))))
58+
label1.setText(str((str("Status Code:") + str((http_req.status_code)))))
59+
label2.setText(str((str("Text:") + str((http_req.text)))))
60+
61+
62+
if __name__ == "__main__":
63+
try:
64+
setup()
65+
while True:
66+
loop()
67+
except (Exception, KeyboardInterrupt) as e:
68+
try:
69+
from utility import print_error_msg
70+
71+
print_error_msg(e)
72+
except ImportError:
73+
print("please update to latest firmware")

0 commit comments

Comments
 (0)