Revision: 14 http://acme-dev.svn.sourceforge.net/acme-dev/?rev=14&view=rev Author: claudyus Date: 2010-02-15 16:31:05 +0000 (Mon, 15 Feb 2010) Log Message: ----------- fox.py: add display class, usable with 4D system oled Modified Paths: -------------- python/fox.py Modified: python/fox.py =================================================================== --- python/fox.py 2010-02-11 13:42:04 UTC (rev 13) +++ python/fox.py 2010-02-15 16:31:05 UTC (rev 14) @@ -1,9 +1,12 @@ -# Test - -import os.path +# This file is released under public domain. # +# 2010 - Claudio Mignanti, Sergio Tanzilli +# # $Id$ +import os.path +import pyserial + class pin(): kernelid_table = { @@ -114,4 +117,27 @@ def off(self): if self.kernelid<>-1: self.setValue(0) - + +class display: + """ This class can be used to controll 4D System oled display +attacched to serial port. If no arg is supply if will use ttyS3 as default. + """ + def __init__(self, port="/dev/ttyS3"): + ser = serial.Serial(port, 115200, 1, + serial.PARITY_NONE, + serial.STOPBITS_ONE, + serial.EIGHTBITS + ) + ser.write("U") # Autobaud char + ser.read(1) + + def clear(self): + """Clear screen""" + ser.write("E") + ser.read(1) + + def write(self, string, x=0, y=0): + """Write string to x,y position""" + ser.write("s%c%c%c%c%c%s%c" % (int(x),int(y),1,0xFF,0xFF,string,0x00)) + ser.read(1) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.