SPI VFD Character Mapping

Hello,

This is my first post to the forum so please excuse my naivety.

I could use some help figuring out how to send specific characters to the VFD display I purchased from Adafruit. I have made my first driver, which I can use to initialize the display and clear, etc. However, I am having to hard code the hex values that represent the text I am trying to display. Obviously this is very inefficient and I have figured out that the character map is ASCII. Browsing the forum I found that ASCII encoding is not supported in .netmf. Is there any way around this?

This may come down to me not really understanding encoding so a brief explanation might help??

I moved over to the FEZ Panda II after messing around unsuccessfully with the Netduino Plus. It also didn’t have many GPIOs so I am really liking the Panda.

Thanks

Hi Nate,

welcome to the forum. .Net MF is .NetMF, so besides the number of pins your netduino will be happy alongside us here :slight_smile:

The #1 question - what display? Point us to a link to it and someone will chime in !

@ Nate, is it [this display]? If the driver you’ve written is currently having to use hex values for character values, are you asking how to get a set of byte values from a string? I presume you would like your driver instead to support something like vfd.print(“Hello!”) and are asking how to translate “Hello” to a sequence of bytes to send to the VFD.


byte[] buffer = System.Text.Encoding.UTF8.GetBytes(sendstring);

‘buffer’ is now an array of bytes. If there’s nothing in sendstring that would require multiple-byte encoding, i.e. special characters outside the usual English alphabet, then UTF8 encoding should also be compatible with ASCII too.

RorschachUK

@ Nate - I’ve got this display, and it’s a beauty. Unfortunately, I do not believe there is a driver on codeshare for it (yet!). If you are motivated to come up with one, you will get instant geek cred here :slight_smile: I have used the Adafruit driver on an ExtraCore (small SM Arduino clone) and sent data to it serially via an XBee. That driver is solid, so would be a good starting point for a port. One note: watch the current - this thing can suck up quite a bit.

Thanks for the replies. Here is the link to the VFD:

I tried using the UTF8 encoding and it didn’t work. I’ll double check my code and if it still doesn’t work I’ll post the code when I get home from work. I am currently sending hex characters in a byte array to the display.

I am definitely going to build a driver for this and I will certainly post it on the codeshare section. Is there any special variable name conventions that I should use while building the driver? Thanks for the sample driver I’ll check it out.

How about this:


/// <summary>
        /// Converts a char array to a byte array
        /// </summary>
        /// <param name="Input">The char array</param>
        /// <returns>The byte array</returns>
        public static byte[] Chars2Bytes(char[] Input)
        {
            byte[] Output = new byte[Input.Length];
            for (int Counter = 0; Counter < Input.Length; ++Counter)
                Output[Counter] = (byte)Input[Counter];
            return Output;
        }


        /// <summary>
        /// Converts a byte array to a char array
        /// </summary>
        /// <param name="Input">The byte array</param>
        /// <returns>The char array</returns>
        public static char[] Bytes2Chars(byte[] Input)
        {
            char[] Output = new char[Input.Length];
            for (int Counter = 0; Counter < Input.Length; ++Counter)
                Output[Counter] = (char)Input[Counter];
            return Output;
        }


//then you would use it:
byte[] Buffer = Chars2Bytes(Data.ToCharArray());

Hope the above helps

Thanks to all that replied. I finally had a chance to try out some code and Rorschach had exactly what I needed.

[quote]byte[] buffer = System.Text.Encoding.UTF8.GetBytes(sendstring);
[/quote]

I am working on getting a driver finished for this display. I’ll post to this topic when I’m done.

Thanks Again!