With it being the festive season and looking for something for my recent Inky PHAT purchase needing to be I used I decided to create a Countdown To Christmas.
I started off with a basic countdown in Python, where today’s date (2nd) is taken away from the 25th (Christmas Day).
Countdown to Christmas code
Then I used the guidance provided by the excellent PiMoroni to create a small program that did the Christmas Countdown and display it on the Inky PHAT.
Countdown to Christmas code outputting to InkyPHAT
The original output did not go exactly as planned….
How many days until Christmas?
But with a little modification the Inky PHAT correctly displays the amount of days until Christmas.
Inky PHAT displaying days until Christmas
——
#!/bin/python3
# geektechstuff
# import date from datetime
from datetime import date
# import the InkyPHAT library
from inky import InkyPHAT
# setting up InkyPHAT
inky_display = InkyPHAT(“black”)
inky_display.set_border(inky_display.WHITE)
# import Python Image Library modules
from PIL import Image, ImageFont, ImageDraw
# creates an image (img) and a then a canvas (draw) on the image
[…] phats (Pi Hats). I have used some of these options in past project (e.g. a temperature project, a countdown display) and installation of the hats is generally very easy, i.e. power off the Pi and push the hat onto […]
my home away from home and where I will be sharing my adventures in the world of technology and all things geek.
The technology subjects have varied over the years from Python code to handle ciphers and Pig Latin, to IoT sensors in Azure and Python handling Bluetooth, to Ansible and Terraform and material around DevOps.
One response to “Christmas Countdown (Python / Raspberry Pi)”
[…] phats (Pi Hats). I have used some of these options in past project (e.g. a temperature project, a countdown display) and installation of the hats is generally very easy, i.e. power off the Pi and push the hat onto […]
LikeLike