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)
|
||||
await asyncio.sleep_ms(toWait)
|
||||
waited += toWait
|
||||
if self.blinkRate == None:
|
||||
break
|
||||
blinkWaitMs = int(500 / self.blinkRate)
|
||||
|
||||
def toggle(self):
|
||||
|
@ -93,6 +93,7 @@ class InitHandsScreen():
|
||||
HW.stepperminu.rotateTo(0)
|
||||
HW.stepperhour.rotateTo(0)
|
||||
HW.housingLEDs.upper((50,50,50))
|
||||
HW.leds[1].setOffState(pwmDuty=500,blinkRate=1.2)
|
||||
timeScreen = Get2PositionsScreen(\
|
||||
startTime=(0,0),\
|
||||
onStart=lambda _: HW.buzzer.playSound(HW.Buzzer.BEEP),\
|
||||
@ -102,6 +103,7 @@ class InitHandsScreen():
|
||||
HW.stepperhour.reset() # Set the new Zero
|
||||
HW.stepperminu.reset()
|
||||
HW.housingLEDs.fill((0,0,0))
|
||||
HW.leds[1].setOffState()
|
||||
|
||||
class SetAlarmTimeScreen():
|
||||
def setAlarmTime(self,selectedTime):
|
||||
@ -247,7 +249,6 @@ class Get2PositionsScreen():
|
||||
self.mode=0 # 0: Minutes, 1: Hours
|
||||
HW.stepperminu.rotateTo(-(self.pickedTime[1])/12)
|
||||
HW.stepperhour.rotateTo(-(self.pickedTime[0])/12)
|
||||
HW.leds[1].setOffState(blinkRate=1.2)
|
||||
for number,button in enumerate(HW.buttons):
|
||||
button.setCallbacks(\
|
||||
onPushDown=lambda i=number:self.onButtonPressed(i),\
|
||||
@ -261,7 +262,6 @@ class Get2PositionsScreen():
|
||||
await asyncio.sleep_ms(200)
|
||||
if self.onPicked:
|
||||
self.onPicked(self.pickedTime)
|
||||
HW.leds[1].setOnState() # Reset to default
|
||||
|
||||
__iter__ = __await__ # https://github.com/micropython/micropython/issues/2678
|
||||
def finish(self):
|
||||
|
27
boot.py
27
boot.py
@ -1,14 +1,28 @@
|
||||
import network
|
||||
import webrepl
|
||||
import uasyncio as asyncio
|
||||
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
webrepl.start()
|
||||
sta_if = network.WLAN(network.STA_IF)
|
||||
sta_if.active(True)
|
||||
sta_if.config(dhcp_hostname="stepper-clock")
|
||||
sta_if.config(dhcp_hostname="stepper-wecker")
|
||||
|
||||
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()]
|
||||
print(availableNetworkSSIDs)
|
||||
if len(availableNetworkSSIDs) > 0:
|
||||
print("availableNetworkSSIDs:\n",availableNetworkSSIDs)
|
||||
#load wifi credentials from file
|
||||
with open("wifi-credentials","r") as f:
|
||||
while sta_if.status() != network.STAT_GOT_IP:
|
||||
@ -22,3 +36,12 @@ if sta_if.status() != network.STAT_GOT_IP:
|
||||
print("Connecting to",ssid)
|
||||
sta_if.connect(ssid,password)
|
||||
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