Click here to Skip to main content
15,906,097 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am Electronics Embedded Engineer. I Doing a Moving message display and i need to develop a software.

there are 20x20 Led arranged in a matrix. when a user selects any installed computer Fonts and type a letter in the keyboard. the letter should be displayed and a code related to it should also be displayed.

if typed a letter is A

xxxxxxiiiiiiiixxxxxx
xxxxxiiiixxiiiixxxxx
xxxxiiiixxxxiiiixxxx
xxxiiiixxxxxxiiiixxx
xxiiiixxxxxxxxiiiixx
xiiiixxxxxxxxxxiiiix
iiiixxxxxxxxxxxxiiii
iiiixxxxxxxxxxxxiiii
iiiixxxxxxxxxxxxiiii
iiiixxxxxxxxxxxxiiii
iiiixxxxxxxxxxxxiiii
iiiixxxxxxxxxxxxiiii
iiiiiiiiiiiiiiiiiiii
iiiiiiiiiiiiiiiiiiii
iiiixxxxxxxxxxxxiiii
iiiixxxxxxxxxxxxiiii
iiiixxxxxxxxxxxxiiii
iiiixxxxxxxxxxxxiiii
iiiixxxxxxxxxxxxiiii
iiiixxxxxxxxxxxxiiii

such a code map should be generated where i = led on, x = led off

Can Anybody Help me please!!!!!!!!!!!!
Posted

That is really, really difficult. The problem is that some characters don't fit into a 20x20 matrix. For example, in English, there are some characters with "descenders": "gjpqy" and sometimes "z" depending on teh font. These descenders are necessary, because without them, in most fonts 'a' and 'q' look identical. In addition, in some fonts characters like 'Q' have a portion below the baseline. So, your matrix is no longer 20x20, it's 20x14 or so. Fortunately, this provides ample space for proportionally spaced characters: 'I' is narrower than 'W', but they should both fit because you have lost so much height. (You may have to loose some at the top to allow for accented characters as well - not sure).

It's nasty - very nasty - and making the characters look good when you automatically draw them at low pixcel resolutions is especially difficult, because the font engines built into Windows don't just work in black and white, like LED's do: they work in shades of grey (To prove it take a screen shot of this page, and zoom in on text in Paint)

A much, much better solution is to design fixed height character sets yourself, and display those - it's a PITA and a lot of dull hand-destroying work, but it's really is the best way to get nice character shapes. I should know, I've done it far too many times over the years...:laugh: (And before you ask, no I can't send you the fonts!)
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 3-Aug-11 15:23pm    
Quite possible! Please see my solution. Yes, 20x20 is a challenge (so, my 5 for your notes). It's only a matter of right font.
--SA
Here is the idea:

1) Use the class System.Drawing.Bitmap, create an instance using the constructor Bitmap(Int32, Int32, PixelFormat). For PixelFormat, use System.Drawing.Imaging.PixelFormat.Format1bppIndexed to have the minimal 1-bit black-and-white format. Make the bitmap size 20x20.

2) Get an instance of System.Drawing.Graphics using its static factory method System.Drawing.Graphics.FromImage using an instance of your bitmap as a parameter.

3) Using the instance of System.Drawing.Graphics, draw the text on your bitmap using one of the System.Drawing.Graphics.DrawString methods. This is a delicate step: you need to select appropriate font (probably monospace), its size and location to fit a character in your 20x20 matrix and position (say, center) it properly. Some minor experimenting can help. It will be a challenge to find a font good for such a small matrix, but I believe it's possible. With old text-mode PC programs I used to use even smaller matrices.

4) Don't forget to dispose the instance of System.Drawing.Graphics. It's the best to declare and use the instance under the "using" statement. Same thing stands about the instance of System.Drawing.Bitmap; see http://msdn.microsoft.com/en-us/library/yh598w02%28v=VS.100%29.aspx[^].

5) To get access to the bitmap's bits, use the method System.Drawing.Bitmap.LockBits and System.Runtime.InteropServices.Marshal; see the code sample here: http://msdn.microsoft.com/en-us/library/5ey6h79d.aspx[^], but don't forget you have only one bit per pixel.

6) Use the array of bitmap bits and bmpData.Stride (see the code sample referenced above) to address your bits on your physical matrix.

7) PROFIT!

See:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx[^],
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx[^],
http://msdn.microsoft.com/en-us/library/3z132tat.aspx[^],
http://msdn.microsoft.com/en-us/library/system.drawing.imaging.pixelformat.aspx[^],
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.aspx[^].

(You see how much you will need?! :-))

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900