Skip to main content

Class Max7219

Max7219 LED matrix driver

Assembly: Max7219.dll
View Source
Declaration
public class Max7219 : ISpiPeripheral, IDisposable, IPixelDisplay, IDisplay, IPixelBuffer

Implements:
Meadow.Hardware.ISpiPeripheral, System.IDisposable, Meadow.Peripherals.Displays.IPixelDisplay, Meadow.Peripherals.Displays.IDisplay, Meadow.Peripherals.Displays.IPixelBuffer

Properties

DeviceCount

Number of cascaded devices

View Source
Declaration
public int DeviceCount { get; }

DigitRows

Number of rows when representing digits

View Source
Declaration
public int DigitRows { get; }

DigitColumns

Number of columns when representing digits

View Source
Declaration
public int DigitColumns { get; }

Length

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

View Source
Declaration
public int Length { get; }

DefaultSpiBusSpeed

The default SPI bus speed for the device

View Source
Declaration
public Frequency DefaultSpiBusSpeed { get; }

SpiBusSpeed

The SPI bus speed for the device

View Source
Declaration
public Frequency SpiBusSpeed { get; set; }

DefaultSpiBusMode

The default SPI bus mode for the device

View Source
Declaration
public SpiClockConfiguration.Mode DefaultSpiBusMode { get; }

SpiBusMode

The SPI bus mode for the device

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

IsDisposed

Is the object disposed

View Source
Declaration
public bool IsDisposed { get; }

ColorMode

The currently set color mode for the display

View Source
Declaration
public ColorMode ColorMode { get; }

SupportedColorModes

The Color mode supported by the display

View Source
Declaration
public ColorMode SupportedColorModes { get; }

Width

Width of the display in pixels

View Source
Declaration
public int Width { get; }

Height

Height of the display in pixels

View Source
Declaration
public int Height { get; }

PixelBuffer

Provide a buffer that matches this display's color depth, height, and width This should be the buffer that is sent to the device when Show is called

View Source
Declaration
public IPixelBuffer PixelBuffer { get; }

BitDepth

The bit depth of the display

View Source
Declaration
public int BitDepth { get; }

ByteCount

The total bytes used for the display buffer

View Source
Declaration
public int ByteCount { get; }

Buffer

The backing buffer for the pixel buffer (not implemented)

View Source
Declaration
public byte[] Buffer { get; }

Fields

DigitsPerDevice

Number of digits per Module

View Source
Declaration
public const int DigitsPerDevice = 8

spiComms

SPI Communication bus used to communicate with the peripheral

View Source
Declaration
protected ISpiCommunications spiComms

Methods

SetNumber(int, int)

Set number to display (left aligned)

View Source
Declaration
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
Declaration
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
Declaration
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
Declaration
public void TestDisplay(TimeSpan time)
Parameters
TypeNameDescription
System.TimeSpantimetime to show leds

SetMode(Max7219Mode)

Set the display mode of the Max7219

View Source
Declaration
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
Declaration
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
Declaration
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
Declaration
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
Declaration
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
Declaration
public void Show()

WriteBuffer(byte[,])

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

View Source
Declaration
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
Declaration
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
Declaration
public void Dispose()

Dispose(bool)

Dispose of the object

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

Show(int, int, int, int)

Partial screen update

View Source
Declaration
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
Declaration
public void Clear()

Clear(bool)

Clears the buffer from the given start to end and flushes

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

DrawPixel(int, int, Color)

Draw pixel at location

View Source
Declaration
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
Declaration
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
Declaration
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
Declaration
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
Declaration
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
Declaration
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer)
Parameters
TypeNameDescription
System.Int32xx position in pixels
System.Int32yy position in pixels
Meadow.Peripherals.Displays.IPixelBufferdisplayBufferbuffer to draw

Fill(Color)

Fill the display with a normalized color to on/off

View Source
Declaration
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
Declaration
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
Declaration
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

  • Meadow.Hardware.ISpiPeripheral
  • System.IDisposable
  • Meadow.Peripherals.Displays.IPixelDisplay
  • Meadow.Peripherals.Displays.IDisplay
  • Meadow.Peripherals.Displays.IPixelBuffer