Exemplo n.º 1
0
def main():

    iot_oled.connect_oled(bounce_config.oled_scl, bounce_config.oled_sda,
                          bounce_config.oled_width, bounce_config.oled_height)
    iot_oled.splash_oled(bounce_title)
    iot_oled.clear_oled()

    x = y = 0
    dx = dy = 1

    while True:
        # clear old pixel before new pixel
        iot_oled.oled.pixel(x, y, 0)

        # update the dot's position
        x += dx
        y += dy

        # make the dot bounce off the edges of the screen for both X and Y
        if (x <= 0) or (x >= (bounce_config.oled_width - 1)): dx = -dx
        if (y <= 0) or (y >= (bounce_config.oled_height - 1)): dy = -dy

        print("dx " + str(dx) + ":dy " + str(dy) + ":x " + str(x) + ":y " +
              str(y))

        # draw the dot
        iot_oled.oled.pixel(x, y, 1)

        # show the dot on the display
        iot_oled.oled_show()

        # pause for 10 millseconds
        utime.sleep_ms(10)
Exemplo n.º 2
0
def main():

    iot_oled.connect_oled(bounce_config.oled_scl, bounce_config.oled_sda,
                          bounce_config.oled_width, bounce_config.oled_height)
    iot_oled.splash_oled(bounce_title)
    iot_oled.clear_oled()

    x = min_x + 1
    y = min_y + 1
    dx = iot_random.max_dxdy
    dy = iot_random.max_dxdy

    iot_oled.drawRect(min_x, min_y, max_x - min_x + 1, max_y - min_y + 1, 1)

    while True:

        # delete old line
        iot_oled.drawLine(x, y, x + dx, y + dy, 0)

        # update the dot's position
        x += dx
        y += dy

        # make the dot bounce off the edges of the screen
        if x + dx <= min_x + 1:
            x = min_x + 1
            dx = iot_random.random_dxdy()
            if (x + dx >= max_x):
                dx = iot_random.max_dxdy

        if x + dx >= max_x - 1:
            x = max_x - 1
            dx = -iot_random.random_dxdy()
            if (x + dx <= min_x):
                dx = iot_random.max_dxdy

        if y + dy <= min_y + 1:
            y = min_y + 1
            dy = iot_random.random_dxdy()
            if (y + dy >= max_y):
                dy = iot_random.max_dxdy

        if y + dy >= max_y - 1:
            y = max_y - 1
            dy = -iot_random.random_dxdy()
            if (y + dy <= min_y):
                dy = iot_random.max_dxdy

        print("dx " + str(dx) + ":dy " + str(dy) + ":x " + str(x) + ":y " +
              str(y))

        # draw the line
        iot_oled.drawLine(x, y, x + dx, y + dy, 1)

        # show the line on the display
        iot_oled.oled.show()

        # pause for 10 millseconds
        utime.sleep_ms(10)
Exemplo n.º 3
0
def main():

    iot_oled.connect_oled(bounce_config.oled_scl, bounce_config.oled_sda,
                          bounce_config.oled_width, bounce_config.oled_height)
    iot_oled.splash_oled(bounce_title)
    iot_oled.clear_oled()

    x = min_x
    y = min_y
    dx = iot_random.random_dx()
    dy = iot_random.random_dy()

    while True:

        # delete old line
        iot_oled.drawLine(x, y, x + dx, y + dy, 0)

        # update the dot's position
        x += dx
        y += dy

        # make the dot bounce off the edges of the screen
        if x < min_x:
            dx = iot_random.random_dx()
            x = min_x

        if x > max_x:
            dx = -iot_random.random_dx()
            x = max_x

        if y < min_y:
            dy = iot_random.random_dy()
            y = min_y

        if y > max_y:
            dy = -iot_random.random_dy()
            y = max_y

        print("dx " + str(dx) + ":dy " + str(dy) + ":x " + str(x) + ":y " +
              str(y))

        # draw the line
        iot_oled.drawLine(x, y, x + dx, y + dy, 1)

        # show the line on the display
        iot_oled.oled_show()

        # pause for 10 millseconds
        utime.sleep_ms(10)
Exemplo n.º 4
0
def main():

    iot_oled.connect_oled(bounce_config.oled_scl, bounce_config.oled_sda,
                          bounce_config.oled_width, bounce_config.oled_height)
    iot_oled.splash_oled(bounce_title)
    iot_oled.clear_oled()

    x = y = 0
    dx = iot_random.random_dxdy()
    dy = iot_random.random_dxdy()

    while True:
        # update the dot's position
        x += dx
        y += dy

        # make the dot bounce off the edges of the screen
        if x <= 0:
            dx = iot_random.random_dxdy()
            update_oled_loop()

        if x >= (bounce_config.oled_width - 1):
            dx = -iot_random.random_dxdy()
            update_oled_loop()

        if y <= 0:
            dy = iot_random.random_dxdy()
            update_oled_loop()

        if y >= (bounce_config.oled_height - 1):
            dy = -iot_random.random_dxdy()
            update_oled_loop()

        print("dx " + str(dx) + ":dy " + str(dy) + ":x " + str(x) + ":y " +
              str(y))

        # draw the dot
        iot_oled.oled.pixel(x, y, 1)

        # show the dot on the display
        iot_oled.oled_show()

        # pause for 10 millseconds
        utime.sleep_ms(10)