56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
import time
|
|
import machine
|
|
import uasyncio as asyncio
|
|
import DS3231
|
|
import Button
|
|
import LED
|
|
import HousingLEDs
|
|
import Buzzer
|
|
import StepperL298M
|
|
|
|
import Screens
|
|
|
|
#Async
|
|
loop = asyncio.get_event_loop()
|
|
|
|
#Initialise the time module with the RTC
|
|
try:
|
|
dsRtc = DS3231.DS3231(machine.I2C(sda = machine.Pin(17), scl=machine.Pin(18)))
|
|
rtc = machine.RTC()
|
|
rtc.init(dsRtc.DateTime()+[0])
|
|
except:
|
|
print("Error on DS3231-Inititalisation")
|
|
|
|
#Init Buzzer
|
|
buzzer = Buzzer.Buzzer(pin=2)
|
|
|
|
#Initalise the Motors
|
|
stepperminu = StepperL298M.Stepper([19,21,22,23],inverted=False)
|
|
stepperhour = StepperL298M.Stepper([12,27,26,25],inverted=True)
|
|
|
|
#Init LEDs
|
|
housingLEDs = HousingLEDs.LEDs(pin=16)
|
|
|
|
leftButtonLED = LED.LED(13)
|
|
middleButtonLED = LED.LED(33)
|
|
rightButtonLED = LED.LED(32)
|
|
|
|
#Init Buttons
|
|
leftButton = Button.Button(pin=34,inverted=True)
|
|
middleButton = Button.Button(pin=39,inverted=True)
|
|
rightButton = Button.Button(pin=36,inverted=True)
|
|
|
|
|
|
buttons = (leftButton,middleButton,rightButton)
|
|
leds = (leftButtonLED,middleButtonLED,rightButtonLED)
|
|
|
|
modus = 0
|
|
screens = (Screens.ClockScreen(stepperhour,stepperminu,buttons,leds),\
|
|
Screens.SettingsScreen(stepperhour,stepperminu,buttons,leds,housingLEDs,buzzer))
|
|
async def run_screens():
|
|
global modus,screens
|
|
while True:
|
|
await screens[modus%len(screens)]
|
|
modus += 1
|
|
|
|
loop.run_until_complete(run_screens()) |