From b07a3820b29e4118131da3c0ed3cb057b947c3d3 Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 11 Apr 2023 18:52:21 +0800 Subject: [PATCH] ip viewer upon boot --- stockTicker.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/stockTicker.py b/stockTicker.py index ddc2eb7..4052889 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -5124,6 +5124,28 @@ class StockTicker(): return self.stitchImage(image_list) + + def ip_viewer(self): + + font = ImageFont.load("./fonts/6x10.pil") + + image = Image.new('RGB', (128, 32)) + + hostname = str(os.popen('hostname').read()).strip() + ".local:1024" + ip_add = str(os.popen('hostname -I').read()).replace(" ", "").strip() + ":1024" + mac_add = str(os.popen('cat /sys/class/net/wlan0/address').read()).replace(" ", "").strip() + + hostname_img = self.textImage(hostname, font, r = 255, g = 255 , b = 255) + ip_img = self.textImage(ip_add, font, r = 255, g = 255 , b = 255) + mac_img = self.textImage(mac_add, font, r = 255, g = 255 , b = 255) + + image.paste(hostname_img, (0,0)) + image.paste(ip_img, (0,12)) + image.paste(mac_img, (0,23)) + + stock_ticker.setImage(image) + time.sleep(10) + def displayStocks(self): @@ -5301,8 +5323,10 @@ class StockTicker(): #stock_ticker.setImage(start_image) time.sleep(2) self.resetMatrix() - - + + self.ip_viewer() + time.sleep(2) + self.resetMatrix() def run_intro_screen(self): dct = {"feature": "Custom Messages", "speed": "Medium", "animation": "Down", "title": False, "messages": [{"name": "welcome", "text": "Welcome to Fintic!", "text_colour": "White", "size": "Large", "background_colour": "Black"}, {"name": "get_started", "text": "To get started, connect your device to the \"Fintic Hotspot\" and access \"fintic.local:1024\" on your web browser. You can connect your ticker to Wi-Fi there.", "text_colour": "White", "size": "Small", "background_colour": "Black"}]}