A better sample for the Netduino ShieldStudio 4-digit shield

Tags: netduino, how-to, tools, net, microsoft

I recently started working with the Netduino microcontroller and one of the initial projects I decided to tackle was creating a better sample for a LED matrix shield. It wasn’t really complicated – overall, it took me around an hour to put everything together and test it on a real device.

DSC_0257

Here are some things that I added to the updated sample:

  • Automatically initialize the I2CDevice instance when the LEDMatrix class is instantiated.
  • Perform the device setup automatically on class instantiation
  • Ability to write a single character in one matrix slot with additional effects (ShortBlink or LongBlink)
  • Ability to directly write a string instead of passing single characters
  • Support of different ways a string can de displayed (MarqueeRight, MarqueeLeft, Blocks)
  • Built-in references for some special characters (e.g. currency symbols, arrow up, arrow down)
  • Support for writing inverted characters (inverted background/foreground)

That being said, a simple snippet that would allow the user to pass a string would look like this:

LEDMatrix matrix = new LEDMatrix(0×50, 400); <br />matrix.Clear(); <br />matrix.WriteString(&quot;Hello from my sample!&quot;, StringEffect.MarqueeRight);

Special symbols are introduced simply to reduce the amount of work needed to look for special characters. A simple for loop from 0 to 255 will reveal most of the characters that cannot be introduced from the keyboard in a single tap, if needed. The characters I included in the SpecialCharacters enum are the most useful for me.

DSC_0257 (2)

Special blinking effects for characters are taking place “one slot at a time” due to the single-threaded nature of the Netduino CPU. This can be modified with a Timer and preserved object state, but for now I needed sequential blinking so this does the job perfectly.

Inverted characters are calculated by adding 128 to the default character byte value (according to the ASCII table – decimal) for alphanumeric characters and some symbols. The inverted version for the characters represented in the image above would look like this:

DSC_0257 (3)

This is more of a “just for fun” class, but it extends the default sample to show some basic capabilities out of the box. You can download the ZIP here.

Here is a video of the class in action:

Requirements:

1 Comment

  • cyn said

    hi,

    how i can set single Leds on / off.
    I cant find any command in the MAX driver documentation.

    THX for the tutorial.

    greets!

Add a Comment