def brightness():
    '''All matrices show displays all LEDs lit, from min to max brightness over about 1 second.
    Should be left at max brightness.
    '''
    fb = FrameBuffer(matrix_layout=[(0,0,90)])
    for i in range(16):
        fb.erase(i)
        fb.show()
        time.sleep(0.1)
def brightness():
    '''All matrices show displays all LEDs lit, from min to max brightness over about 1 second.
    Should be left at max brightness.
    '''
    fb = FrameBuffer(matrix_layout=[(0, 0, 90)])
    for i in range(16):
        fb.erase(i)
        fb.show()
        time.sleep(0.1)
def char_on_each_matrix():
    '''Verify that the numbers 0-9, A-Z are in the vertical chain of LEDs,
    lowest number at the bottom.
    '''
    chars = [Text(chr(ord('0')+i)) for i in range(10)]
    chars += [Text(chr(ord('A')+i)) for i in range(26)]

    num = FrameBuffer.detect()
    matrix_layout = [(0,y*8,90) for y in reversed(range(num))]
    fb = FrameBuffer(matrix_layout=matrix_layout)

    fb.erase()
    for i in range(num):
        fb.draw(chars[i], (2,8*i))
    fb.show()
def sprite_draw():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.erase(0xE)
    s = copy.deepcopy(default_sprite)
    fb.draw(s, origin=(2,3))
    expected_fb = '''
        EEEEEEEE
        EE123EEE
        EE456EEE
        EE789EEE
        EEABCEEE
        EEEEEEEE
        EEEEEEEE
        EEEEEEEE
        '''
    return arrays_equal(expected_fb, fb)
def sprite_draw():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.erase(0xE)
    s = copy.deepcopy(default_sprite)
    fb.draw(s, origin=(2, 3))
    expected_fb = '''
        EEEEEEEE
        EE123EEE
        EE456EEE
        EE789EEE
        EEABCEEE
        EEEEEEEE
        EEEEEEEE
        EEEEEEEE
        '''
    return arrays_equal(expected_fb, fb)
Exemplo n.º 6
0
mc = minecraft.Minecraft.create()

SCALE = 25
fb = FrameBuffer()

count = 0
FLASH_COUNT = 3
flash_lit = True
while True:
    pos = mc.player.getTilePos()

    x = round(pos.x / SCALE + (fb.width - 1) / 2)
    x_out_of_bounds = not 0 <= x < fb.width
    x = min(fb.width - 1, max(0, x))

    z = round(pos.z / SCALE + (fb.height - 1) / 2)
    z_out_of_bounds = not 0 <= z < fb.height
    z = min(fb.height - 1, max(0, z))

    fb.erase()
    count += 1
    if count > FLASH_COUNT:
        flash_lit = not flash_lit
        count = 0
    if not x_out_of_bounds and not z_out_of_bounds or flash_lit:
        fb.point(z, x)
    fb.show()

    time.sleep(0.01)
from rstem.accel import Accel
from rstem.led_matrix import FrameBuffer
import time

fb = FrameBuffer()
accel = Accel()

TILT_FORCE = 0.1
STEP = 0.1
x, y = (3, 3)
while True:
    x_force, y_force, z_force = accel.forces()
    
    if x_force > TILT_FORCE:
        x -= STEP
    elif x_force < -TILT_FORCE:
        x += STEP

    fb.erase()
    fb.point(round(x), round(y))
    fb.show()
    
    time.sleep(.1)


def erase3():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.erase(7)
    return fb._framebuffer() == makefb('77777777\n' * 8)
def erase2():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.erase(3)
    return fb._framebuffer() == makefb('33333333\n' * 8)
def erase1():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.erase(0xf)
    fb.erase()
    return fb._framebuffer() == makefb('00000000\n' * 8)
    - UUT shows vertical bar go from left to right (1 second)
    - UUT shows 1 quarter lit (upper left/right, then lower left/right) (1
      second)
    - UUT shows checkerboard with bottom left lit, then inverted checkerboard
      (1.5 seconds)
Any missing LEDs lit is a failure.

Sequence repeats forever - hit CTRL-C to stop.
""")

input("Press Enter to start the test...")

print("TEST SEQUENCE RUNNING - CTRL-C TO END")

while True:
    fb.erase()
    fb.draw(Text("A"), (0,0))
    fb.draw(Text("B"), (8,0))
    fb.draw(Text("C"), (8,8))
    fb.show()
    time.sleep(1)

    fb.erase(0xF)
    fb.show()
    time.sleep(1)

    for color in range(16):
        fb.erase(color)
        fb.show()
        time.sleep(2/16)
def erase3():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.erase(7)
    return fb._framebuffer() == makefb('77777777\n' * 8)
def erase2():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.erase(3)
    return fb._framebuffer() == makefb('33333333\n' * 8)
def erase1():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.erase(0xf)
    fb.erase()
    return fb._framebuffer() == makefb('00000000\n' * 8)