AaronLiddiment / LEDText

FastLED Flexible Text Message Class requires LEDMatrix Class
89 stars 32 forks source link

Smallest possible font 3 x 5 pixels #5

Closed benlooi closed 7 years ago

benlooi commented 7 years ago

Hi! I would like to make my own small font for a project, consisting of mainly numbers and a decimal point. I studied the fontMatrise file and kinda figured I need to somehow make the values for each row for characters 46 to 57.

It starts with 0x...then I guess the next 2 digits will determine how many LEDS will light up per row and in what combination. What I do not understand is the hexadecimal system and how it relates to a 3 x 5 font. Here are the following combis I need to form a number:

0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 1 0 0 0 0 0 1 0 0 1 1 0 1 1 0 0

Can anyone advise how each can be represented in the format 0x00...0xFF? For my learning, some explanation would be great. I'll gladly contribute the file back to the project for this small number set.

Thanks!

benlooi commented 7 years ago

Hi again. Did some more research (read google). Decimal Hexadecimal Binary 0 = 0x00 = 0000-0000 1 = 0x01 = 0000-0001 2 = 0x02 = 0000-0010 3 = 0x03 = 0000-0011 4 = 0x04 = 0000-0100 5 = 0x05 = 0000-0101 6 = 0x06 = 0000-0110 7 = 0x07 = 0000-0111 8 = 0x08 = 0000-1000 9 = 0x09 = 0000-1001 10 = 0x0A = 0000-1010 11 = 0x0B = 0000-1011 12 = 0x0C = 0000-1100 13 = 0x0D = 0000-1101 14 = 0x0E = 0000-1110 15 = 0x0F = 0000-1111 so, I am guessing I could try these values to form my combis to turn the rows of LEDs on and off?

benlooi commented 7 years ago

Here is the working file. I just deleted 2 values from fontMatrise. Will figure out the combis to form numbers.

ifndef FontSmall3x5_h

define FontSmall3x5_h

const uint8_t Small3x5FontData[] = { 3, // Font Width 5, // Font Height 46, // Font First Character 57,// Font Last Character

    0x00, 0x00, 0x00, 0x00, 0x04,   // Code for char .
    0x10, 0x10, 0x20, 0x20, 0x20,   // Code for char /
    0x70, 0x88, 0xc8, 0xa8, 0x98,   // Code for char 0
    0x20, 0x60, 0x20, 0x20, 0x20,   // Code for char 1
    0x70, 0x88, 0x08, 0x10, 0x20,   // Code for char 2
    0xf8, 0x08, 0x10, 0x30, 0x08,   // Code for char 3
    0x10, 0x30, 0x50, 0x90, 0xf8,   // Code for char 4
    0xf8, 0x80, 0xf0, 0x08, 0x08,   // Code for char 5
    0x30, 0x40, 0x80, 0xf0, 0x88,   // Code for char 6
    0xf8, 0x08, 0x10, 0x20, 0x20,   // Code for char 7
    0x70, 0x88, 0x88, 0x70, 0x88,   // Code for char 8
    0x70, 0x88, 0x88, 0x78, 0x08,   // Code for char 9

            };

endif

benlooi commented 7 years ago

ifndef FontSmall3x5_h

define FontSmall3x5_h

const uint8_t SmallFont3x5Data[] = { 3, // Font Width 5, // Font Height 46, // Font First Character 57,// Font Last Character

0x00, 0x00, 0x00, 0x00, 0x40,   // Code for char .
0x20, 0x40, 0x40, 0x40, 0x80,   // Code for char /
0xf8, 0xA0, 0xA0, 0xA0, 0xf8,   // Code for char 0
0x40, 0xC0, 0x40, 0x40, 0x40,   // Code for char 1
0xf8, 0x30, 0xf8, 0x80, 0xf8,   // Code for char 2
0xf8, 0x30, 0xf8, 0x30, 0xf8,   // Code for char 3
0xA0, 0xA0, 0xf8, 0x30, 0x30,   // Code for char 4
0xf8, 0x80, 0xf8, 0x20, 0xf8,   // Code for char 5
0xf8, 0x80, 0xf8, 0xA0, 0xf8,   // Code for char 6
0xf8, 0x30, 0x40, 0x80, 0x80,   // Code for char 7
0xf8, 0xA0, 0xf8, 0xA0, 0xf8,   // Code for char 8
0xf8, 0xA0, 0xf8, 0x30, 0xf8  // Code for char 9

        };

endif

benlooi commented 7 years ago

Hi, The above is the working smallest possible number set font. A bit of background to why I needed this. I built an LED wall with squares, so each square is lighted by a WS2811 string LED. I had to display scores from another input at various parts of the screen, but the limited size and number of squares makes it impossible to use a 5x7 pixel font. So, I needed a 3 x 5 font, just for numbers. Not really possible to make letters with this few pixels.

I used the online converter at http://www.binaryhexconverter.com/hex-to-binary-converter and tried out the following: 0x20 -> 0000 0000 0010 0000 This gave me a lighted row of 001. I then tried other combis and this is what I found to correspond to the "building blocks" of numbers 0x20 -> 001 (Binary 0000 0000 0010 0000) 0x40 ->010 (Binary 0000 0000 0100 0000) 0x80 -> 100 (Binary 0000 0000 1000 0000) 0xE0 ->111 (Binary 0000 0000 1110 0000) (I used 0xf8...still works ) 0xA0 ->101 (Binary 0000 0000 1010 0000)

So, basically, the 3rd set of 4 numbers determine how the row of 3 will light up. That's sufficient for me to make my font.