From b19a68156515efe357f355c9fd3682a9dfb2a446 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Mon, 11 Jun 2018 15:33:52 +0100 Subject: [PATCH] i keep forgetting how class declarations work in python --- init_sample.py | 33 +++++++++++++++++---------------- main.py | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/init_sample.py b/init_sample.py index 0401665..62cde2a 100644 --- a/init_sample.py +++ b/init_sample.py @@ -1,16 +1,17 @@ -def __init__(self, hw): - #Basic script to print module family, variant, and IP address - from network import WLAN as wlan, STA_IF as staif - from time import sleep_ms - if hw.features.display.oled: - oled = hw.oled.handle - oled.text("uPyConfig!",0,0) - oled.text(hw.family,0,8) - oled.text(hw.variant,0,16) - oled.text(wlan(staif).ifconfig()[0],0,24) - oled.show() - else: - print(hw.family) - print(hw.variant) - print(wlan(staif).ifconfig()[0]) - sleep_ms(1000) +class PrintHWInfo: + def __init__(self, hw): + #Basic script to print module family, variant, and IP address + from network import WLAN as wlan, STA_IF as staif + from time import sleep_ms + if hw.features.display.oled: + oled = hw.oled.handle + oled.text("uPyConfig!",0,0) + oled.text(hw.family,0,8) + oled.text(hw.variant,0,16) + oled.text(wlan(staif).ifconfig()[0],0,24) + oled.show() + else: + print(hw.family) + print(hw.variant) + print(wlan(staif).ifconfig()[0]) + sleep_ms(1000) diff --git a/main.py b/main.py index 7fefcdc..d6575b0 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,6 @@ import uPyConfig hw = uPyConfig.esp32(variant='wemos-lolin32') #print family, variant and IP address (using oled, if available on-board) import init_sample -init_sample(hw) +init_sample.PrintHWInfo(hw) # Main app