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
|
2021-10-27 15:24:42 +08:00
|
|
|
|
2021-10-26 21:44:10 +08:00
|
|
|
right = STM32.GPIO()
|
2021-10-27 15:24:42 +08:00
|
|
|
right.init()
|
|
|
|
right.setPin('PA0')
|
|
|
|
right.setMode('in')
|
|
|
|
right.setPull('down')
|
|
|
|
right.enable()
|
|
|
|
up = STM32.GPIO()
|
|
|
|
up.init()
|
|
|
|
up.setPin('PA15')
|
|
|
|
up.setMode('in')
|
|
|
|
up.setPull('up')
|
|
|
|
up.enable()
|
|
|
|
oled = PikaPiZero.OLED()
|
|
|
|
oled.init()
|
|
|
|
|
2021-10-26 20:31:56 +08:00
|
|
|
p0 = PikaPiZero.Point()
|
2021-10-28 11:18:02 +08:00
|
|
|
p0.x = 7
|
|
|
|
p0.y = 4
|
|
|
|
p_next_num = 0
|
|
|
|
|
|
|
|
k = 0
|
|
|
|
while k < 6:
|
|
|
|
p = p0
|
|
|
|
i = 0
|
|
|
|
while i < p_next_num:
|
|
|
|
p = p.next
|
|
|
|
i = i + 1
|
|
|
|
p.next = PikaPiZero.Point()
|
|
|
|
p.next.prev = p
|
|
|
|
p_next_num = p_next_num + 1
|
|
|
|
k = k + 1
|
|
|
|
|
2021-10-27 15:24:42 +08:00
|
|
|
|
2021-10-27 22:45:17 +08:00
|
|
|
mem = PikaStdLib.MemChecker()
|
|
|
|
print('mem used max:')
|
|
|
|
mem.max()
|
|
|
|
|
2021-10-27 15:24:42 +08:00
|
|
|
pos = 0
|
|
|
|
isUpdate = 1
|
2021-10-25 20:16:08 +08:00
|
|
|
while True:
|
2021-10-26 21:44:10 +08:00
|
|
|
if isUpdate:
|
|
|
|
isUpdate = 0
|
2021-10-28 11:18:02 +08:00
|
|
|
p = p0
|
|
|
|
i = 0
|
|
|
|
while i < p_next_num:
|
|
|
|
p = p.next
|
|
|
|
i = i + 1
|
|
|
|
i = 0
|
|
|
|
while i < p_next_num:
|
|
|
|
p = p.prev
|
|
|
|
p.next.x = p.x
|
|
|
|
p.next.y = p.y
|
|
|
|
i = i + 1
|
2021-10-26 21:44:10 +08:00
|
|
|
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
|
2021-10-28 11:18:02 +08:00
|
|
|
p = p0
|
|
|
|
i = 0
|
2021-10-26 21:44:10 +08:00
|
|
|
oled.clear()
|
2021-10-28 11:18:02 +08:00
|
|
|
while i < p_next_num:
|
|
|
|
oled.drawPoint(p.x, p.y)
|
|
|
|
p = p.next
|
|
|
|
i = i + 1
|
2021-10-27 22:45:17 +08:00
|
|
|
oled.refresh()
|
2021-10-26 21:44:10 +08:00
|
|
|
if right.read() == 1:
|
|
|
|
pos = 0
|
|
|
|
isUpdate = 1
|
|
|
|
if up.read() == 0:
|
|
|
|
pos = 2
|
2021-10-27 22:45:17 +08:00
|
|
|
isUpdate = 1
|