[Prashant Mohta] got hold of a Raspberry Pi, a 16×2 LCD display and got down to writing a simple game in Python. Pretty soon, he realized that it was cumbersome to have the Ras-Pi and LCD connected when all he wanted to do was write the code. So he wrote a simple Python module which renders the LCD on his computer display. A simple, quick, useful hack.
[Prashant]’s code relies on the use of Pygame, a set of Python modules designed for writing games. His code uses just two functions – one to define the LCD (characters and number of lines) while the other draws the characters on the screen by looking up an array. The code is just under 20 lines and available from his Github repo. It will be useful to those who are getting started on Python to help them understand some basics. Python is awesome and writing Python code is pretty simple.
This might draw some flak from the naysayers so if you’re commenting below on the merits, or not, of Python, just keep your comments civil and healthy. In the video below, unrelated to this hack, [Raymond Hettinger] talks about “What makes Python so Awesome”!
Continue reading “Virtual LCD Using Python”
[5 Volt Junkie] has built his share of Arduino projects, but never anything with Python, and certainly never anything with a GUI. After listening to Internet radio one day, a new idea for a project was born: a Raspberry Pi with a small touchscreen display for a UI and displaying soma.fm tracks. It’s finally finished, and it’s a great introduction to Python, Pygame, and driving tiny little displays with the Pi.
Playing soma.fm streams was handled by mpd and mpc, while the task of driving a 2.8″ TFT LCD was handled by the fbtft Linux framebuffer driver. This left [5 Volt Junkie] with the task of creating a GUI, some buttons, and working out how to play a few streams. This meant drawing some buttons in Inkscape, but these were admittedly terrible, so [5 Volt Junkie] gave up and turned on the TV. Tron Legacy was playing, giving him the inspiration to complete his Tron-themed music player.
The result of [5 Volt Junkie]’s work is a few hundred lines of Python with Pygame and a few multicolor skins all wrapped up in a Tron theme. It looks great, it works great, and it’s a great introduction to Python and Pygame.
Continue reading “Learning Python With Tron Radio”
The Kobo e-reader has been hacked for a while now. It’s pretty easy to enable telnet access by modifying some files. Once [Kevin] was able to telnet into the device and draw to the display, he created the Kobo Wifi Weather Forecast. This hack was inspired by the Kindle weather display that we discussed in the past, but this version runs entirely on the Kobo.
The weather report software is written in Python using the pygame library. After loading the software package onto a Kobo, a few commands are run over telnet to set up Python and run the display. Since Python and pygame run on the Kobo, it allows for direct access to the e-ink display.
There’s a lot of possibilities for a internet connected e-ink device running custom graphics code. It’s asking to be turned into any kind of display you can imagine. What ideas do you have for a custom e-ink display? Let us know in the comments.
Adafruit has a new tutorial on creating video with an RPi and pygame. The goal is to create custom user interfaces on low cost hardware, powered by the easy to use pygame library. The tutorial walks through getting your RPi set up to run pygame, creating a basic pygame script that controls the framebuffer, and drawing an oscilloscope display on the screen.
This tutorial uses Adafruit’s WebIDE as a development environment. This is an excellent solution for working on video display, since you can develop the code on a networked computer and view the shell while running your graphical application. This is very useful for debugging, since you can just print information to your WebIDE console.
There’s a lot of potential for this setup. It would be ideal for creating any kiosk application. Maybe an announcement display, interactive kiosk, or even a programmable logic controller type user interface? What else could you build with a RPi attached to a LCD touchscreen?
Check out a video of Adafruit’s display in action after the break.
Continue reading “RPi Video with Pygame”
The guys over at NerdKits put together a really informative video on a meat thermometer using predictive filtering which is viewable below. The video, supplemental text, and code is available on their website. The thermometer is constructed of a LM34 temperature sensor attached to a piece of 12 gauge solid copper wire. The thermometer signal is processed on an ATmega168 microcontroller and visualized using the pygame library for python. The real gem in this project is their excellent explanation of predictive filtering, which could easily be utilized for a large number of projects.
Continue reading “Meat thermometer using predictive filtering”