46 lines
981 B
Python
Raw Normal View History

2021-10-01 00:21:50 +08:00
import PikaStdLib
2021-10-19 08:15:01 +08:00
import PikaPiZero
2021-10-26 21:44:10 +08:00
import STM32
oled = PikaPiZero.OLED()
up = STM32.GPIO()
right = STM32.GPIO()
2021-10-26 20:31:56 +08:00
p0 = PikaPiZero.Point()
2021-10-26 21:44:10 +08:00
p1 = PikaPiZero.Point()
p2 = PikaPiZero.Point()
p1.x = 0
p1.y = 0
2021-10-25 20:16:08 +08:00
while True:
2021-10-26 21:44:10 +08:00
if isUpdate:
isUpdate = 0
p2.x = p1.x
p2.y = p1.y
p1.x = p0.x
p1.y = p0.y
if pos == 0:
2021-10-26 20:31:56 +08:00
p0.x = p0.x + 1
2021-10-26 21:44:10 +08:00
if p0.x > 15:
p0.x = 0
if pos == 1:
2021-10-26 20:31:56 +08:00
p0.x = p0.x - 1
2021-10-26 21:44:10 +08:00
if p0.x < 0:
p0.x = 15
if pos == 2:
2021-10-26 20:31:56 +08:00
p0.y = p0.y - 1
2021-10-26 21:44:10 +08:00
if p0.y < 0:
p0.y = 7
if pos == 3:
2021-10-26 20:31:56 +08:00
p0.y = p0.y + 1
2021-10-26 21:44:10 +08:00
if p0.y > 7:
p0.y = 0
oled.clear()
2021-10-26 20:31:56 +08:00
oled.drawPoint(p0.x, p0.y)
2021-10-26 21:44:10 +08:00
oled.drawPoint(p1.x, p1.y)
oled.drawPoint(p2.x, p2.y)
if right.read() == 1:
pos = 0
isUpdate = 1
if up.read() == 0:
pos = 2
isUpdate = 1
2021-10-10 10:57:13 +08:00