ePaper display driven by a Raspberry Pi Pico
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

53 行
1.4 KiB

  1. import epaper
  2. import microbmp
  3. import time
  4. import random
  5. import os
  6. import storage
  7. import display
  8. import gc
  9. gc.enable()
  10. epd = display.init_display()
  11. disk = storage.Storage()
  12. while True:
  13. disk.mount()
  14. images = list(filter(lambda x : x.endswith(".bmp"), os.listdir(disk.get_root_path())))
  15. epd.EPD_5IN65F_Init()
  16. epd.fill(epd.White)
  17. filename = random.choice(images)
  18. print("TV drawing image ", filename)
  19. free_space = [0,0,0,0]
  20. try:
  21. free_space = display.draw_image(epd, disk.get_root_path() + "/" + filename)
  22. except Exception as e:
  23. print("Failed drawing image from disk: ", e)
  24. try:
  25. free_space = display.draw_image(epd, "tiny.bmp")
  26. except Exception as e:
  27. print("Failed drawing fallback image: ", e)
  28. free_space = display.draw_pattern(epd)
  29. caption = None
  30. try:
  31. caption = storage.load_joke(disk.get_root_path())
  32. except Exception as e:
  33. print("Failed loading a joke: ", e)
  34. try:
  35. display.draw_extra(epd, free_space, caption)
  36. except Exception as e:
  37. print("Failed drawing extra: ", e)
  38. time_render_start = time.ticks_ms()
  39. epd.EPD_5IN65F_Display(epd.buffer)
  40. time_render_stop = time.ticks_ms()
  41. print(" time to render: ", (time_render_stop - time_render_start) / 1000, " s")
  42. print("TV showing ", filename)
  43. epd.Sleep()
  44. disk.umount()
  45. print("")
  46. gc.collect()
  47. epd.delay_ms(60000 * 10)