예제 #1
0
def test_rand_line(n=5000, delay=1):
    lcd.clear()
    lcd.set_font(24)
    lcd.set_text_color(255, 255, 128, 0)
    lcd.display_string_at(0, 0, 'line test', 0)
    sleep_ms(1000)
    t0 = ticks_ms()
    for i in range(n):
        lcd.set_text_color(rand(0xFF), rand(0xFFFFFF))
        lcd.draw_line(rand(MAX_X), rand(MAX_Y), rand(MAX_X), rand(MAX_Y))
        sleep_ms(delay)
    return ticks_diff(ticks_ms(), t0)
예제 #2
0
def test_rand_fillrect(n=2000, delay=1):
    lcd.clear()
    lcd.set_font(24)
    lcd.set_text_color(255, 255, 128, 0)
    lcd.display_string_at(0, 0, 'fill rect test', 0)
    sleep_ms(1000)
    t0 = ticks_ms()
    for i in range(n):
        lcd.set_text_color(rand(0xFF), rand(0xFFFFFF))
        x, y = rand(MAX_X), rand(MAX_Y)
        lcd.fill_rect(x, y, rand(MAX_X - x), rand(MAX_Y - y))
        sleep_ms(delay)
    return ticks_diff(ticks_ms(), t0)
예제 #3
0
def test_rand_char(n=2000, font=12, delay=1):
    if font > 20: _w, _h = 17, 24,
    elif font > 16: _w, _h = 14, 20
    elif font > 12: _w, _h = 11, 16
    elif font > 8: _w, _h = 7, 12
    else: _w, _h = 5, 8

    lcd.clear()
    lcd.set_font(_h)
    mx, my = MAX_X // _w, MAX_Y // _h

    for i in range(n):
        lcd.set_text_color(rand(0xFFFFFF))
        lcd.display_char(rand(mx) * _w, rand(my) * _h, rand(95) + 32)
        sleep_ms(delay)
예제 #4
0
def ts_test():
    while 1:
        ts.get_state()
        if ts.touches() > 0:
            lcd.clear(0)
            print('\nTouch num: ', str(ts.touches()))
            for i in range(ts.touches()):
                print('  {} {}'.format(i + 1, ts.point_info(i + 1)))
                p = ts.point_info(i + 1)
                x1 = max(min(p[0] - p[2] // 2, 479), 0)
                x2 = max(min(p[0] + p[2] // 2, 479), 0)
                y1 = max(min(p[1] - p[2] // 2, 271), 0)
                y2 = max(min(p[1] + p[2] // 2, 271), 0)
                lcd.set_text_color(0x00FF00)
                lcd.draw_rect(x1, y1, x2 - x1, y2 - y1)
        sleep_ms(100)
예제 #5
0
def test_rand_pchar(n=2000, font=12, delay=5):
    if font > 20: _w, _h = 17, 24,
    elif font > 16: _w, _h = 14, 20
    elif font > 12: _w, _h = 11, 16
    elif font > 8: _w, _h = 7, 12
    else: _w, _h = 5, 8

    lcd.clear()
    lcd.set_font(_h)
    mx, my = MAX_X // _w, MAX_Y // _h
    px, py = 0, 0

    for i in range(n):
        lcd.set_text_color(rand(0xFFFFFF))
        lcd.display_char(px * _w, py * _h, rand(95) + 32)
        px += 1
        if px >= mx:
            px, py = 0, py + 1
            if py >= my:
                py = my - 1
                lcd.scroll(0, -_h)
                lcd.set_text_color(0)
                lcd.fill_rect(0, MAX_Y - _h, MAX_X - 1, MAX_Y - 1)
        sleep_ms(delay)