small fixes
This commit is contained in:
parent
8a75738d6d
commit
1ba5bf4cab
2
LED.py
2
LED.py
@ -30,6 +30,8 @@ class LED():
|
|||||||
toWait = min(50,blinkWaitMs)
|
toWait = min(50,blinkWaitMs)
|
||||||
await asyncio.sleep_ms(toWait)
|
await asyncio.sleep_ms(toWait)
|
||||||
waited += toWait
|
waited += toWait
|
||||||
|
if self.blinkRate == None:
|
||||||
|
break
|
||||||
blinkWaitMs = int(500 / self.blinkRate)
|
blinkWaitMs = int(500 / self.blinkRate)
|
||||||
|
|
||||||
def toggle(self):
|
def toggle(self):
|
||||||
|
@ -93,6 +93,7 @@ class InitHandsScreen():
|
|||||||
HW.stepperminu.rotateTo(0)
|
HW.stepperminu.rotateTo(0)
|
||||||
HW.stepperhour.rotateTo(0)
|
HW.stepperhour.rotateTo(0)
|
||||||
HW.housingLEDs.upper((50,50,50))
|
HW.housingLEDs.upper((50,50,50))
|
||||||
|
HW.leds[1].setOffState(pwmDuty=500,blinkRate=1.2)
|
||||||
timeScreen = Get2PositionsScreen(\
|
timeScreen = Get2PositionsScreen(\
|
||||||
startTime=(0,0),\
|
startTime=(0,0),\
|
||||||
onStart=lambda _: HW.buzzer.playSound(HW.Buzzer.BEEP),\
|
onStart=lambda _: HW.buzzer.playSound(HW.Buzzer.BEEP),\
|
||||||
@ -102,6 +103,7 @@ class InitHandsScreen():
|
|||||||
HW.stepperhour.reset() # Set the new Zero
|
HW.stepperhour.reset() # Set the new Zero
|
||||||
HW.stepperminu.reset()
|
HW.stepperminu.reset()
|
||||||
HW.housingLEDs.fill((0,0,0))
|
HW.housingLEDs.fill((0,0,0))
|
||||||
|
HW.leds[1].setOffState()
|
||||||
|
|
||||||
class SetAlarmTimeScreen():
|
class SetAlarmTimeScreen():
|
||||||
def setAlarmTime(self,selectedTime):
|
def setAlarmTime(self,selectedTime):
|
||||||
@ -247,7 +249,6 @@ class Get2PositionsScreen():
|
|||||||
self.mode=0 # 0: Minutes, 1: Hours
|
self.mode=0 # 0: Minutes, 1: Hours
|
||||||
HW.stepperminu.rotateTo(-(self.pickedTime[1])/12)
|
HW.stepperminu.rotateTo(-(self.pickedTime[1])/12)
|
||||||
HW.stepperhour.rotateTo(-(self.pickedTime[0])/12)
|
HW.stepperhour.rotateTo(-(self.pickedTime[0])/12)
|
||||||
HW.leds[1].setOffState(blinkRate=1.2)
|
|
||||||
for number,button in enumerate(HW.buttons):
|
for number,button in enumerate(HW.buttons):
|
||||||
button.setCallbacks(\
|
button.setCallbacks(\
|
||||||
onPushDown=lambda i=number:self.onButtonPressed(i),\
|
onPushDown=lambda i=number:self.onButtonPressed(i),\
|
||||||
@ -261,7 +262,6 @@ class Get2PositionsScreen():
|
|||||||
await asyncio.sleep_ms(200)
|
await asyncio.sleep_ms(200)
|
||||||
if self.onPicked:
|
if self.onPicked:
|
||||||
self.onPicked(self.pickedTime)
|
self.onPicked(self.pickedTime)
|
||||||
HW.leds[1].setOnState() # Reset to default
|
|
||||||
|
|
||||||
__iter__ = __await__ # https://github.com/micropython/micropython/issues/2678
|
__iter__ = __await__ # https://github.com/micropython/micropython/issues/2678
|
||||||
def finish(self):
|
def finish(self):
|
||||||
|
29
boot.py
29
boot.py
@ -1,14 +1,28 @@
|
|||||||
import network
|
import network
|
||||||
import webrepl
|
import webrepl
|
||||||
|
import uasyncio as asyncio
|
||||||
|
|
||||||
|
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
webrepl.start()
|
webrepl.start()
|
||||||
sta_if = network.WLAN(network.STA_IF)
|
sta_if = network.WLAN(network.STA_IF)
|
||||||
sta_if.active(True)
|
sta_if.active(True)
|
||||||
sta_if.config(dhcp_hostname="stepper-clock")
|
sta_if.config(dhcp_hostname="stepper-wecker")
|
||||||
|
|
||||||
if sta_if.status() != network.STAT_GOT_IP:
|
async def connect():
|
||||||
|
connectingFor = 0
|
||||||
|
while True:
|
||||||
|
if sta_if.status() != network.STAT_GOT_IP:
|
||||||
|
if connectingFor > 5:
|
||||||
|
sta_if.disconnect()
|
||||||
|
connectingFor = 0
|
||||||
|
else:
|
||||||
|
connectingFor += 1
|
||||||
|
try:
|
||||||
availableNetworkSSIDs = [s[0].decode() for s in sta_if.scan()]
|
availableNetworkSSIDs = [s[0].decode() for s in sta_if.scan()]
|
||||||
print(availableNetworkSSIDs)
|
if len(availableNetworkSSIDs) > 0:
|
||||||
|
print("availableNetworkSSIDs:\n",availableNetworkSSIDs)
|
||||||
#load wifi credentials from file
|
#load wifi credentials from file
|
||||||
with open("wifi-credentials","r") as f:
|
with open("wifi-credentials","r") as f:
|
||||||
while sta_if.status() != network.STAT_GOT_IP:
|
while sta_if.status() != network.STAT_GOT_IP:
|
||||||
@ -22,3 +36,12 @@ if sta_if.status() != network.STAT_GOT_IP:
|
|||||||
print("Connecting to",ssid)
|
print("Connecting to",ssid)
|
||||||
sta_if.connect(ssid,password)
|
sta_if.connect(ssid,password)
|
||||||
break
|
break
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
await asyncio.sleep(2)
|
||||||
|
else:
|
||||||
|
connectingFor = 0
|
||||||
|
await asyncio.sleep(2)
|
||||||
|
|
||||||
|
loop.create_task(connect())
|
Loading…
x
Reference in New Issue
Block a user