Skip to content
Snippets Groups Projects
Commit 50c7b8ef authored by Martin Winter's avatar Martin Winter
Browse files

remove some bugs

parent 1d35f97d
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ def scroll(message, duration=5, speed = 15):
frame = get_picture("clear")
while time()-start <= duration:
shift_left(frame, get_column(letter(message[lettercounter]),7-colcounter))
shift_left(frame, get_column(letter(message[lettercounter]),colcounter))
shield.blit(frame, (0, 0))
if colcounter < 7:
......@@ -66,7 +66,28 @@ def rustle(duration=5, speed = 10):
shield.update()
sleep(1/speed)
def matrix(duration=10, speed = 5):
shield.clear()
shield.update()
display = get_picture("clear")
start = time()
row = [0,0,0,0,0,0,0,0]
while time()-start <= duration:
for i in range(8):
row[i] = getrandbits(1)
#rand = getrandbits(2)
#if rand == 0:
#row[i] = int(not row[i])
print(row)
sleep(1/2)
shift_down(display,row)
shield.blit(display)
shield.update()
sleep(1/speed)
def arrows(duration=5, direction = "right", speed = 10):
shield.clear()
shield.update()
......@@ -81,9 +102,9 @@ def arrows(duration=5, direction = "right", speed = 10):
start = time()
while time()-start <= duration:
if direction == "right":
shift_right(arrow, get_column(arrow,0))
shift_right(arrow, get_column(arrow,7))
elif direction == "left":
shift_left(arrow, get_column(arrow,7))
shift_left(arrow, get_column(arrow,0))
elif direction == "up":
shift_up(arrow, arrow[0])
else:
......@@ -93,6 +114,9 @@ def arrows(duration=5, direction = "right", speed = 10):
shield.update()
sleep(1/speed)
def get_row(bitmap: list[list[int | bool]], rownumber: int):
row = bitmap[rownumber]
return row
def get_column(bitmap: list[list[int | bool]], colnumber: int):
col = []
......@@ -112,17 +136,24 @@ def shift_down(bitmap: list[list[int | bool]],
bitmap.insert(0,row)
def shift_left(bitmap: list[list[int | bool]],
row: list[int | bool] = [0,0,0,0,0,0,0,0]):
col: list[int | bool] = [0,0,0,0,0,0,0,0]):
for i in range(len(bitmap)):
bitmap[i].pop(-1)
bitmap[i].insert(0,row[i])
bitmap[i].pop(0)
bitmap[i].append(col[i])
def shift_right(bitmap: list[list[int | bool]],
row: list[int | bool] = [0,0,0,0,0,0,0,0]):
col: list[int | bool] = [0,0,0,0,0,0,0,0]):
for i in range(len(bitmap)):
bitmap[i].pop(0)
bitmap[i].append(row[i])
bitmap[i].pop(-1)
bitmap[i].insert(0,col[i])
if __name__ == "__main__":
while True:
random()
\ No newline at end of file
#scroll("Hallo Welt!",10)
#arrows(5)
#arrows(5, "left", 20)
#arrows(5, "up", 20)
#arrows(5, "down")
#rustle()
matrix()
\ No newline at end of file
......@@ -17,7 +17,7 @@ def byte_to_bits(byte):
while len(bits) <= 8:
bits.insert(0,0)
return bits
return bits[::-1]
def letter(letter):
return bytes_to_bitsarray(font[letter])
......
from myfrabuled import WEMOSMatrixLEDShield
from time import sleep, time, ticks_ms
def get_picture(pic):
picture = [[0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0],
......@@ -53,7 +56,7 @@ pictures = {
[0,1,1,1,1,1,1,0],
[0,0,1,1,1,1,0,0],
[0,0,0,1,1,0,0,0]],
'l_arrow': [[0,0,0,1,1,0,0,0],
'r_arrow': [[0,0,0,1,1,0,0,0],
[0,0,0,0,1,1,0,0],
[0,0,0,0,0,1,1,0],
[1,1,1,1,1,1,1,1],
......@@ -61,7 +64,7 @@ pictures = {
[0,0,0,0,0,1,1,0],
[0,0,0,0,1,1,0,0],
[0,0,0,1,1,0,0,0]],
'r_arrow': [[0,0,0,1,1,0,0,0],
'l_arrow': [[0,0,0,1,1,0,0,0],
[0,0,1,1,0,0,0,0],
[0,1,1,0,0,0,0,0],
[1,1,1,1,1,1,1,1],
......@@ -85,4 +88,10 @@ pictures = {
[0,1,1,1,1,1,1,0],
[0,0,1,1,1,1,0,0],
[0,0,0,1,1,0,0,0]]
}
\ No newline at end of file
}
if __name__ == "__main__":
shield = WEMOSMatrixLEDShield()
shield.blit(pictures['l_arrow'])
shield.update()
sleep(0.8)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment