diff --git a/examples/system/wlan_sta/wlan_sta_cores3_example.py b/examples/system/wlan_sta/wlan_sta_cores3_example.py index 988edeed..d98c53f6 100644 --- a/examples/system/wlan_sta/wlan_sta_cores3_example.py +++ b/examples/system/wlan_sta/wlan_sta_cores3_example.py @@ -1,51 +1,48 @@ -# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD -# -# SPDX-License-Identifier: MIT - import os, sys, io import M5 from M5 import * -from image_plus import ImagePlus +import network + title0 = None -image_plus0 = None +label0 = None +label1 = None +label2 = None +wlan = None def setup(): - global title0, image_plus0 + global title0, label0, label1, label2, wlan - M5.begin() - Widgets.fillScreen(0x222222) - title0 = Widgets.Title("Image+ CoreS3 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18) - image_plus0 = ImagePlus( - "https://static-cdn.m5stack.com/resource/public/assets/aboutus/m5logo2022.png", - 43, - 51, - True, - 3000, - default_img="res/img/default.png", - ) + M5.begin() + Widgets.fillScreen(0x222222) + title0 = Widgets.Title("WLAN STA CoreS3 Example", 3, 0xffffff, 0x0000FF, Widgets.FONTS.DejaVu18) + label0 = Widgets.Label("label0", 2, 81, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18) + label1 = Widgets.Label("label1", 2, 114, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18) + label2 = Widgets.Label("label2", 2, 143, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18) - image_plus0.setVisible(True) - image_plus0.set_update_period(5000) - image_plus0.set_update_enable(True) + wlan = network.WLAN(network.STA_IF) + wlan.config(reconnects=3) + wlan.connect('M5-R&D', 'echo"password">/dev/null') def loop(): - global title0, image_plus0 - M5.update() - - -if __name__ == "__main__": + global title0, label0, label1, label2, wlan + M5.update() + label0.setText(str((str('Connected?:') + str((wlan.isconnected()))))) + label1.setText(str((str('RSSI:') + str((wlan.status('rssi')))))) + label2.setText(str((str('IP:') + str((wlan.ifconfig()[0]))))) + + +if __name__ == '__main__': + try: + setup() + while True: + loop() + except (Exception, KeyboardInterrupt) as e: try: - setup() - while True: - loop() - except (Exception, KeyboardInterrupt) as e: - try: - from utility import print_error_msg - - print_error_msg(e) - except ImportError: - print("please update to latest firmware") + from utility import print_error_msg + print_error_msg(e) + except ImportError: + print("please update to latest firmware")