Python module interface to Ciseco Pi-LITE LED matrix through serial port
Stephen Blythe 2014
This python module provides an interface to the Ciseco Pi-LITE LED matrix through the Raspberry Pi's serial port.
Before use, you MUST follow the instructions at http://openmicros.org/index.php/articles/94-ciseco-product-documentation/raspberry-pi/283-setting-up-my-raspberry-pi to prevent the Pi from using the serial port for login or console-logging.
This module contains a single class, PiLite, which you must instantiate to initialise the serial port using, for example:
import pilite pilite=pilite.PiLite()
Then call the other methods using the
test.py shows examples of use.
A note on co-ordinates
The PiLite has 9 rows each containing 14 LEDs. In this library I have chosen to stick to the more usual convention of numbering from 0, rather than Ciseco's preferred convention of numbering from 1. So, if you use $$$ commands directly, the rows are numbered 1-9 and the columns 1-14, but if you call the methods provided by this module, they are numbered 0-8 and 0-13 respectively.
These methods implement the commands described at http://openmicros.org/index.php/articles/94-ciseco-product-documentation/raspberry-pi/280#Using the Pi-Lite pre-loaded software
Send a string to the PiLite, can be simple text or a $$$ command.
Send a string to the PiLite, sleep until the message has been displayed (based on an estimate of the speed of the display. Due to the font not being monotype, this will wait too long in most cases.
Send a $$$ command - just pass the command itself to this function without the $$$ at the beginning or the CR at the end
Switch on all LEDs
Switch off all LEDs
Set the display speed. The parameter is the number of milliseconds between each column scrolling off the display.
Set the "frame buffer". fb is a string of "1" and "0" for each pixel, starting with the top row from left to right.
Set the "frame buffer". All whitespace is removed from pattern, plus x/y axes are transposed in the string, and '.' and '*' may be used in place of '0' and '1'. This allows more "friendly" multi-line string pictures to be passed.
Sets the "frame buffer" to a random pattern of pixels.
Assuming a vertical bar graph using each column of the display, set column "index" to percentage "value". Columns are indexed 0-13 from left to right
Assuming a horizontal bar graph with each bar using 5 rows of the display, set row "index" to percentage "value". Rows are indexed 0-1 from top to bottom.
Set pixel at "x,y" to "state" where state can be one of "ON", "OFF" or "TOGGLE".
Switch on pixel at "x,y"
Switch off pixel at "x,y"
Toggle pixel at "x,y"
Scroll the whole display "value" columns to the left. Use negative values to scroll to the right.
Scroll the whole display "value" columns to the left.
Scroll the whole display "value" columns to the right.
Display character "char" with its top left at "x,y"