7-Segment and 16-Segment Display Component
This is a component which has been sitting around on my hard drive for a while. I thought I may as well release it for anyone who was interested. It’s a component that turns a string of digits into a 7-segment (alarm-clock style) display. There is also a 16-segment mode for displaying characters with diagonals etc.
It’s a fairly simple bit of code, most of the work is actually figuring out the character mappings, and as such I’ve only done upper-case A-Z, 0-9 and a little bit of punctuation.
Check it out here
Posted in Flex Components | 13 Comments
August 13th, 2007 at 9:17 pm
The characters are looking nice, how did you do the mapping?
August 13th, 2007 at 9:33 pm
The segments are numbered 1-7 (or 1-16) and each segment is treated as a single bit of an integer. So you get something like
mappings["8"] = 127; //1111111 binary
Which basically means that for the character “8″, all the segments of the display are on. So theres a whole list of these mappings, and converting a string to a 7-seg digit is just a matter of bit-masking and shifting in order to get the individual Boolean values for the segments like:
var segD:Boolean = (mappings[char] & 0×08) >> 3;
These values in turn dictate whether a segment is drawn with a light or dark colored fill.
August 14th, 2007 at 5:43 am
Very cool. But you said ‘release’… does that mean the source is forthcoming?
August 14th, 2007 at 7:22 am
Ah semantics!
Yeah the source is available now, right-click in the application. Something I overlooked.
Enjoy.
February 27th, 2008 at 8:29 am
Very nice!! Just what I needed.
Thanks.
September 20th, 2008 at 2:10 pm
how can i do that 16 segment display using Logic GATES and a 555 timer of course? can you teach me? we have project to do bout sequential circuits
September 21st, 2008 at 11:19 am
hi,im a student i need your help…
how can i display the word “OK” in one 16 segment only…
September 21st, 2008 at 11:22 am
or the word OK will be running?thankyou
September 22nd, 2008 at 4:26 am
In response to a few previous comments, I have no experience with hardware logic gates. etc. This component is completely in software. Mappings are simply stored as integers, where each of the bits 0-15 are used to indicate whether one of the segments is lit or unlit. there is a mapping from ASCII characters to these mapping integers. To change the mappings, add characters, etc. you would have to change the code to add another mapping. Look in the source at LedChar.mxml at the existing mappings to see how this is done.
For example: mappings["L"] = 56;
56 is 111000 in binary. The bytes are read from the right-left, so 111000 would represent segment A=off, B=off, C=off, D=on, E=on, F=on, (and the rest are off)
You can extend this through all the segments, and they are listed in order in the source file. Getting a word like ‘OK’ in a single segment is probably more of an artistic challenge than a technical one
January 19th, 2009 at 8:55 am
amazing think))
July 21st, 2009 at 1:05 pm
Nice!…been looking for something like this for a while,…here’s some extra mappings we figured out….Thanks!
mappings['_'] = 8
mappings['\''] = 512
mappings[','] = 4096
mappings['+'] = 2368
mappings['='] = 72
mappings['-'] = 64
mappings['/'] = 4608
mappings['\\'] = 1152
mappings['"'] = 258
mappings['|'] = 768
mappings['>'] = 4224
mappings[’
July 21st, 2009 at 1:13 pm
whoops…got clipped, lol
mappings[’
July 21st, 2009 at 1:21 pm
Thanks for the extra mappings, I’m glad you found the component useful.
I think the list is getting clipped by wordpress somehow. Not sure how you would need to escape it for it to get through