Ever have a project that you just keep finding cool things you want to

Ever have a project that you just keep finding cool things you want to add to it? This matrix is turning into that.

So far:
IR module + remote
SD card
BMP180 temp/pressure sensor.

Things I’m looking to add:
Piezo buzzer for audible feedback on certain actions
Synapse RF module for wireless comms with my PC.

Dude, welcome to my life. Hell, just look at FastLED’s checkin log!

I bet!

My current project as a sub-project: Figure out how to generate fonts for the SmartMatrix library. BDF fonts are impossible to find, for starters, and bdf2c is in source format only, but I should be able to compile that. Except bdf2c doesn’t handle fonts from the other half of the conversion equation, ttf2bdf.

I suppose I could hand-carve the glyphs, as the format used is really simple. it’s just amazingly tedious to do.

Maybe work out a method that parses glyphs from a pixmap - I have a huge library of old video game fonts - I use them in my silly shoot-em-up scene generator: http://shmups.twyst.us/hori/

Example font file: http://shmups.twyst.us/fontgen/fonts/imgf-Image%20Fight%20(IREM).png

All I want is the “Commodore 64” font. Then my life will be complete :slight_smile:

I was doing some research on fonts and looking at the current method of handling fonts… And sad to say, its pretty inefficient. It’s clever, and a way of making the fonts human readable, but it’s something like 8x bigger than it needs to be because of it.

So I’m looking at parsing fonts from the SD card. Use a tool like BMFont to make a bitmap with a reference file, and go from there.

Of course there is also the tiny resolution we’re working with.

Hi Noel, I agree SmartMatrix font support could use some improvement. It had to start somewhere though. :slight_smile:

I haven’t tried ttf2bdf → bdf2c, what is the incompatibility?

It looks like the font example that you supplied is two shades on top of a transparent background, so SmartMatrix would need to be able to handle fonts containing multiple bits per pixel. Right now it just handles 1bpp. I believe bdf is also limited to 1bpp, so I would go a different route to converting fonts.

I like your idea of loading bmps from the SD card. As long as the character set is a reasonable size, like the example you provided, it should only take a few kB of RAM to store a bitmap for a single font.

I’ve done a few project with Synapse SNAP modules and like them a lot (as long as you’re not trying to do too much number crunching on them). I used the SM200P81 modules to make a USB adapter for programming and sending serial data, and for the target device, and it worked well. They are just over $20 ea from Future, and after adding a cheap USB-TTL adapter with 3.3V out from Aliexpress, much cheaper than buying a dev kit. Pictures I just put up on my personal G+:
https://plus.google.com/101433779981299302803/posts/Ch92yBZWiUu

bdf2c specifically says it can’t handle the fonts made from ttf2bdf :frowning: as per: http://sourceforge.net/p/bdf2c/code/ci/master/tree/

Anyways, I have a BMP reading routine that is pretty fast for files from the SD card, so it’s mostly figuring out how to crop a BMP to specific dimensions. It’s surprisingly non-trivial when you don’t have a GDL to handle that. :wink:

I’m looking at the FTOLED library, as they have a different BMP reading function, with offsets. Swipin’ code from errywhere!

Are you thinking of reading on the fly, cropping letters out of the BMP file to generate a bitmap for your string, or reading the entire BMP into a bitmap in RAM, then pulling letters out?

I was thinking on the fly. Of course, there’s also the option of having all the glyphs in separate files, named via ascii code - so 32-122 or so. That would probably work well.
And if we use a “magic color” (probably some neon pink color), then we can fake a transparency. Or just make black transparent.

I think that could work, as long as you load the entire bitmap for your string at once, and not just the visible part of the bitmap (what SmartMatrix fonts are doing right now). You don’t want to have to read from the SD card in interrupt context several times per second, at a minimum that will interfere with any other SD card operations going on, like playing a GIF animation, and it will probably take too long.

If in the future the SmartMatrix library supported playing a GIF animation in the background (something I’m thinking about), then I see issues with updating the string while the GIF is playing. If you had the full font already loaded into RAM, you could build your string bitmap without needing to go to SD, interrupting the animation.

As I understand, reading several files vs one large file using the Arduino SDFAT library is a little slow, so I would suggest keeping the BMP to one file if possible for efficiency.

That makes sense. So now I just need to figure that out. In the image font I linked earlier, I’d only use one row of course. But that’s still a pretty big file, RAM-wise. 760px by 8px by 3bytes = 18240 bytes.

Where does the 3bytes come from? It should be stored as 2 bits per pixel to accommodate the two shades or transparent pixel. (760 * 2bpp) * 8 rows = 1520 bytes.

if I’m using a bmp font, most of the ones I have are multi-color: http://shmups.twyst.us/fontgen/fonts/sold-Soldam%20(Data%20East).png

There HAS to be a way to have dynamic fonts without a bunch of terrible hoops to jump through to get them. I’d be okay with 1-bit fonts, if it was possible to convert some of these TTF files, like Silkscreen or Sevenet 7. Heck, a web-based app to convert TTF -> c format would be aces.

I see, but even with a multicolor font, you would probably want to generate a palette that is just a few bits per pixel. A font similar to what you showed with up to 15 colors (plus transparency) would only take up 3kB.

There are a lot of font conversion tools out there. I did research before I settled on bdf2c, but it wasn’t exhaustive. Let me know if you find anything good!

Ah, right. Limiting the number of colors would work much better.

And yea, I’ll keep a-hunting. :slight_smile:

So here’s what I have for a start - use a PHP script to read out all chars into a bitmap, like so: http://i.imgur.com/GePp2Ch.png - next up is write a quick parser to read that bitmap, and return a c-format array. I need to fine-tune the sizes in that font, but it’s a start.

Looks like a good start to me!

Sadly, the spacing on the glyphs is all over the place and I can’t get rid of the anti-aliasing. So I’m not sure this is the method to use.

So in the interests of stuff that Just Works ™, I managed to find some nice monospace BDF files - Profont and Gohufont, and managed to compile bdf2c, and now I have 3 new fonts - one of which is nice and bold. I’ll probably remove the two bigger apple fonts from the list, just to save space.

Maybe set up some defines to enable/disable fonts? I can see them taking up a fair chunk of space.