import time
time.sleep(0.1) # Wait for USB to become ready
print('Starting')
from picolcd import *
from boxes_buffer import *
if __name__ == '__main__':
print('Testing')
display = GraphicLCD(width=240,height=240)
buffer_width = 240
buffer_height = 240
try:
boxes = [Box(buffer_width - 1, buffer_height - 1, randint(7, 40), display,
display.color565(randint(30, 256), randint(30, 256), randint(30, 256))) for i in range(50)]
# print(free())
start_time = ticks_us()
frame_count = 0
while True:
for b in boxes:
b.update_pos()
for b in boxes:
b.draw()
# render display
display.show()
display.fill(0)
frame_count += 1
if frame_count == 100:
frame_rate = 100 / ((ticks_us() - start_time) / 1000000)
print(frame_rate)
start_time = ticks_us()
frame_count = 0
except KeyboardInterrupt:
display.cleanup()