v.0.8.2 sync_ntp_time_task
This commit is contained in:
83
main.py
83
main.py
@@ -2,59 +2,72 @@ from app.display import NeoPixel_64x64
|
||||
from app.display.fonts import font_5x7
|
||||
from app.tryout import Font_Checker, Weather_Checker, Emoji_Checker
|
||||
from app.utils import show_system_load
|
||||
from app.utils import sync_ntp_time, get_datetime_string, get_german_datetime # Time-related functions
|
||||
from app.utils import (
|
||||
sync_ntp_time,
|
||||
get_datetime_string,
|
||||
get_german_datetime,
|
||||
) # Time-related functions
|
||||
from app.utils import SimpleCounter
|
||||
from app.web import Wlan
|
||||
import time
|
||||
import uasyncio as asyncio # type: ignore
|
||||
import uasyncio as asyncio # type: ignore
|
||||
from app.web import Wlan
|
||||
|
||||
CITY_LIST: list[str]= sorted(["Großhansdorf","Columbus", "London", "Ebeltoft", "Tokio"])
|
||||
CITY_LIST: list[str] = sorted(
|
||||
["Großhansdorf", "Columbus", "London", "Ebeltoft", "Tokio"]
|
||||
)
|
||||
|
||||
async def weather_check_task(weather_checker:Weather_Checker):
|
||||
|
||||
async def weather_check_task(weather_checker: Weather_Checker):
|
||||
while True:
|
||||
for city in CITY_LIST:
|
||||
weather_checker.check(city=city, lang="de", test_mode=False)
|
||||
print(f"Checked {city}")
|
||||
await asyncio.sleep(3 * 60) # Non-blocking sleep
|
||||
|
||||
|
||||
async def print_time_task() -> None:
|
||||
simpleCnt: SimpleCounter = SimpleCounter()
|
||||
while True:
|
||||
dt1:int = get_datetime_string()
|
||||
dt2:int = get_german_datetime()
|
||||
simpleCnt+=1
|
||||
print(f"print_time_task running... {simpleCnt.value%16} {dt1} {dt2}")
|
||||
dt1: int = get_datetime_string()
|
||||
dt2: int = get_german_datetime()
|
||||
simpleCnt += 1
|
||||
print(f"print_time_task running... {simpleCnt.value % 16} {dt1} {dt2}")
|
||||
await asyncio.sleep(10)
|
||||
|
||||
|
||||
async def main(weather_checker:Weather_Checker)->None:
|
||||
|
||||
|
||||
async def sync_ntp_time_task() -> None:
|
||||
while True:
|
||||
sync_ntp_time()
|
||||
await asyncio.sleep(60)
|
||||
|
||||
|
||||
async def main(weather_checker: Weather_Checker) -> None:
|
||||
# Run both tasks concurrently
|
||||
await asyncio.gather(weather_check_task(weather_checker), print_time_task())
|
||||
|
||||
await asyncio.gather(
|
||||
sync_ntp_time_task(), weather_check_task(weather_checker), print_time_task()
|
||||
)
|
||||
|
||||
|
||||
# Programm Startpunkt
|
||||
if __name__ == '__main__':
|
||||
display = NeoPixel_64x64()
|
||||
wlan: Wlan = Wlan( )
|
||||
wlan.connect( ssid="Wokwi-Wlan", password="12345678")
|
||||
if __name__ == "__main__":
|
||||
display = NeoPixel_64x64()
|
||||
wlan: Wlan = Wlan()
|
||||
wlan.connect(ssid="Wokwi-Wlan", password="12345678")
|
||||
|
||||
sync_ntp_time()
|
||||
# font_checker : Font_Checker = Font_Checker( display)
|
||||
# font_checker.fonts_check(pretty=False)
|
||||
|
||||
# font_checker : Font_Checker = Font_Checker( display)
|
||||
# font_checker.fonts_check(pretty=False)
|
||||
# emoji_checker : Emoji_Checker = Emoji_Checker(display)
|
||||
# emoji_checker.check()
|
||||
|
||||
# emoji_checker : Emoji_Checker = Emoji_Checker(display)
|
||||
# emoji_checker.check()
|
||||
# tryout.weather_check(display, test_mode=False)
|
||||
display.set_font(font_5x7)
|
||||
weather_checker: Weather_Checker = Weather_Checker(display=display)
|
||||
|
||||
# tryout.weather_check(display, test_mode=False)
|
||||
display.set_font(font_5x7)
|
||||
weather_checker: Weather_Checker = Weather_Checker( display=display)
|
||||
|
||||
|
||||
|
||||
# while True:
|
||||
# for city in sorted(CITY_LIST):
|
||||
# weather_checker.check(city=city, lang="de", test_mode=False)
|
||||
# time.sleep(5*60)
|
||||
# while True:
|
||||
# for city in sorted(CITY_LIST):
|
||||
# weather_checker.check(city=city, lang="de", test_mode=False)
|
||||
# time.sleep(5*60)
|
||||
|
||||
# show_system_load()
|
||||
asyncio.run(main(weather_checker))
|
||||
# show_system_load()
|
||||
asyncio.run(main(weather_checker))
|
||||
|
||||
Reference in New Issue
Block a user