hugokernel / UnicornClock

A Python clock designed to run on a Pimoroni GalacticUnicorn.
MIT License
53 stars 2 forks source link
cosmicunicorn galactic galacticunicorn pimoroni python raspberry raspberry-pi-pico raspberrypi unicorn

UnicornClock

Unicorn Clock Example

Example video

Features

Compatibility

Installation

Copy the files into the device via Thonny or the way you want.

Create a secrets.py file:

WLAN_SSID = 'Your WLAN SSID'
WLAN_PASSWORD = 'Your secrets password'

Example

The example.py display the calendar widget and the clock with an effect when number changes.

Use

Here is a detailed example explaining how to use this project.

import uasyncio as asyncio

# This imports is useful to configure the screen
from galactic import GalacticUnicorn
from picographics import DISPLAY_GALACTIC_UNICORN, PicoGraphics

# We want to update the brightness and change the position
from unicornclock import Brightness, Clock, Position

# Import the rainbow move effect
from unicornclock.effects import RainbowMoveEffect

# Load the GalacticUnicorn and PicoGraphics
galactic = GalacticUnicorn()
graphics = PicoGraphics(DISPLAY_GALACTIC_UNICORN)

# Here, we declare a rainbow clock by using the RainbowMoveEffect with Clock
class RainbowMoveEffectClock(RainbowMoveEffect, Clock):
    pass

async def example():
    # Create Brightness object for handling the brightness of the screen
    # depending of the brightness of the piece (screens have light sensors).
    brightness = Brightness(galactic)

    # Creating the Clock
    clock = RainbowMoveEffectClock(
        galactic,
        graphics,
        x=Position.CENTER,
        show_seconds=True,
        am_pm_mode=False,
    )

    # And now, we creating the 2 tasks
    asyncio.create_task(brightness.run())
    asyncio.create_task(clock.run())

loop = asyncio.get_event_loop()
loop.run_until_complete(example())
loop.run_forever()

TODO

Here is what I plan to add and feel free to make suggestions or code submissions.

Contribute