That’s really long, for me it took around 2 weeks from UK --> NL, maybe Pimoroni has a Track&Trace / can contact Royal Mail?
Already contacted them, it was sent track and trace, but once its handed over to Canada Post I can’t track it. The Royal Mail tracking number doesn’t work with Canada Post’s tracking. And Canada Post doesn’t give any number back to Royal mail or Pimoroni.
It will eventually show as delivered once I sign for it, but that’s it. I have no way of knowing if its out for delivery etc.
If I don’t get it by end of week they said they would resend it. So now its just hurry up and wait. ;)
My missing order just showed up. I will be getting it setup today or tomorrow. Really sore today so might be tomorrow. I have chronic pain issues that sometimes get in the way of me having fun.
Good to hear that it finally arrived. No stress with it, caring about health is way more important than anything else.
Finally have it installed and tested OK. It rained almost every day straight for a week and that spiked my chronic pain issues. Then on the few sunny days we had, I was playing catchup doing yard work like mowing the lawn lol. Managed to put a few hours aside to setup the Unicorn Mini.
@placebo83 , if you post what code you have now, what your working on, I’ll be happy to test run it on mine. I don’t really want to start all over from scratch. ;)
Good to hear that, I’ve been busy with a Pirate Audio but that’s even causing more trouble than the Unicorn HAT Mini. Here’s my last code:
#!/usr/bin/env python3
import time
import font5x5
from colorsys import hsv_to_rgb
from unicornhatmini import UnicornHATMini
print("""
Unicorn HAT Mini: Clock
Displays hours and minutes in text,
plus a seconds progress bar.
Press Ctrl+C to exit!
""")
# Display a progress bar for seconds
# Displays a dot if False
DISPLAY_BAR = False
# Brightness of the seconds bar and text
BRIGHTNESS = 0.3
# Uncomment the below if your display is upside down
# (e.g. if you're using it in a Pimoroni Scroll Bot)
# unicornhatmini.rotate(degrees=180)
unicornhatmini = UnicornHATMini()
while True:
unicornhatmini.clear()
# Grab the "seconds" component of the current time
# and convert it to a range from 0.0 to 1.0
float_sec = (time.time() % 60) / 59.0
# Multiply our range by 15 to spread the current
# number of seconds over 15 pixels.
#
# 60 is evenly divisible by 15, so that
# each fully lit pixel represents 4 seconds.
#
# For example this is 28 seconds:
# [x][x][x][x][x][x][x][ ][ ][ ][ ][ ][ ][ ][ ]
# ^ - 0 seconds 59 seconds - ^
seconds_progress = float_sec * 15
if DISPLAY_BAR:
# Step through 15 pixels to draw the seconds bar
for y in range(15):
# For each pixel, we figure out its brightness by
# seeing how much of "seconds_progress" is left to draw
# If it's greater than 1 (full brightness) then we just display 1.
current_pixel = min(seconds_progress, 1)
# Multiply the pixel brightness (0.0 to 1.0) by our global brightness value
unicornhatmini.set_pixel(y + 1, 6, current_pixel * BRIGHTNESS)
# Subtract 1 now we've drawn that pixel
seconds_progress -= 1
# If we reach or pass 0, there are no more pixels left to draw
if seconds_progress <= 0:
break
else:
# Just display a simple dot
unicornhatmini.set_pixel(int(seconds_progress), 6, 255, 0, 0)
# Display the time (HH:MM) in a 5x5 pixel font
unicornhatmini.write_string(
time.strftime("%H:%M"),
x=0, # Align to the left of the buffer
y=0, # Align to the top of the buffer
font=font5x5, # Use the font5x5 font we imported above
brightness=BRIGHTNESS # Use our global brightness value
)
# int(time.time()) % 2 will tick between 0 and 1 every second.
# We can use this fact to clear the ":" and cause it to blink on/off
# every other second, like a digital clock.
# To do this we clear a rectangle 8 pixels along, 0 down,
# that's 1 pixel wide and 5 pixels tall.
if int(time.time()) % 2 == 0:
unicornhatmini.clear()
# Display our time and sleep a bit. Using 1 second in time.sleep
# is not recommended, since you might get quite far out of phase
# with the passing of real wall-time seconds and it'll look weird!
#
# 1/10th of a second is accurate enough for a simple clock though :D
unicornhatmini.show()
time.sleep(0.1)
Thank you, saved for a look see tomorrow some time.
I think I may have posted in that Pirate Audio thread?
I have one of the original Pirate Radio setups with a pHat Beat. I listen to internet radio with VLC radio. It’s playing my favorite classic rock in the background as I type this. =)
I’m taking my favorite liquid equivalent mussel relaxer and pain killer, run & coke. =)
In moderation of course. ;) So just going to sit back and relax a bit tonight.
Yes I’m reading a lot of Pirate Audio threads here, and also the Mopify forums. It’s just frustrating if things don’t work like they should out of the box, but I don’t give up and when it finally works I’m happy. I also mainly intend to use it for internet radio (also classic rock btw) and some Spotify. Enjoy your evening and good luck tomorrow.
I had it easy I guess, I never messed with Spotify etc. I just did this.
I will be having a go at the clock code latter on. That particular Pi build is sitting on top of the media hutch in our bedroom. We have two in that room, one has the TV cable box and my XBOX setup on it. The second one I use for a dresser and the odd Pi project.
It’s basically a low wide dresser with two small cubby holes at the top for your clock radio etc. And a nice open flat top.
That’s where my Unicorn Mini is at the moment. So I’ll have to wait for my wife to get up before tinkering with it.
Am I also going to need the modified init.py? And if yes, were do I get it from and where do i put it?
@placebo83 I went to your github page linked to above. The install instructions are the same as for the pimoroni github page. sudo pip install unicornhatmini
I downloaded your zip file, unziped it, and copied it to my Pi.
Doing the
cd unicornhatmini-python-master
sudo ./install.sh
gets me an command not found error.
Renamed the folder too unicornhatmini-python
cd unicornhatmini-python
sudo ./install.sh
gets me the same error.
Currently I’m getting a no module named font5x5 error in line 4
Ow sorry the github page is not really updated because I don’t know how to download/upload that stuff easy to my raspberry 😅
Anyways what I also did was get the font script from the Scroll HAT Mini and copy/pasted it in the /examples directory, after that the font5x5 error didn’t show up anymore
Ok, not a big deal. I’ll have anther go tonight or tomorrow.
EDIT: I went with some simpler code and left out the seconds progress bar.
I was getting a font error until I copied my file to the unicornminihat examples folder on my Pi. There is a 5x5.ttf file in there and that fixed that error.
The error I get now is line 33, UnicornHatMini object has no attribute write_string.
#!/usr/bin/env python3
import time
import sys
from colorsys import hsv_to_rgb
from PIL import Image, ImageDraw, ImageFont
from unicornhatmini import UnicornHATMini
print("""
Unicorn HAT Mini: Clock
Displays hours and minutes in text,
Press Ctrl+C to exit!
""")
# Uncomment the below if your display is upside down
# (e.g. if you're using it in a Pimoroni Scroll Bot)
# unicornhatmini.rotate(degrees=180)
unicornhatmini = UnicornHATMini()
unicornhatmini.set_brightness(0.5)
font = ImageFont.truetype("5x7.ttf", 8)
while True:
unicornhatmini.clear()
# Display the time (HH:MM) in a 5x5 pixel font
unicornhatmini.write_string(
time.strftime("%H:%M"),
x=0, # Align to the left of the buffer
y=0, # Align to the top of the buffer
)
# int(time.time()) % 2 will tick between 0 and 1 every second.
# We can use this fact to clear the ":" and cause it to blink on/off
# every other second, like a digital clock.
# To do this we clear a rectangle 8 pixels along, 0 down,
# that's 1 pixel wide and 5 pixels tall.
if int(time.time()) % 2 == 0:
unicornhatmini.clear()
# Display our time and sleep a bit. Using 1 second in time.sleep
# is not recommended, since you might get quite far out of phase
# with the passing of real wall-time seconds and it'll look weird!
#
# 1/10th of a second is accurate enough for a simple clock though :D
unicornhatmini.show()
time.sleep(0.1)
Sadly the library isn’t compatible with the Pirate Audio somehow, but was worth a try anyways :)
I checked back and with me it also was the missing write_string, but also to copy it into the init didn’t help, see this one: Adjust Python examples
I managed to get a working clock by editing the text.py example. It scrolls across the screen but its a start in the right direction. It’s actually more of how I want to do it anyway.
I eventually want it to show date, time, temperature, humidity, pressure etc.
If you put this file in the examples folder where the font file is it won’t error.
Or copy the 5x7.ttf file to the same folder you save this file and run it from.
EDIT: Just replaced the following with a new working version. As near as I can tell its working. The time changed with what Raspbian displayed in the tray.
#!/usr/bin/env python3
import time, datetime
import sys
from colorsys import hsv_to_rgb
from PIL import Image, ImageDraw, ImageFont
from unicornhatmini import UnicornHATMini
# The text we want to display. You should probably keep this line and replace it below
# That way you'll have a guide as to what characters are supported!
#text = time.strftime("%A %B %-d %-I:%M:%p")
unicornhatmini = UnicornHATMini()
rotation = 0
if len(sys.argv) > 1:
try:
rotation = int(sys.argv[1])
except ValueError:
print("Usage: {} <rotation>".format(sys.argv[0]))
sys.exit(1)
unicornhatmini.set_rotation(rotation)
display_width, display_height = unicornhatmini.get_shape()
print("{}x{}".format(display_width, display_height))
# Do not look at unicornhatmini with remaining eye
unicornhatmini.set_brightness(0.1)
# Load a nice 5x7 pixel font
# Granted it's actually 5x8 for some reason :| but that doesn't matter
font = ImageFont.truetype("5x7.ttf", 8)
# Measure the size of our text, we only really care about the width for the moment
# but we could do line-by-line scroll if we used the height
#text_width, text_height = font.getsize(text)
# Create a new PIL image big enough to fit the text
#image = Image.new('P', (text_width + display_width + display_width, display_height), 0)
#draw = ImageDraw.Draw(image)
# Draw the text into the image
#draw.text((display_width, -1), text, font=font, fill=255)
offset_x = 0
while True:
text = time.strftime("%A %B %-d %-I:%M:%p")
text_width, text_height = font.getsize(text)
image = Image.new('P', (text_width + display_width + display_width, display_height), 0)
draw = ImageDraw.Draw(image)
draw.text((display_width, -1), text, font=font, fill=255)
for y in range(display_height):
for x in range(display_width):
if image.getpixel((x + offset_x, y)) == 255:
unicornhatmini.set_pixel(x, y, 0, 255, 0)
else:
unicornhatmini.set_pixel(x, y, 0, 0, 0)
offset_x += 1
if offset_x + display_width > image.size[0]:
offset_x = 0
unicornhatmini.show()
time.sleep(0.05)
It appears like its not updating the time, so more work is needed. I think the text= needs to be in the while true section. I moved it but get an error, so some of the other stuff needs moving too. I moved the while true and changed some indents and no errors, but my display in blank / black.
EDIT: Think I fixed it. I replaced the above with the latest code I’m running.
Awesome! It works and I like it a lot, quite busy at the moment, but when I have time I will check the script also to change the time to 24 hour clock. Keep up the good work!
https://strftime.org/
|%H|Hour (24-hour clock) as a zero-padded decimal number.|07|
|%-H|Hour (24-hour clock) as a decimal number. (Platform specific)|7|
Already did that, worked perfect!