09_localTimeClock.py 946 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env python
  2. #version : 2023.04.07
  3. #language : ch
  4. import time
  5. from maix import camera, display, image
  6. image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
  7. month={
  8. "Jan":"1月",
  9. "Feb": "2月",
  10. "Mar": "3月",
  11. "Apr": "4月",
  12. "May": "5月",
  13. "Jun": "6月",
  14. "Jul": "7月",
  15. "Aug": "8月",
  16. "Sep": "9月",
  17. "Oct": "10月",
  18. "Nov": "11月",
  19. "Dec": "12月",
  20. }
  21. week={
  22. "Mon": "星期一",
  23. "Tue": "星期二",
  24. "Wed": "星期三",
  25. "Thu": "星期四",
  26. "Fri": "星期五",
  27. "Sat": "星期六",
  28. "Sun": "星期日",
  29. }
  30. while True:
  31. hello_img = image.new(size = (240, 240), color = (0, 0, 0), mode = "RGB")
  32. date = time.asctime().split(" ")
  33. hello_img.draw_string(20, 108, date[5]+"年"+month[date[1]]+date[3]+"日 "+date[4]+" "+week[date[0]], scale = 1.0, color = (255, 255, 255), thickness = 1)
  34. display.show(hello_img)
  35. time.sleep(1)