Advertisement
Guest User

Pi TFT Script

a guest
Mar 2nd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.01 KB | None | 0 0
  1. # Copyright (c) 2014 Adafruit Industries
  2. # Author: Tony DiCola
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a copy
  5. # of this software and associated documentation files (the "Software"), to deal
  6. # in the Software without restriction, including without limitation the rights
  7. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. # copies of the Software, and to permit persons to whom the Software is
  9. # furnished to do so, subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be included in
  12. # all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. # THE SOFTWARE.
  21. from PIL import Image
  22.  
  23. import Adafruit_ILI9341 as TFT
  24. import Adafruit_GPIO as GPIO
  25. import Adafruit_GPIO.SPI as SPI
  26. import sys
  27.  
  28.  
  29. # Raspberry Pi configuration.
  30. # Defaults
  31. #DC = 18
  32. #RST = 23
  33. DC = 24
  34. RST = 25
  35. SPI_PORT = 0
  36. SPI_DEVICE = 0
  37.  
  38. # BeagleBone Black configuration.
  39. # DC = 'P9_15'
  40. # RST = 'P9_12'
  41. # SPI_PORT = 1
  42. # SPI_DEVICE = 0
  43.  
  44. # Create TFT LCD display class.
  45. disp = TFT.ILI9341(DC, rst=RST, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=64000000))
  46.  
  47. # Initialize display.
  48. #disp.begin()
  49.  
  50. # Load an image.
  51. #print('Loading image...')
  52. imageName = str(sys.argv[1])
  53. #print(imageName)
  54. #image = Image.open('/home/pi/Adafruit_Python_ILI9341/examples/cat.jpg')
  55. image = Image.open(imageName)
  56.  
  57. # Resize the image and rotate it so it's 240x320 pixels.
  58. image = image.rotate(90).resize((240, 320))
  59.  
  60. # Draw the image on the display hardware.
  61. #print('Drawing image')
  62. disp.display(image)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement