PyMaOrb: Python module for LK204-25-USB displays


Moderators: Henry, Mods

Post Reply
Posts: 8
Joined: Sat May 08, 2010 7:20 am
Location: Norway

PyMaOrb: Python module for LK204-25-USB displays

Post by zyprexa »

Here is a Python module for communicating with LK204-25-USB display (and compatible displays?). Read the source before using, along with your display's manual. It uses the pyserial library. Event if it doesn't work with your display model, the source should give you an idea of how you can program your display using Python.

Linux/Windows example:

Code: Select all

# -*- coding: utf-8 -*-

import PyMaOrb

DISPLAY = PyMaOrb.LCDDisplay('/dev/ttyUSB0',19200)
# i.e DISPLAY = PyMaOrb.LCDDisplay(2,19200) , on windows, where 2 is the comport

DISPLAY.Write("Wake up Neo...")

print "Display version is: "+ str( DISPLAY.ReadVersionNumber() )
Example for creating custom characters for startup screen:
Don't run this, or it will replace the original startup characters!

Code: Select all

## Create the characters for a small startup logo shaped like a flame on a stick thingy
#DISPLAY.SaveStartupScreenCustomCharacters(0, ('00100','00000','00000','00000','00000','00010','00000','00001'))
#DISPLAY.SaveStartupScreenCustomCharacters(1, ('00011','00111','01110','01100','01110','00100','00011','00001'))
#DISPLAY.SaveStartupScreenCustomCharacters(2, ('00100','00110','00110','01110','01011','11010','10110','10111'))
#DISPLAY.SaveStartupScreenCustomCharacters(3, ('11110','11110','11110','11110','10111','01111','01111','11111'))
#DISPLAY.SaveStartupScreenCustomCharacters(4, ('10000','00000','00010','00000','00000','10000','01000','01100'))
#DISPLAY.SaveStartupScreenCustomCharacters(5, ('10110','11010','01010','10010','10100','11000','10000','00000'))
#DISPLAY.SaveStartupScreenCustomCharacters(6, ('11111','11111','00000','00000','00000','00000','00000','00000'))
#DISPLAY.SaveStartupScreenCustomCharacters(7, ('00000','00000','00000','01000','00000','00000','00000','00100'))

## Create startup screen
#DISPLAY.ChangeStartupScreen("              "+chr(7)+"       Morten's   "+ chr(0) + chr(2) + chr(4) +"      Brannmur   "+ chr(1) + chr(3) + chr(5)+"                "+chr(6)*5+"   ")
Example medium and large numbers:

Code: Select all

DISPLAY.PlaceMediumDigit(1,2,2) # place a medium size digit "1" in row 2 column 2

DISPLAY.PlaceLargeDigit(2,1)	# place a large digit "2" in column 1
I have not had the chance to test it on other displays, and also some functions are missing, like 1-Wire and some Data security. (they are there, just pass'ed)

It's licensed cc by-nc-sa.

Hope you find it useful and any feedback is appreciated! Sorry for typos, missing comments and such! cheers! <:)

- Morten
Python module PyMaOrb v1.2
(10.8 KiB) Downloaded 447 times

Post Reply