ARRAY ={{10, 31, 'A',{1,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0}}, etc. };
but that will take < 36 lookups so what I need is a better way.
what I need a leaves that has both the index 1 to 36 and a letter.
Does the library say I need a string?
is there a better way??
like hash (11, 'A'); where I Can match the 'A' and return the 11, to do this ARRAY[11].segment[1]; which should be the 'a' pin in the display.
~~Cris
Do you simply want to take a c-string, say "ABC0123" and display it on your 16 segment displays ?
The problems is exactly the same as with a seven segment display but instead of using bytes to represent each displayable character you have to use unsigned integers.
You address the array by using the ascii value of the character so you have to map ranges 0x30 to 0x39 (the digits) and 0x41 to 0x5A (the capital letters) to 0 to 35 (your array index)
Not sure what you are trying to achieve with such a complicated structure.
A glyph at the end of the day is just 16 bits telling you which segment is on or off (so a uint16_t type will be great for that).
-> if you look at the ASCII table
0 is 48(dec)... 9 is 57(dec)
A is 65(dec)... Z is 90(dec)
they are nicely ordered but capital letters do not follow digits directly, so you need some sort of intelligence.
=> the idea would be to just create an array based on the table in your link where most significant bit is status of segment a and least significant digit the status if segment p
const uint16_t pictograms[] = {
0b1111111100100010,Ā // 0Ā --> index 0
0b0000001100000000,Ā // 1
...
0b1101111100010001,Ā // 9
0b0011111100010001,Ā // A --> index 10
...
0b1100110000100010,Ā // Z
}
then when you want to display a char, you just have to do a short if/else
uint16_t pictogramFor(const char c)
{
Ā if (c >= '0' && c <= '9') return pictograms[c-'0'];
Ā if (c >= 'A' && c <= 'Z') return pictograms[c-'A'+10];
Ā return 0;
}
printing a character X now is a matter of calling pictogramFor(X) and going through a small for loop to check each bit (use bitRead()) and light on or off the corresponding pin.
You are probably not the first to do this so a quick Google search for 16-segment font should turn up someone's list. Like this one:
It leaves out the 17th bit (decimal point) so it will fit into a 16-bit integer. It covers all 96 printable ASCII characters. Just subtract 32 from each character to get the index into the table.
Btw, itās probably the case that the original ā36 lookupsā per value would be plenty fast enough for anything human readable on a relatively small number of displays.