LCD.py 693 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import PikaStdLib
  2. import machine
  3. lcd = machine.LCD()
  4. lcd.init()
  5. lcd.clear('white')
  6. mem = PikaStdLib.MemChecker()
  7. key = machine.KEY()
  8. key.init()
  9. time = machine.Time()
  10. h = 10
  11. w = 10
  12. x = 10
  13. y = 10
  14. x_last = x
  15. y_last = y
  16. is_update = 0
  17. print('mem used max:')
  18. mem.max()
  19. lcd.fill(x, y, w, h, 'blue')
  20. while True:
  21. key_val = key.get()
  22. if key_val != -1:
  23. x_last = x
  24. y_last = y
  25. is_update = 1
  26. if key_val == 0:
  27. x = x + 5
  28. if key_val == 1:
  29. y = y - 5
  30. if key_val == 2:
  31. y = y + 5
  32. if key_val == 3:
  33. x = x - 5
  34. if is_update:
  35. is_update = 0
  36. lcd.fill(x_last, y_last, w, h, 'white')
  37. lcd.fill(x, y, w, h, 'blue')