How do I Create a 7-Segment (LED type) Numeric font for video/vga
laser-vector
Posts: 118
this is probably a noob question but i was wondering if anybody knew how i could generate numbers that look like 7 segment displays for VGA??
Thanks
Post Edited (laser-vector) : 7/29/2010 11:56:53 PM GMT
Thanks
Post Edited (laser-vector) : 7/29/2010 11:56:53 PM GMT
Comments
Then to draw characters, you just set the X and Y, and call all the segments you want lit. If you provide a color argument to those methods, you could then also erase with the same code. Look at the google fonts, get some graph paper, and graph them out, using a grid size that you think will look good. Then code them in terms of lines and the fill command you find in graphics.spin.
Imagine a small 8 pixel by 8 pixel square as a sample of how to do a segment. It's drawn a coordinate that is aligned with it's upper left corner...
The line segments would be 0,0 - 0,8 : 0,8 - 8,8 : 8,8 - 8,0 : 8,0 - 0,0
Here is some sample code that illustrates what is needed to build up the two methods you will need to draw complete characters on the screen at a given position.
A segment would look like:
You've only got to get the 7 segments drawn out, then you can write another routine to "print" with the LED font, that calls the segments required for the characters.
If you want to, you could scale those numbers to make them bigger or smaller too. Just multiply before adding and drawing.
Notice I've got more than one line drawn from a plot point. I think that's the behavior. If not, just draw each line with a plot, followed by a line, and it will all be good, just a tad slower.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
8x8 color 80 Column NTSC Text Object
Wondering how to set tile colors in the graphics_demo.spin?
Safety Tip: Life is as good as YOU think it is!
Post Edited (potatohead) : 7/30/2010 5:29:05 AM GMT
ill give that a shot tomorrow!
If there are a ton of them, you might consider storing the line segments in the DAT section, with some special values to terminate a character. You can then change the LED_char to read from the DAT section, and just draw all the segments for that character.
DAT
char0 byte 1,4,6, 255
char1 byte 1,3,4, 255
char2 byte 0,3,5, 255
You can get rid of the case statement in there, and just have a repeat until loop that draws the segments it finds for the character. Keep knocking out segments until reaching the 255, which just isn't a segment, and can serve as a marker for end of character.
Chip wrote something that works like that for the text in graphics.spin Look that over, for a good example of how to pack all the characters into a DAT, using the SPIN procedures to draw them as needed.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
8x8 color 80 Column NTSC Text Object
Wondering how to set tile colors in the graphics_demo.spin?
Safety Tip: Life is as good as YOU think it is!
Post Edited (potatohead) : 7/30/2010 6:26:20 AM GMT