Guest User

Untitled

a guest
Jan 18th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. import board
  2. import displayio
  3. import time
  4.  
  5. s = board.SPI()
  6.  
  7. displayio.release_displays()
  8. display_bus = displayio.FourWire(s, command=board.D10, chip_select=board.D9)
  9. init_sequence = (b"\x01\x80\x78"# Software reset then delay 0x78 (120ms)
  10. b"\xEF\x03\x03\x80\x02"
  11. b"\xCF\x03\x00\xC1\x30"
  12. b"\xED\x04\x64\x03\x12\x81"
  13. b"\xE8\x03\x85\x00\x78"
  14. b"\xCB\x05\x39\x2C\x00\x34\x02"
  15. b"\xF7\x01\x20"
  16. b"\xEA\x02\x00\x00"
  17. b"\xc0\x01\x23" # Power control VRH[5:0]
  18. b"\xc1\x01\x10" # Power control SAP[2:0];BT[3:0]
  19. b"\xc5\x02\x3e\x28" # VCM control
  20. b"\xc7\x01\x86" # VCM control2
  21. b"\x36\x01\x30" # Memory Access Control
  22. b"\x37\x01\x00" # Vertical scroll zero
  23. b"\x3a\x01\x55" # COLMOD: Pixel Format Set
  24. b"\xb1\x02\x00\x18" # Frame Rate Control (In Normal Mode/Full Colors)
  25. b"\xb6\x03\x08\x82\x27" # Display Function Control
  26. b"\xF2\x01\x00" # 3Gamma Function Disable
  27. b"\x26\x01\x01" # Gamma curve selected
  28. b"\xe0\x0f\x0F\x31\x2B\x0C\x0E\x08\x4E\xF1\x37\x07\x10\x03\x0E\x09\x00" # Set Gamma
  29. b"\xe1\x0f\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F" # Set Gamma
  30. b"\x11\x80\x78"# Exit Sleep then delay 0x78 (120ms)
  31. b"\x29\x80\x78"# Display on then delay 0x78 (120ms)
  32. )
  33. display = displayio.Display(display_bus, init_sequence, width=320, height=240)
  34.  
  35. p = displayio.Palette(2)
  36. p[1] = 0xff0000
  37. shp = displayio.Shape(10, 10)
  38. g = displayio.Group(max_size=1)
  39. s = displayio.Sprite(shp, pixel_shader=p, position=(5,5))
  40. g.append(s)
  41. display.show(g)
  42.  
  43. print("sleeping")
  44. time.sleep(4)
  45. print("done")
Add Comment
Please, Sign In to add comment