Skip to content

Instantly share code, notes, and snippets.

@todbot
Created April 27, 2023 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todbot/93692c13d02051a961d4dda3fb7242c7 to your computer and use it in GitHub Desktop.
Save todbot/93692c13d02051a961d4dda3fb7242c7 to your computer and use it in GitHub Desktop.
test out picodvi + seesaw in CircuitPython
# space_dvi_seesaw_test.py -- test out picodvi + seesaw in CircuitPython
# 26 Apr 2023 - @todbot / Tod Kurt
# demo at https://www.youtube.com/live/Gcw8rOYaO8U?feature=share&t=916
import time, random, math
import board, displayio, vectorio
import terminalio
from adafruit_display_text import bitmap_label as label
from adafruit_seesaw.seesaw import Seesaw
ss = Seesaw(board.I2C())
display = board.DISPLAY
dw,dh = display.width, display.height
print("display width, height:", dw,dh)
maingroup = displayio.Group()
display.root_group = maingroup
pal = displayio.Palette(3)
pal[0] = 0xffffff
pal[1] = 0x0099ff
pal[2] = 0xaa33aa
shapes = displayio.Group()
maingroup.append(shapes)
shapes_pos = []
text = label.Label(terminalio.FONT, text="<-0->", color=0x999999, x=100,y=100)
maingroup.append(text)
wcnt, hcnt = 32/4, 24/4
for i in range(wcnt):
for j in range(hcnt):
x,y = 20 + i * 40, 20 + j * 40
da = random.uniform(-2.6, 2.6)
shapes_pos.append( (x,y, da) )
p = random.randint(0,2)
c = vectorio.Circle(pixel_shader=pal, color_index=p, radius=1, x=x, y=y)
shapes.append(c)
r = 10
a = 0
last_joy_read = time.monotonic()
joyx,joyy = ss.analog_read(2), ss.analog_read(3)
joyfilt = 0.95
while True:
if time.monotonic() - last_joy_read > 0.1:
last_joy_read = time.monotonic()
joyx = joyfilt * joyx + (1-joyfilt)*ss.analog_read(2)
joyy = joyfilt * joyy + (1-joyfilt)*ss.analog_read(3)
print(joyx,joyy)
text.x = int(joyx * dw / 1024)
text.y = dh - int(joyy * dh / 1024)
for i in range(len(shapes_pos)):
cx,cy,da = shapes_pos[i]
shapes[i].x = int( cx + r * math.sin(a+da) )
shapes[i].y = int( cy + r * math.cos(a+da) )
a += 0.01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment