LED fun, four characters at a time, with Netduino and ShieldStudio

Today's post returns us to one of the more fun hardware things to play with, Netduino. Den Delimarsky in his, A better sample for the Netduino ShieldStudio 4-digit shield, post.

image

Here's a snip of Den's tweaks;

"...

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

...

To load the Visual Studio Solution you'll need, at minimum, Microsoft Visual C# Express 2010 and .NET Micro Framework 4.1 installed. Of course you won't be able to deploy it without the hardware, but if all you want to check out the code...

Here's a code snip that displays a character;

public void WriteSingleCharacter(char value, MatrixUnit panel, CharEffect effect = CharEffect.None)
{
switch (effect)
{
case CharEffect.None:
{
if (value != '\0')
{
device.Execute(new I2CDevice.I2CTransaction[]
{
I2CDevice.CreateWriteTransaction(new byte[] { (byte)panel, (byte)value })
}, i2ctimeout);
}
else
{
device.Execute(new I2CDevice.I2CTransaction[]
{
I2CDevice.CreateWriteTransaction(new byte[] { (byte)panel, 0x20 })
}, i2ctimeout);
}
break;
}
case CharEffect.ShortBlink:
{
WriteSingleCharacter(value, panel);
Thread.Sleep(500);
WriteSingleCharacter((char)SpecialChar.Empty, panel);
Thread.Sleep(500);
WriteSingleCharacter(value, panel);
break;
}
case CharEffect.LongBlink:
{
WriteSingleCharacter(value, panel);
Thread.Sleep(2000);
WriteSingleCharacter((char)SpecialChar.Empty, panel);
Thread.Sleep(2000);
WriteSingleCharacter(value, panel);
break;
}
}

}

Here’s a few more links you might find interesting:

Follow the Discussion

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.