From f74fede51754ba621f518b7464d174d30f3faeaf Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Sun, 25 Oct 2015 22:24:02 +0100 Subject: [PATCH] Lazy load theta module. Also change wifi mode only if necessary. --- main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index d5ae052..3679d4c 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,6 @@ from machine import Pin import time -import theta led = Pin("GP16", Pin.OUT) @@ -20,10 +19,13 @@ btn.irq(trigger=Pin.IRQ_FALLING, handler=btnPressed) def home(): global wifi + if wifi.mode() != WLAN.STA: + wifi.mode(WLAN.STA) wifi.connect(config.HOME_SSID, auth=(WLAN.WPA, config.HOME_PASSWORD)) def tc(): global t, p + import theta t = theta.Theta() p = t.connect() if not p: