# Text scrolling Marquee?

Is there some example code that I can have a message scroll across a matrix?

Hi Nagmier,
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?

@jeff,
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.

e.g.

``````var bitmap = array(bitmapSize)
bitmap[0] = 0x1234
bitmap[1] = 0x5678
...
``````

Or pack 32 bits (thereâ€™s no fractional hex literal for 32 bits):

``````var bitmap = array(bitmapSize)
bitmap[0] = 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â€¦

1 Like

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 `0x12`?

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â€¦

@nagmier and @eflyguy - Hey, I just posted some code to do this with an old 8-bit IBM font in this thread: Here's code for scrolling text across a matrix

1 Like