Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- things we should know
- ----------------------
- the screens max width without scrolling is 20 chars
- if a word is longer than 20 chars it will scroll
- if a string is longer than 20 chars it will alternatve
- back and fourth displaying 20 chars at a time
- give the screen apropriate time to draw before sending more data
- The sign will chop messages up at spaces. So if you send a long
- message with no spaces it will scroll forever but if you add spaces
- it will show each block one at a time.
- ser.write adds a carrage return at the end
- use bytearray and append char or extend strings
- '''
- #!/usr/bin/env python
- import time
- import serial
- ser = serial.Serial(
- port='/dev/ttyAMA0',
- baudrate = 4800,
- parity=serial.PARITY_NONE,
- stopbits=serial.STOPBITS_ONE,
- bytesize=serial.EIGHTBITS,
- timeout=1
- )
- #counter=0
- print("begining loop")
- while 1:
- print("----------loop begin----------")
- #print("attempting serial comms")
- #ser.write('Write counter')
- #print("serial comms successfull")
- #counter += 1
- print("sending data")
- packet = bytearray()
- packet.append(0x00)
- packet.append(0x00)
- packet.append(0x00)
- packet.append(0x00)
- packet.append(0x00)
- packet.append(0x00)
- packet.append(0x00)
- packet.append(0x00)
- packet.append(0x00)
- packet.append(0x00)
- packet.append(0x01)
- packet.append(0x5A)
- packet.append(0x30)
- packet.append(0x30)
- packet.append(0x02)
- packet.append(0x41)
- packet.append(0x41)
- packet.append(0x1b)
- packet.append(0x22)
- packet.append(0x62)
- packet.append(0x1c)
- packet.append(0x33)
- packet.append(0x10)
- packet.append(0x44)
- packet.append(0x04)
- ser.write(packet)
- packet2 = bytearray()
- packet2.append(0x00)
- packet2.append(0x00)
- packet2.append(0x00)
- packet2.append(0x00)
- packet2.append(0x00)
- packet2.append(0x00)
- packet2.append(0x00)
- packet2.append(0x00)
- packet2.append(0x00)
- packet2.append(0x00)
- packet2.append(0x01)
- packet2.append(0x5A)
- packet2.append(0x30)
- packet2.append(0x30)
- packet2.append(0x02)
- packet2.append(0x47)
- packet2.append(0x44)
- packet2.append(0x1c)
- packet2.append(0x33)
- packet2.extend("ABCDEFGHIJKLMNOPQRST")
- packet2.append(0x04)
- ser.write(packet2)
- print("data send completed")
- print("----------loop end----------")
- time.sleep(60)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement