コード例 #1
0
def drawHorizontalLine(y):
    from gfxhat import lcd, backlight
    from time import sleep
    from rios0021Library import clearBacklight
    # Clear the lcd
    lcd.clear()
    lcd.show()
    # Clear backlight
    clearBacklight()
    r = 255
    g = 0
    # Draw the line at y
    for x in range(0, 128):
        lcd.set_pixel(x,y,1)
        lcd.show()
        # Additional code to make a color transition while drawing line
        backlight.set_all(r, g, 0)
        backlight.show()
        if (g < 252):
            g += 4
        elif(r > 3):
            r -= 4
    # Turn off backlight after 2 seconds
    sleep(2)
    clearBacklight()
    lcd.clear()
    lcd.show()
コード例 #2
0
def drawRandomPixels(seconds):
    from random import randint
    from gfxhat import lcd, backlight
    from time import sleep
    from rios0021Library import clearBacklight
    # Clear the lcd
    lcd.clear()
    lcd.show()
    # Clear backlight
    clearBacklight()
    time = 0.0
    # Show a nice blue color
    backlight.set_all(0, 255, 255)
    backlight.show()
    # Loop determined by the number of seconds to draw random pixels every .2 seconds
    while(int(time) != int(seconds)):
        x = randint(0,127)
        y = randint(0,63)
        lcd.set_pixel(x,y,1)
        lcd.show()
        sleep(0.2)
        time += 0.2
    # Show green as signal the pixel drawing has finished
    backlight.set_all(0, 255, 0)
    backlight.show()
    sleep(0.5)
    backlight.set_all(0, 255, 255)
    backlight.show()
    # Clear the lcd and backlight after 4 seconds
    sleep(4)
    lcd.clear()
    lcd.show()
    clearBacklight()
コード例 #3
0
def displVertLineAtX(x):
    lcd.clear()
    lcd.show()
    y = 0
    while (y <= 64):
        lcd.set_pixel(x, y, 1)
        y = y + 1
        lcd.show()
コード例 #4
0
def displayHorizontalLine(y):
    from gfxhat import lcd
    lcd.clear()
    i = 0
    while i < 128:
        lcd.set_pixel(i, y, 1)
        lcd.show()
        i = i + 1
コード例 #5
0
def displayVerticalLine(x):
    from gfxhat import lcd
    lcd.clear()
    i = 0
    while i < 64:
        lcd.set_pixel(x, i, 1)
        lcd.show()
        i = i + 1
コード例 #6
0
def dispHorizLineAtY(y):
    lcd.clear()
    lcd.show()
    x = 0
    while (x <= 127):
        lcd.set_pixel(x, y, 1)
        x = x + 1
        lcd.show()
コード例 #7
0
def randomPixelSleep(secs):
    x = random.randrange(127)
    y = random.randrange(63)
    lcd.set_pixel(x, y, 1)
    lcd.show()
    time.sleep(secs)
    lcd.clear()
    lcd.show()
コード例 #8
0
ファイル: menu.py プロジェクト: ajay0006/madPythonLabs
def randomPixelDisplay(expires=showPixelForDuration()):
    while expires >= int(time.time()):
        lcd.set_pixel(random.randint(1, 127), random.randint(1, 63), 1)
        lcd.show()
        time.sleep(2)
        lcd.clear()
        lcd.show()
        lcd.clear()
        lcd.show()
コード例 #9
0
ファイル: clsMenu.py プロジェクト: ajalexsmith/PW2019
 def reboot(self):
     for x in range(6):
         backlight.set_pixel(x, 0, 0, 0)
         touch.set_led(x, 0)
     backlight.show()
     lcd.clear()
     drive = clsDrive.Drive()
     drive.stop()
     lcd.show()
     call("sudo reboot", shell=True)
コード例 #10
0
def moveObject(obj, x, y, vx, vy):
    while x < 127 or y < 63:
        for i in range(0, len(obj)):
            for j in range(0, len(obj[i])):
                lcd.set_pixel(x + j, y + i, obj[i][j])
                lcd.show()
        lcd.clear()
        x += vx
        y += vy
        lcd.show()
コード例 #11
0
def MainMenu():
    print("select ... : ")
    print("1 - Display Object ")
    print("2 - Exit")
    option = input("Enter Your Choise : ")

    if option == "1":
        lcd.clear()
        lcd.show()
        print("choose : \n 1 - to draw a PAC MAN \n 2 - to draw fighter ")
        obj = int(input())
        if obj == 1:
            obj = pm
        elif obj == 2:
            obj = f1

        else:
            print("invalid option ...")
            print("choose : \n 1 - to draw a PAC MAN \n -2 to draw fight")
            obj = int(input())

        for y1 in obj:
            for x1 in y1:
                lenthX = len(y1)
                lenthY = len(obj)

        xPoint = int(
            input("input the x cordinate -must be between 0 and 127 :"))
        yPoint = int(
            input("input the  y cordinate -must be between 0 and 63 : "))

        totalX = lenthX + xPoint
        totalY = lenthY + yPoint

        if totalX > 127:
            print(
                "X value is too big for the image please type a smaller X cordinate "
            )
            xPoint = int(
                input("input the x cordinate -must be between 0 and 127 : "))
            diplayObject(obj, xPoint, yPoint)

        elif totalY > 63:
            print(
                "Y value is too big for the image please type a smaller X cordinate "
            )
            yPoint = int(
                input("input the  y cordinate -must be between 0 and 63 : "))
            diplayObject(obj, xPoint, yPoint)

        else:
            diplayObject(obj, xPoint, yPoint)
    elif option == "2":
        lcd.clear()
        lcd.show()
コード例 #12
0
def randomPixel(waitTime):
    import random, time
    from gfxhat import lcd
    lcd.clear()
    x = random.randint(1, 127)
    y = random.randint(1, 63)
    lcd.set_pixel(x, y, 1)
    lcd.show()
    time.sleep(waitTime)
    lcd.clear()
    lcd.show()
コード例 #13
0
def createVerticalLine():
    lcd.clear()
    lcd.show()
    y = 0
    x = int(input('Set the x cordinate for the vertical line: '))

    while (y <= 63):
        lcd.set_pixel(x, y, 1)
        y = y + 1

    lcd.show()
コード例 #14
0
def displayObject(obj, x=0, y=0):
    lcd.clear()
    lcd.show()
    y1 = y
    for i in obj:
        y1 += 1
        x1 = x
        for j in i:
            x1 += 1
            lcd.set_pixel(x1, y1, j)
            lcd.show()
コード例 #15
0
def displayrandompixel(seconds):
    from gfxhat import lcd
    import random, time
    lcd.clear()

    x = random.rantint(1, 128)
    y = random.randint(1, 64)
    lcd.set_pixel(x, y, 1)
    lcd.show()
    time.sleep(seconds)
    lcd.clear()
コード例 #16
0
def etchSketch(x, y):
    while True:
        key = getchar()

        if key in bmaps.keys():  #[key1key2....]
            displayObject(bmaps[key], x, y)
            lcd.show()

        if key == 'q':
            lcd.clear()
            lcd.show()
コード例 #17
0
ファイル: rokn0001Library.py プロジェクト: rokn0001/Python
def horizontal_line(y):
    from gfxhat import lcd
    from time import sleep
    lcd.clear()
    lcd.show()
    for x in range(0, 127):
        lcd.set_pixel(x, y, 1)
        lcd.show()
    sleep(6)
    lcd.clear()
    lcd.show()
コード例 #18
0
def createHorizontalLine():
    lcd.clear()
    lcd.show()
    x = 0
    y = int(input('Set the y cordinate for the horizontal line: '))

    while (x <= 127):
        lcd.set_pixel(x, y, 1)
        x = x + 1

    lcd.show()
コード例 #19
0
ファイル: rokn0001Library.py プロジェクト: rokn0001/Python
def vertical_line(x):
    from gfxhat import lcd
    from time import sleep
    lcd.clear()
    lcd.show()
    for y in range(0, 64):
        lcd.set_pixel(x, y, 1)
        lcd.show()
    sleep(6)
    lcd.clear()
    lcd.show()
コード例 #20
0
 def draw(image, rgb=(0, 100, 0)):
     backlight.set_all(rgb[0], rgb[1], rgb[2])
     backlight.show()
     lcd.clear()
     for x in range(128):
         for y in range(64):
             pixel = image.getpixel((x, y))
             if pixel > 1:
                 lcd.set_pixel(x, y, 1)
             else:
                 lcd.set_pixel(x, y, 0)
     lcd.show()
コード例 #21
0
def bouncingBall(obj, x, y, vx, vy, sx=127, sy=63):
    while (True):
        for i in range(0, len(obj)):
            for j in range(0, len(obj[i])):
                lcd.set_pixel(x + j, y + i, obj[i][j])
                lcd.show()
        time.sleep(.1)
        lcd.clear()
        x += vx
        y += vy
        lcd.show()
        x, y, vx, vy = checkCollision(obj, x, y, vx, vy, sx, sy)
コード例 #22
0
def displayText(text, lcd, x, y):
    lcd.clear()
    width, height = lcd.dimensions()
    image = Image.new('P', (width, height))
    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype(fonts.AmaticSCBold, 24)
    w, h = font.getsize(text)
    draw.text((x, y), text, 1, font)
    for x1 in range(x, x + w):
        for y1 in range(y, y + h):
            pixel = image.getpixel((x1, y1))
            lcd.set_pixel(x1, y1, pixel)
    lcd.show()
コード例 #23
0
def horizontalLine(y):
    lcd.clear()
    lcd.show()

    x = 0
    while (x <= 127):
        lcd.set_pixel(x, y, 1)
        x = x + 1

    backlight.set_all(0, 255, 0)
    backlight.show()
    lcd.show()
    return
コード例 #24
0
ファイル: Task1-1.py プロジェクト: dalerben61/Lab5
def verticalLine(x):
    lcd.clear()
    lcd.show()

    y = 0
    while (y <= 63):
        lcd.set_pixel(x, y, 1)
        y = y + 1

    backlight.set_all(0, 255, 0)
    backlight.show()
    lcd.show()
    return
コード例 #25
0
def etchSketch(x, y):
    while True:
        key = getchar()
        lcd.set_pixel(x, y, 1)
        lcd.show()
        if key == 's':  # start again a new drawing on the hat
            clearScreen(lcd)
        elif key == '\x1b[A':  #up
            y = y - 1
            if y == 0:
                y = 63
            lcd.set_pixel(x, y, 1)
            lcd.show()
        elif key == '\x1b[B':  #DOWN:
            y = y + 1
            if y == 63:
                y = 0
            lcd.set_pixel(x, y, 1)
            lcd.show()
        elif key == '\x1b[C':  #right:
            x = x + 1
            if x == 127:
                x = 0
                ###
            if x > 127:
                x = 0
            if x < 0:
                x = 127
                ####

            lcd.set_pixel(x, y, 1)
            lcd.show()
        elif key == '\x1b[D':  #left:
            x = x - 1
            if x == 0:
                x = 127
                ###
            if x > 127:
                x = 0
            if x < 0:
                x = 127
                ####
            lcd.set_pixel(x, y, 1)
            lcd.show()
        elif key == 'q':  #quit
            lcd.clear()
            lcd.show()
            exit()
        else:
            print('done')
コード例 #26
0
def etchSketch(x, y):
    while True:
        key = getchar()
        lcd.set_pixel(x, y, 1)
        lcd.show()

        # key 's' restarts the game
        if key == 's':
            clearScreen(lcd)

        # key is up arrow
        elif key == '\x1b[A':
            y = y - 1
            if y == 0:
                y = 63
            lcd.set_pixel(x, y, 1)
            lcd.show()

        # key is down arrow
        elif key == '\x1b[B':
            y = y + 1
            if y == 63:
                y = 0
            lcd.set_pixel(x, y, 1)
            lcd.show()

        # key is right arrow
        elif key == '\x1b[C':
            x = x + 1
            if x == 127:
                x = 0
            lcd.set_pixel(x, y, 1)
            lcd.show()

        # key is left arrow
        elif key == '\x1b[D':
            x = x - 1
            if x == 0:
                x = 127
            lcd.set_pixel(x, y, 1)
            lcd.show()

        # key 'q' quits the game
        elif key == 'q':
            lcd.clear()
            lcd.show()
            exit()

        else:
            print("Press a valid option")
コード例 #27
0
def staircase(x, y, width, height):
    from gfxhat import lcd
    lcd.clear()

    while x < 128 and y < 64:
        for i in range(height):
            lcd.set_pixel(x, y, 1)
            lcd.show()
            y = y + 1

        for i in range(width):
            lcd.set_pixel(x, y, 1)
            lcd.show()
            x = x + 1
コード例 #28
0
def randomPixels(length):
    lcd.clear()
    lcd.show()
    timestop = time.time() + length
    backlight.set_all(0, 255, 0)
    backlight.show()

    while time.time() <= timestop:
        x = random.randint(1, 127)
        y = random.randint(1, 63)
        lcd.set_pixel(x, y, 1)
        lcd.show()
        time.sleep(0.2)

    return
コード例 #29
0
def displayText(text, x, y):
    from gfxhat import lcd, fonts, backlight
    from PIL import Image, ImageFont, ImageDraw
    lcd.clear()
    width, height = lcd.dimensions()
    image = Image.new('P', (width, height))
    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype(fonts.BitbuntuFull, 10)
    w, h = font.getsize(text)
    draw.text((x, y), text, 1, font)
    for x1 in range(x, x + w):
        for y1 in range(y, y + h):
            pixel = image.getpixel((x1, y1))
            lcd.set_pixel(x1, y1, pixel)
    lcd.show()
コード例 #30
0
def randonPixel():
    lcd.clear()
    lcd.show()
    x = random.randint(0, 127)
    y = random.randint(0, 63)
    timer = int(
        input(
            'Enter an amount of seconds for the pixel to appear on the screen: '
        ))

    lcd.set_pixel(x, y, 1)
    lcd.show()

    sleep(5)
    lcd.clear()
    lcd.show()