#!/usr/bin/python # -*- coding: utf-8 -*- # qrmovie import time # need to use git://github.com/mozillazg/python-qrcode.git import qrcode from PIL import Image, ImageFont import ImageOps # uses bgreat's SPI code; see # raspberrypi.org/phpBB3/viewtopic.php?f=32&t=9814&p=262274&hilit=nokia#p261925 import nokiaSPI noki = nokiaSPI.NokiaSPI() # create display device qr = qrcode.QRCode(version=1, # V.1 QR Code: 21x21 px error_correction=qrcode.constants.ERROR_CORRECT_M, box_size=2, border=1) bg = Image.new('1', (84, 48)) # blank (black) image background # intro noki.cls() noki.led(0) time.sleep(3) for i in range(0,769,32): noki.led(i) time.sleep(0.04) # display is 14 columns by 8 rows noki.centre_word(1, 'scruss.com') noki.centre_word(3, 'presents') time.sleep(3) noki.cls() noki.centre_word(1, 'qrclock') noki.centre_word(2, 'the') noki.gotorc(3,3) noki.text("[Q]uite") noki.gotorc(4,3) noki.text("[R]ubbish") noki.gotorc(5,3) noki.text(" Clock") time.sleep(3) elapsed=0 start_time = time.time() while (elapsed<12): qr.clear() newbg = bg.copy() # copy blank background s = time.strftime('%Y-%m-%d %H:%M:%S') qr.add_data(s) # make QR Code of YYYY-MM-DD HH:MM:SS qr.make() qrim = qr.make_image() # convert qrcode object to PIL image qrim = qrim.convert('L') # make greyscale qrim = ImageOps.invert(qrim) # invert colours: B->W and W->B qrim = qrim.convert('1') # convert back to 1-bit newbg.paste(qrim, (18, 0)) # paste QR Code into blank background noki.show_image(newbg) # display code on LCD time.sleep(0.4) # pause before next display elapsed = time.time() - start_time noki.cls() noki.centre_word(1, 'for') noki.centre_word(2, 'more') noki.centre_word(3, 'details') time.sleep(3) noki.cls() noki.load_bitmap("blogpost-nokia.bmp", True) time.sleep(7) noki.cls() noki.centre_word(3, 'fin') noki.centre_word(5, 'scruss, 2013') time.sleep(1) for i in range(768,-1,-32): noki.led(i) time.sleep(0.05) time.sleep(1) noki.cls()
(This source, plus nokiaSPI class: qrclock-movie.zip)
Lines 43-58 show off the QR clock for a maximum of 12 seconds. Any more, and you’d get really bored.
The screen handling functions I used are:
- cls() — Clears the screen.
- led(brightness) — sets the backlight to brightness. For me, full brightness is at 768. A value of zero turns the backlight off. If you don’t have the screen LED connected to one of the Raspberry Pi’s PWM pin, this will either be full on (for any brightness >= 1), or off, for brightness=0. This is used to fade up the screen in lines 24-26, and fade it down far too theatrically in lines 72-74.
- show_image(PILImage) — display a single bit depth black and white Python Imaging Library object PILImage. This can be no larger than 84×48 pixels.
- load_bitmap(file, Invert) — load a single bit depth black and white BMP file of maximum size 48×84. If Invert is true, keep the colours as they are, otherwise swap black and white to make a negative image. nokiSPI flips images by 90°, so the image I loaded to show the URL of the blog post looks like this:
(I know, I could have generated this in code, but I’d already made the image using qrencode. I couldn’t be bothered working out the image size and offsets.)
The text handling functions I used are:
- gotorc(row, column) — move the text cursor to row, column. The screen only has 14 columns by 8 rows if you use the standard 6×6 pixel font, so keep your text short to avoid disappointment.
- text(text) — write text at the current cursor position.
- centre_word(row, text) — write text centred in row row. Since the text rows are a maximum of 14 columns, text with an odd number of characters will appear slightly off-centre.
There are many more functions in the nokiaSPI class; watch the demo, have a dig through the source and see what you can use.
Copyright Info: The Star Spangled Banner
Your video, The Star Spangled Banner , may include content that is owned or administered by these entities:
- Entity: Music Publishing Rights Collecting Society Content Type: Musical Composition
What should I do?
No action is required on your part. Your video is still available worldwide. In some cases ads may appear next to your video.
What can I do about my video’s status?
Please note that the video’s status can change, if the policies chosen by the content owners change. You may want to check back periodically to see if you have new options available to you.
Under certain circumstances, you may dispute this copyright claim. These are:
- if the content is mistakenly identified and is actually completely your original creation;
- if you believe your use does not infringe copyright (e.g. it is fair use under US law);
- if you are actually licensed by the owner to use this content.
I need more information. I want to learn more about the dispute process.
Please take a few minutes to visit our Help Center section on Policy and Copyright Guidelines, where you can learn more about copyright law and our Content Identification Service.
A little bit of silliness for Thanksgiving:
This took almost no time to put together. The “speaker” is a Tim Hortons cup with a cheap piezo glued to the base. What makes the Arduino sing is the Tone Library running its RTTTL demo sketch, with the anthem itself pasted in from a rather old Nokia Ringtones library.
Genius: Cape Wind Comedy Daily.
And we thought this was teh k00l v1d in 1981: Landscape – “Einstein a Go-Go”