How do I write a generic function that takes a Number or some alphabets and display that in 7- bit segment display.? [closed]
I want to write a Digital Clock application in which I have a 7- bit segment display. I want to write a generic code for displaying all the input. I have a CGPath in which I have 1 line for each segment. Now, how would I write a generic function for the above description? Any help with some logic or code will be appreciated. Thanks
Simplest would be a look-up table. You could do it with ten bytes. Assign one bit in the bytes to each segment. Pre-load the table with the hex values necessary to set the bits. Index the table with your digit 0-9. If you want to have additional combinations of segments then make the table larger -- typically these are set up to display an additional 6 "characters" (eg, A, b, C, d, E, and F), making the table conveniently 16 long.
But, for extra credit, do it with NAND gates.
精彩评论