Lots of LEDs Shield

This shield comes as a kit and demonstrates charlieplexing.
The shield has been tested with a Netduino Plus 2. It works on a Netduino Classic too but it would be too slow to animate properly.

Toolbox.NETMF.Hardware.LolShield(CpuPins)
  • CpuPins An array with all used pins

Methods

  • Clear() Clears the display
  • Dispose() Disposes the object
  • Get(Row, Col) Gets the state of a pixel
  • HorizontalLine(Row, Value) Draws a horizontal row
  • Invert() Inverts the display
  • LoadBitmap(Bitmap, BitmapWidth, StartLeft, StartTop, DrawLeft, DrawTop, DrawWidth, DrawHeight) Draws a bitmap
  • Set(Row, Col, Value) Sets the state of a pixel
  • VerticalLine(Col, Value) Draws a vertical row

Properties

  • Height The height of the display
  • Width The width of the display

Sample code in C#

// Defines a new LoL-shield connected to pins 2 to 13
LolShield Shield = new LolShield(new Cpu.Pin[] {
    Pins.GPIO_PIN_D2, Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D5, 
    Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D9, 
    Pins.GPIO_PIN_D10, Pins.GPIO_PIN_D11, Pins.GPIO_PIN_D12, Pins.GPIO_PIN_D13
});

// Then, a test for every single LED:
for (int LedNo = 0; LedNo < Shield.Width * Shield.Height; ++LedNo)
{
    Shield.Set(LedNo, true);
    Thread.Sleep(100);
    Shield.Set(LedNo, false);
}

// Loop over all columns
for (int Col = 0; Col < Shield.Width; ++Col)
{
    Shield.VerticalLine(Col, true);
    Thread.Sleep(100);
    Shield.VerticalLine(Col, false);
}

// Loop over all rows
for (int Row = 0; Row < Shield.Height; ++Row)
{
    Shield.HorizontalLine(Row, true);
    Thread.Sleep(100);
    Shield.HorizontalLine(Row, false);
}

// Now turns on all LEDs for a few seconds
Shield.Clear(true);
Thread.Sleep(2000);
 
// Draws a bitmap to the screen (0xaa == 0b10101010)
Shield.LoadBitmap(new byte[] { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa });

// And inverts that state after a few seconds, for 2 times
Thread.Sleep(2000); Shield.Invert();
Thread.Sleep(2000); Shield.Invert();

Sample code in VB

' Defines a new LoL-shield connected to pins 2 to 13
Dim Shield As LolShield = New LolShield(New Cpu.Pin() {
    Pins.GPIO_PIN_D2, Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D5,
    Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D9,
    Pins.GPIO_PIN_D10, Pins.GPIO_PIN_D11, Pins.GPIO_PIN_D12, Pins.GPIO_PIN_D13
})

' Then, a test for every single LED:
For LedNo As Integer = 0 To (Shield.Width * Shield.Height) - 1
    Shield.Set(LedNo, True)
    Thread.Sleep(100)
    Shield.Set(LedNo, False)
Next

' Loop over all columns
For Col As Integer = 0 To Shield.Width - 1
    Shield.VerticalLine(Col, True)
    Thread.Sleep(100)
    Shield.VerticalLine(Col, False)
Next

' Loop over all rows
For Row As Integer = 0 To Shield.Height - 1
    Shield.HorizontalLine(Row, True)
    Thread.Sleep(100)
    Shield.HorizontalLine(Row, False)
Next

' Now turns on all LEDs for a few seconds
Shield.Clear(True)
Thread.Sleep(2000)

' Draws a bitmap to the screen (&HAA == &B10101010)
Shield.LoadBitmap(New Byte() {&HAA, &HAA, &HAA, &HAA, &HAA, &HAA, &HAA, &HAA, &HAA, &HAA, &HAA, &HAA, &HAA, &HAA, &HAA, &HAA})

' And inverts that state after a few seconds, for 2 times
Thread.Sleep(2000) : Shield.Invert()
Thread.Sleep(2000) : Shield.Invert()

Last edited Dec 29, 2012 at 6:45 AM by Garrcomm, version 2