Is there some example code that I can have a message scroll across a matrix?
Unfortunately text and images aren’t supported right now. There’s nothing stopping it, but there’s no helper tools.
To do something like that, you’d need to encode your text as a bitmap (a bunch of bits, not a .bmp file), or encode a font and use that to draw the characters. Then to draw it, you could look up each pixel to see which bit of which character to draw.
I plan on adding support for text and images at some point in the future.
Hey Ben - do you think that support for array literals would help with this, so it’s easier to define bitmaps?
Yes, that would make it a bit easier code-wise, though the implementation is quite tricky (at the moment) and requires memory management, garbage collection, etc.
The best way to do it now would be to generate it. You have 2 options, use the 16 high bits that are easily specified, or pack all 32 bits with some shifting.
var bitmap = array(bitmapSize) bitmap = 0x1234 bitmap = 0x5678 ...
Or pack 32 bits (there’s no fractional hex literal for 32 bits):
var bitmap = array(bitmapSize) bitmap = 0x1234 + (0x5678>>16) ...
Here’s my start on coding numbers for a clock. Using a spreadsheet, manually creating digits, then coding them into an array similar to as shown above, using excel formulas to automate the necessary code.
I’ll use similar logic to determine the value for each pixel in the array…
Realizing the maths is a lot simpler if I assign the bits in reverse…
@elfguy - That’s clever to use Excel conditional formatting!
I think there might be a problem with the hex generator - In your screenshot, shouldn’t line 2 of the “0” digit be producing
0x11 instead of
Another idea: the Pixelblaze editor supports binary literals, so you can follow Ben’s example but in binary, which lets you somewhat visualize the bitmap in the editor’s monospaced font. Here’s your zero, for example:
digits[ 0] = 0b00001110 digits[ 1] = 0b00010001 digits[ 2] = 0b00010001 digits[ 3] = 0b00010001 digits[ 4] = 0b00001110
If you need to reverse the bits for use, you could adapt this gist
Yeah, there was a typo where I was multiplying the 5th bit by 17. Didn’t bother fixing the screenshot.
I’m not sure using arrays is the most efficient way to tackle this. Lots of playing around in my spare time…