Pertelian LCD Display

I just got a Pertelian X2040 LCD for my birthday and I whipped up a little Python to start talking to it. I'm still looking for suggestions on what I should do with it...
import serial
import struct
import time

class Pertelian(object):

def __init__(self, tty='/dev/ttyUSB0'):
self.ser = serial.Serial(tty)
self.ser.open()

def __del__(self):
self.ser.close()

def Setup(self):
bytes = 0xfe, 0x38, 0xfe, 0x06, 0xfe, 0x10, 0xfe, 0x0c, 0xfe, 0x01
b = struct.pack('B' * len(bytes), *bytes)
self.ser.write(b)
time.sleep(0.5)

def Message(self, msg):
bytes = struct.pack('c' * len(msg), *msg)
for char in bytes:
self.ser.write(char)
time.sleep(0.001)

if __name__ == '__main__':
p = Pertelian()
p.Setup()
p.Message('Hello World!')

No comments:

Post a Comment