Skip to main content

Class Max7219

Max7219 LED matrix driver

Assembly: Max7219.dll
View Source
public class Max7219 : ISpiPeripheral, IDisposable, IGraphicsDisplay, IPixelBuffer

Implements:
Meadow.Hardware.ISpiPeripheral, System.IDisposable, Meadow.Foundation.Graphics.IGraphicsDisplay, Meadow.Foundation.Graphics.Buffers.IPixelBuffer

Properties

DeviceCount

Number of cascaded devices

View Source
public int DeviceCount { get; }

DigitRows

Number of rows when representing digits

View Source
public int DigitRows { get; }

DigitColumns

Number of columns when representing digits

View Source
public int DigitColumns { get; }

Length

Gets the total number of digits (cascaded devices * num digits)

View Source
public int Length { get; }

DefaultSpiBusSpeed

The default SPI bus speed for the device

View Source
public Frequency DefaultSpiBusSpeed { get; }

SpiBusSpeed

The SPI bus speed for the device

View Source
public Frequency SpiBusSpeed { get; set; }

DefaultSpiBusMode

The default SPI bus mode for the device

View Source
public SpiClockConfiguration.Mode DefaultSpiBusMode { get; }

SpiBusMode

The SPI bus mode for the device

View Source
public SpiClockConfiguration.Mode SpiBusMode { get; set; }

IsDisposed

Is the object disposed

View Source
public bool IsDisposed { get; }

ColorMode

Color mode of display - 1bpp

View Source
public ColorMode ColorMode { get; }

SupportedColorModes

The Color mode supported by the display

View Source
public ColorMode SupportedColorModes { get; }

Width

Width of array of displays in pixels

View Source
public int Width { get; }

Height

Height of array of displays in pixels

View Source
public int Height { get; }

PixelBuffer

The offscreen buffer used for the display

View Source
public IPixelBuffer PixelBuffer { get; }

BitDepth

The bit depth of the display

View Source
public int BitDepth { get; }

ByteCount

The total bytes used for the display buffer

View Source
public int ByteCount { get; }

Buffer

The backing buffer for the pixel buffer (not implemented)

View Source
public byte[] Buffer { get; }

Fields

DigitsPerDevice

Number of digits per Module

View Source
public const int DigitsPerDevice = 8

spiComms

SPI Communication bus used to communicate with the peripheral

View Source
protected ISpiCommunications spiComms

Methods

SetNumber(int, int)

Set number to display (left aligned)

View Source
public void SetNumber(int value, int deviceId = 0)
Parameters
TypeNameDescription
System.Int32valuethe number to display
System.Int32deviceIdthe cascaded device id
Exceptions

System.ArgumentOutOfRangeException

SetCharacter(CharacterType, int, bool, int)

Set a single character

View Source
public void SetCharacter(Max7219.CharacterType character, int digit, bool showDecimal = false, int deviceId = 0)
Parameters
TypeNameDescription
Meadow.Foundation.Displays.Max7219.CharacterTypecharacterthe character to display
System.Int32digitthe digit index starting from the left
System.BooleanshowDecimalshow the decimal with the character
System.Int32deviceIdthe cascaded device id

GetCharacter(int, int)

Get the stored character

View Source
public Max7219.CharacterType GetCharacter(int digit, int deviceId = 0)
Returns

Meadow.Foundation.Displays.Max7219.CharacterType

Parameters
TypeNameDescription
System.Int32digitthe digit index of the character
System.Int32deviceIdthe cascaded device id

TestDisplay(TimeSpan)

Helper test method - will turn all leds on then off

View Source
public void TestDisplay(TimeSpan time)
Parameters
TypeNameDescription
System.TimeSpantimetime to show leds

SetMode(Max7219Mode)

Set the display mode of the Max7219

View Source
public void SetMode(Max7219.Max7219Mode maxMode)
Parameters
TypeNameDescription
Meadow.Foundation.Displays.Max7219.Max7219ModemaxModethe mode

SetBrightness(int, int)

Sets the brightness for a specific device

View Source
public void SetBrightness(int intensity, int deviceId)
Parameters
TypeNameDescription
System.Int32intensityintensity level ranging from 0..15.
System.Int32deviceIdindex of cascaded device.

SetBrightness(int)

Sets the brightness of all cascaded devices to the same intensity level.

View Source
public void SetBrightness(int intensity)
Parameters
TypeNameDescription
System.Int32intensityintensity level ranging from 0..15.

SetDigit(byte, int, int)

Set a number at a specific position

View Source
public void SetDigit(byte value, int digit, int deviceId = 0)
Parameters
TypeNameDescription
System.Bytevaluethe value to display
System.Int32digitthe digit index
System.Int32deviceIdthe cascaded device id

GetDigit(int, int)

Get the number at a specific position

View Source
public int GetDigit(int digit, int deviceId = 0)
Returns

System.Int32

Parameters
TypeNameDescription
System.Int32digitthe digit index
System.Int32deviceIdthe cascaded device id

Show()

Writes all the Values to the devices.

View Source
public void Show()

WriteBuffer(byte[,])

Writes a two dimensional buffer containing all the values to the devices.

View Source
public void WriteBuffer(byte[,] buffer)
Parameters
TypeName
System.Byte[,]buffer

Clear(int, int)

Clears the buffer from the given start to end (exclusive) and flushes

View Source
public void Clear(int start, int end)
Parameters
TypeName
System.Int32start
System.Int32end

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

View Source
public void Dispose()

Dispose(bool)

Dispose of the object

View Source
protected virtual void Dispose(bool disposing)
Parameters
TypeNameDescription
System.BooleandisposingIs disposing

Show(int, int, int, int)

Partial screen update

View Source
public void Show(int left, int top, int right, int bottom)
Parameters
TypeName
System.Int32left
System.Int32top
System.Int32right
System.Int32bottom

Clear()

Clear the display buffer

View Source
public void Clear()

Clear(bool)

Clears the buffer from the given start to end and flushes

View Source
public void Clear(bool updateDisplay = false)
Parameters
TypeName
System.BooleanupdateDisplay

DrawPixel(int, int, Color)

Draw pixel at location

View Source
public void DrawPixel(int x, int y, Color color)
Parameters
TypeNameDescription
System.Int32xx position
System.Int32yy position
Meadow.Colorcolorcolor of pixel - converted to on/off

DrawPixel(int, int, bool)

Draw pixel at location

View Source
public void DrawPixel(int x, int y, bool enabled)
Parameters
TypeNameDescription
System.Int32xx position in pixels
System.Int32yy position in pixels
System.BooleanenabledTrue = turn on pixel, false = turn off pixel

InvertPixel(int, int)

Invert pixel at location (toggle on/off)

View Source
public void InvertPixel(int x, int y)
Parameters
TypeNameDescription
System.Int32xx position in pixels
System.Int32yy position in pixels

Fill(Color, bool)

Fill with color

View Source
public void Fill(Color fillColor, bool updateDisplay = false)
Parameters
TypeNameDescription
Meadow.ColorfillColorcolor - converted to on/off
System.BooleanupdateDisplayshould refresh display

Fill(int, int, int, int, Color)

Fill region with color

View Source
public void Fill(int x, int y, int width, int height, Color fillColor)
Parameters
TypeNameDescription
System.Int32xx position
System.Int32yy position
System.Int32widthwidth of region
System.Int32heightheight of region
Meadow.ColorfillColorcolor - converted to on/off

WriteBuffer(int, int, IPixelBuffer)

Draw buffer at location

View Source
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer)
Parameters
TypeNameDescription
System.Int32xx position in pixels
System.Int32yy position in pixels
Meadow.Foundation.Graphics.Buffers.IPixelBufferdisplayBufferbuffer to draw

Fill(Color)

Fill the display with a normalized color to on/off

View Source
public void Fill(Color color)
Parameters
TypeNameDescription
Meadow.ColorcolorThe color to fill

GetPixel(int, int)

Get the Color of the pixel at a location (not implemented)

View Source
public Color GetPixel(int x, int y)
Returns

Meadow.Color: The pixel color

Parameters
TypeNameDescription
System.Int32xThe x position in pixels
System.Int32yThe y position in pixels
Exceptions

System.NotImplementedException

SetPixel(int, int, Color)

Set a pixel at a specific location

View Source
public void SetPixel(int x, int y, Color color)
Parameters
TypeNameDescription
System.Int32xThe x position in pixels
System.Int32yThe y position in pixels
Meadow.ColorcolorThe pixel color normalized to on/off

Implements