LED Matrix Font

Well then, basically I made a container called FontChar that holds 6*7 bytes constrained to use 4 bits.

struct FontChar{
  byte value : 4;
};

This is what caused the RAM usage to get halved.

Then I made a constructor of that struct to enable simple construction of characters. The usual way to use structs is:

FontChar char;

char.value = 3;

But since you set 42 values that would take a while with that syntax.

Bu using the constructor you get kind of a visual feedback as well.

I added a function called byte get(byte x,byte y); which returns the corresponding byte if this was a 2d matrix.

The constants
const byte V = 0; //Void
const byte QR = 1; //Quarter
const byte HAL = 2; //Half
const byte FULL = 3;
const byte NO_SUCH_INDEX = 0;

Was created to provide a gretaer visual feedback when initializing FontChars.

The rest is basically just initializing instances of the struct FontChar and the client only uses the get(x,y) function.

Wikipedia on clases and structs

PM me for a more in-depth examination / explanation if you want. :slight_smile: