pyramidscheme / pyramidtriangles

Software to run the Pyramid Scheme triangles
3 stars 0 forks source link

Integrate new grid cell code #10

Closed silverlyra closed 5 years ago

silverlyra commented 5 years ago

This is a doozy. It integrates the new code from this weekend in grid.cell with the rest of the codebase.

Known issues

Changes

Local IP auto-detection

On startup, go_tri will look for a network interface with a 192.168.*.* IP address to use to talk to the LeDMX units. If it doesn’t find one, it’ll exit. You can set the local IP manually with --bind.

More NamedTuples

Instead of using bare (row, col) tuples, there's a new Position subclass of NamedTuple. DMX addresses and cell and pixel information now also have their own named tuples.

Grid rewrite

TriangleGrid is now just called Grid, and it has a simpler interface. All the cell-selection methods have been factored out into functions in a new grid/select.py file:

from color import HSV
from grid import Grid, Position, bottom_edge, hexagon, pointed_up

grid.clear() # same as before

grid.set(pointed_up, HSV(0.1, 0.6, 0.9)) # set color of every up-pointing triangle
grid.set(bottom_edge, HSV(0.7, 0.8, 0.9)) # set color of every cell on the bottom edge
grid.set(hexagon(Position(11, 10)), HSV(0.9, 0.8, 1)) # set color of the bottom-middle hexagon
grid.go()

Model simplification

ModelBase is now a simpler interface to implement. set sets a single LED at a time. (It's nice, but this is how I broke the simulator, which works with whole cells, not individual LED's.)

class ModelBase(ABC):
    def set(self, addr: Address, color: Color): ...
    def go(self): ...

Show updates

I updated the existing shows for the new Grid interface.

johnemajor commented 5 years ago

I'm sure I can hack the simulator back to living. It does not need to handle per-led messages, it was already ignoring pixel settings (And setting the whole cell if pixels were being used). Some of the earlier design was with a mind towards bigger canvas mapping. Ie: treating all of the triangles independently so one side, or both sides, could be interacted with (and not always have all 7 mirror each other). Not sure if these changes go counter to those aims, but worth a mention.

sul3n3t commented 5 years ago

Awesome! Yeah, no problem with fixing the simulator later. Maybe can even update it to simulate pixels within cells.