main.py 897 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/python
  2. # -*- coding:utf-8 -*-
  3. import sys
  4. import os
  5. libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'frontend/lib')
  6. if os.path.exists(libdir):
  7. sys.path.append(libdir)
  8. import logging
  9. from waveshare_epd import epd7in5_V2
  10. import time
  11. from PIL import Image
  12. import traceback
  13. logging.basicConfig(level=logging.DEBUG)
  14. try:
  15. logging.info("Updating Alba screen...")
  16. epd = epd7in5_V2.EPD()
  17. logging.info("Init and clear...")
  18. epd.init()
  19. epd.Clear()
  20. logging.info("Read the BMP file...")
  21. Himage = Image.open('/home/andrea/src/alba/frontend/screen.bmp')
  22. epd.display(epd.getbuffer(Himage))
  23. time.sleep(2)
  24. logging.info("Go to sleep...")
  25. epd.sleep()
  26. except IOError as e:
  27. logging.info(e)
  28. except KeyboardInterrupt:
  29. logging.info("ctrl + c:")
  30. epd7in5_V2.epdconfig.module_exit()
  31. exit()