MikeL's FreeBSD howto - Addressable LED string DIY version - testloop
This is a child doc to MikeL's FreeBSD howto -
Addressable LED string DIY version. See this page for what
project I'm talking about.
Note that this page is shown in archeological order, namely newest
first. If you want to understand the events in order, start at
the bottom.
[20221101]
The following routines started out as test patterns when I was first
getting going on programming this thing. The program has become much
more sophisticated over time, but it's still hard-code to do
anything.
The individual tests will be listed below, bear in mind that with some
programming, any of these effects could be combined.
Idle loop sections in no particular order
- xmas tree
Simple xmas tree. Starts with just the green tree shape, with a
trunk, then adds a star on top. Then adds xmas lights in colors,
and eventually the green background disappears making it just xmas
lights in a tree shape.
- snow
This emulates a snowstorm. You can set the density of flakes, and
the occasional wind shear that makes the flakes jump a little
right or left. Note that the density will increase slightly over
time as if it was snowing harder.
- drunkard's walk
This implements the
classic Random
walk in 2 dimensions. The center of the grid is lit up white
to show where we're starting. Each cycle a random direction is
chosen, only one step - up, down, right, left or the 4 possible
diagonals. The color of that dot is then changed to show where
our drunk is. Each time he hits the same dot, it increases the
color; starting at light blue, bringing in green, then eventually
adding red for a final white appearance. It quits when our drunk
has hit the same square enough times for it to go brght white (at
this writing 12 hits). Note that this is a wraparound world, if
he hits an edge, he'll appear on the opposite side.
- game_of_life
Implements the
classic
Conway's Game of Life. The rules are:
- Any live cell with two or three live neighbors
survives.
- Any dead cell with three live neighbors becomes a live
cell.
- All other live cells die in the next generation. Similarly
all other dead cells stay dead.
Items of note:
- My "universe" is NOT wraparound - if a "glider" hits
the edge, it croaks.
- It is either seeded with a set of 75 random cells, or with a
set of interesting objects. The objects are, left-to-right, a
"blinker", a "toad", a "beacon" and "glider". The former three
change but do not move, the latter changes and moves. Which
method is chosen at random so you'll see one or the other when the
idle loop repeats.
- The game stops when there's no living cells left, or no
changes happened between two adjacent generations, or there were
no changes between the new and one-step-back generations (in other
words, all oscillators), or finally, after 200 generations (half
second pause per generation).
- dark_fill_v
Lights the entire matrix with a solid color (at this time green),
then rapidly turns it black, by filling in black, starting at the
leftmost column, going downwards, then starting from the top of
the next column, going downwards, etc. until the whole matrix is
dark.
- us_flag
A crude attempt at a static American flag.
- bg_fill (white)
These Alitove WS2811 LED strings have an annoying deficiency,
namely that with the provided wiring, you can only power about 3
strings (of 50 bulbs). This grid started out at 10 strings, and
will be increasing. This means that I have to bring in additional
wires from the power supply every 3 strings, making for a bunch of
extra cabling. If any of these cables were to fail (connector
fall out or some such), this all-bright-white display makes it
immediately obvious.
- chaseblock
Diagonal red stripe with white edges moves rightwards. Sort of a
candy cane look.
- curtain_up, curtain_down
Self explanatory.
- calibrate
Draws the perimeter of the matrix. It uses different colors on
each of the 4 edges in order to facilitate figuring out exactly
what's wrong when you're originally setting up. Bear in mind that
the matrix may not exactly correspond to strings of lights. One
step further, there may be lights that are not usable as they are
stuck dangling between rows - the light strings are 2-3 inches
apart, but I'm using them on a grid of every other at 2 inches,
thus one bulb is unusable at the end of each row. This display
aids in building/correcting the corresponding layout array in the
software. (See "OuputArray" in previous page.)
- test_chars
Displays all the characters that we know how to display. Bear in
mind that I had to implement this character set entirely myself,
apologies if it's a bit crude. Also note that not every ASCII
charcter is present, I've only implemented those I needed plus a
few extra punctuations I may use some day.
- show_str
See also test_chars. This is the final mechanism for displaying a
text string. Simply give it a text string and it will smooth
scroll it for you. Test implementation is
"PerennialVintners.com".
- step_scroll, cute_scroll
When I was first implementing characters, I had to immediately
build in automatic sideways scrolling as the matrix could only fit
3 characters across! These are two of my early attempts. They
both had such a cool look, that I decided to keep them around.
cute_scroll ("Perennial") draws 3 letters, then moves them one at
a time, leftwards one character. step_scroll ("Vintners") draws 3
chars, then moves all 3 at a time leftwards.
- fill_fade_in_out
Starts with a black background, and fills the screen with a single
color, slowly bringing it brighter, until maxium is reached, then
fades back out to black.
- black_hole_h, black_hole_v
Draws a background bright color pattern. As it goes, this
background moves rapidly in blurry stripes leftwards. It's hard
to see in the camera view, but there's a little black block that
moves through the image. The h version has a 2x2 black block that
moves left-to-right across the top 2 rows, then starts over at the
left side one row down, and contiunes until it reaches the bottom.
The v version is only a single black dot, and goes down the
leftmost column, then the next column, etc.
- diags
Draws diagonal lines, on a light background, showing the whole
matrix. Again, this is for help in verifying calibration.
- binary_dots
Simulates the bits in an 8 bit number as it increments up from 0
to max 255. Also shows the decimal or hex value, chosen at random
each time.
- back_n_forth
A thick vertical bar moves back and forth across a random color
background.
- sparkle
A random color background is drawn, then white highlights pop
across it at random. The idea was to simulate sunlight sparkling
across water.
- singlechase
A light blue diagonal moves across the screen, rightwards, fuzzily
turning heavier as it goes. This was probably an early offshoot
of sparkle to emulate waves across water.
- rowdown
Like curtain_down, is a single background color, but is only a
single dark row moving down.
- colorstep
A set of fuzzy colors moving diagonally left and down. Same as
used in background for black_hole_h and black_hole_v.
- border
Same as calibrate but all one color.
- forest candle
Randomish green background with a yellow dot mvoing slowly across
the middle. This was an attempt to look like someone walking
along the edge of a forest with a candle at night.
- flashlight
White circle moves at random across screen, dark background.
- Spinner
Alternates slash, vertical bar, backslash to give a spinning
effect.
Copyright © 1995-2024
Mike Lempriere
(running on host bayanus)