41 lines
715 B
Python
Raw Normal View History

2021-11-22 12:17:38 +08:00
from PikaObj import *
import PikaStdLib
import machine
lcd = machine.LCD()
2021-11-22 12:17:38 +08:00
lcd.init()
lcd.clear('white')
mem = PikaStdLib.MemChecker()
key = machine.KEY()
2021-11-22 12:17:38 +08:00
key.init()
time = machine.Time()
2021-11-22 12:17:38 +08:00
h = 10
w = 10
x = 10
y = 10
x_last = x
y_last = y
is_update = 0
print('mem used max:')
mem.max()
lcd.fill(x, y, w, h, 'blue')
while True:
2021-11-30 23:27:18 +08:00
key_val = key.get()
if key_val != -1:
2021-11-22 12:17:38 +08:00
x_last = x
y_last = y
is_update = 1
2021-11-30 23:27:18 +08:00
if key_val == 0:
x = x + 5
if key_val == 1:
2021-11-22 12:17:38 +08:00
y = y - 5
2021-11-30 23:27:18 +08:00
if key_val == 2:
2021-11-22 12:17:38 +08:00
y = y + 5
2021-11-30 23:27:18 +08:00
if key_val == 3:
2021-11-22 12:17:38 +08:00
x = x - 5
if is_update:
is_update = 0
lcd.fill(x_last, y_last, w, h, 'white')
lcd.fill(x, y, w, h, 'blue')