Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. '''
  2. things we should know
  3. ----------------------
  4. the screens max width without scrolling is 20 chars
  5. if a word is longer than 20 chars it will scroll
  6. if a string is longer than 20 chars it will alternatve
  7. back and fourth displaying 20 chars at a time
  8. give the screen apropriate time to draw before sending more data
  9. The sign will chop messages up at spaces. So if you send a long
  10. message with no spaces it will scroll forever but if you add spaces
  11. it will show each block one at a time.
  12.  
  13. ser.write adds a carrage return at the end
  14. use bytearray and append char or extend strings
  15. '''
  16. #!/usr/bin/env python
  17.  
  18.  
  19. import time
  20. import serial
  21. ser = serial.Serial(
  22. port='/dev/ttyAMA0',
  23. baudrate = 4800,
  24. parity=serial.PARITY_NONE,
  25. stopbits=serial.STOPBITS_ONE,
  26. bytesize=serial.EIGHTBITS,
  27. timeout=1
  28. )
  29. #counter=0
  30. print("begining loop")
  31. while 1:
  32. print("----------loop begin----------")
  33. #print("attempting serial comms")
  34. #ser.write('Write counter')
  35. #print("serial comms successfull")
  36.  
  37. #counter += 1
  38. print("sending data")
  39.  
  40. packet = bytearray()
  41.  
  42. packet.append(0x00)
  43. packet.append(0x00)
  44. packet.append(0x00)
  45. packet.append(0x00)
  46. packet.append(0x00)
  47.  
  48. packet.append(0x00)
  49. packet.append(0x00)
  50. packet.append(0x00)
  51. packet.append(0x00)
  52. packet.append(0x00)
  53.  
  54. packet.append(0x01)
  55. packet.append(0x5A)
  56. packet.append(0x30)
  57. packet.append(0x30)
  58. packet.append(0x02)
  59. packet.append(0x41)
  60. packet.append(0x41)
  61. packet.append(0x1b)
  62. packet.append(0x22)
  63. packet.append(0x62)
  64. packet.append(0x1c)
  65. packet.append(0x33)
  66. packet.append(0x10)
  67. packet.append(0x44)
  68. packet.append(0x04)
  69.  
  70. ser.write(packet)
  71.  
  72. packet2 = bytearray()
  73.  
  74. packet2.append(0x00)
  75. packet2.append(0x00)
  76. packet2.append(0x00)
  77. packet2.append(0x00)
  78. packet2.append(0x00)
  79.  
  80. packet2.append(0x00)
  81. packet2.append(0x00)
  82. packet2.append(0x00)
  83. packet2.append(0x00)
  84. packet2.append(0x00)
  85.  
  86. packet2.append(0x01)
  87. packet2.append(0x5A)
  88. packet2.append(0x30)
  89. packet2.append(0x30)
  90. packet2.append(0x02)
  91. packet2.append(0x47)
  92. packet2.append(0x44)
  93. packet2.append(0x1c)
  94. packet2.append(0x33)
  95. packet2.extend("ABCDEFGHIJKLMNOPQRST")
  96. packet2.append(0x04)
  97.  
  98.  
  99. ser.write(packet2)
  100.  
  101.  
  102. print("data send completed")
  103.  
  104. print("----------loop end----------")
  105. time.sleep(60)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement