コード例 #1
0
import sys
import bteve as eve
import board
import busio

if sys.implementation.name == "circuitpython":
    gd = eve.Gameduino()
else:
    from spidriver import SPIDriver
    gd = eve.Gameduino(SPIDriver(sys.argv[1]))
gd.init()

i2c = busio.I2C(board.SCL, board.SDA)
while not i2c.try_lock():
    pass


def pot(a):
    result = bytearray(1)
    i2c.writeto_then_readfrom(a, bytes([0xff]), result)
    return result[0]


while True:
    gd.finish()
    (r, g, b) = (pot(0x2a), pot(0x28), pot(0x2c))
    gd.ClearColorRGB(r, g, b)
    gd.Clear()

    def gauge(x, bg, c):
        gd.cmd_bgcolor(bg)
コード例 #2
0
import random
import bteve as eve

rr = random.randrange

gd = eve.Gameduino()
gd.init()

while True:
    gd.VertexFormat(2)
    gd.Clear()
    gd.Begin(eve.POINTS)
    for i in range(100):
        gd.ColorRGB(rr(256), rr(256), rr(256))
        gd.PointSize(rr(gd.w // 6))
        gd.Vertex2f(rr(gd.w), rr(gd.h))
    gd.swap()