Hi Adam,
Adam Davies wrote:
> Good to hear from you and hope you're keeping well!
Thanks, you too - yes all good. I hope you'll enjoy Iceland once you
can move around. I haven't been but have heard wonderful things.
> Thanks for the file, it seems to mostly make sense to me.
Great!
> If you have time to build a file which receives OLA values and has uder
> defineable variables for the universe it listens to, and the 'threshold'
> (i.e. the 0-255 value a channel has to be higher than for an LED to turn
> on) I'd be most grateful.
All right, attached is a script with everything put together.
Note that it requires a spi.py helper file for calling the kernel,
the link to that is in a comment near the top.
I'm not sure that this script works since I can't test it, but any
problems should be minor, the big picture should be all right.
If it doesn't completely make sense or you have any questions please
ask away.
universe, threshold and output interval can be set at the top.
threshold is the minimum channel value to switch LEDs on. You should
be able to switch on all LEDs without the universe receiving anything
by setting threshold = 0, this is an interesting test to determine
whether performance is in fact sufficient for a pleasant visual.
I'm not super optimistic, I suspect there will be noticeable flicker.
It's good to do that test without any universe data coming it, because
processing universe updates also requires CPU time and if there's flicker
already without universe updates then the flicker will always be worse
once updates are added.
The 0x80 0x40 .. stuff deals with individual bits within byte values,
corresponding to individual GPIO pins within GPIO ports, and while
some may think that this should be abstracted more neatly this
software is short and simple enough, and the software is tied to the
particular hardware design strongly enough that I consider abstraction
to do more harm than good.
Channel mapping is implicit.
The first 64 channels map to the plane on MCP23S17 addr=4 GPA pin 7,
the next 64 to the plane on pin 6, and so on.
The channels within each plane map in order onto MCP23S17 addr=0 GPA pin 7
through 0, addr=0 GPB pin 7 through 0, addr=1 GPA pin 7 through 0, etc.
If this is a disaster for you then the ordering could be changed in
create_data() and NewData(), or a translation map added to the start
of NewData for all channels or for each plane.
> I suppose I'm trying to achieve 2 things
Good goals! Testing two unknowns at once is always dangerous, but
again, we'll help.
> Having a known, working file would allow me to achieve 1 of the goals!
Well, I'm curious whether my script is in fact working, heh. :)
//Peter