Den Delimarsky

I am an engineer working on API documentation, security and machine learning.

github twitter linkedin email rss

A better sample for the Netduino ShieldStudio 4-digit shield

Apr 30, 2011
2 minutes read

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.

Image lost since old blog.

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); 
matrix.WriteString("Hello from my sample!", 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.

Image lost since old blog.

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:

Image lost since old blog.

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:

Video lost since old blog.


Back to posts