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
Type | Name | Description |
---|---|---|
System.Int32 | value | the number to display |
System.Int32 | deviceId | the 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
Type | Name | Description |
---|---|---|
Meadow.Foundation.Displays.Max7219.CharacterType | character | the character to display |
System.Int32 | digit | the digit index starting from the left |
System.Boolean | showDecimal | show the decimal with the character |
System.Int32 | deviceId | the 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
Type | Name | Description |
---|---|---|
System.Int32 | digit | the digit index of the character |
System.Int32 | deviceId | the cascaded device id |
TestDisplay(TimeSpan)
Helper test method - will turn all leds on then off
View Source
public void TestDisplay(TimeSpan time)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | time | time to show leds |
SetMode(Max7219Mode)
Set the display mode of the Max7219
View Source
public void SetMode(Max7219.Max7219Mode maxMode)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Foundation.Displays.Max7219.Max7219Mode | maxMode | the mode |
SetBrightness(int, int)
Sets the brightness for a specific device
View Source
public void SetBrightness(int intensity, int deviceId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | intensity | intensity level ranging from 0..15. |
System.Int32 | deviceId | index 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
Type | Name | Description |
---|---|---|
System.Int32 | intensity | intensity 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
Type | Name | Description |
---|---|---|
System.Byte | value | the value to display |
System.Int32 | digit | the digit index |
System.Int32 | deviceId | the 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
Type | Name | Description |
---|---|---|
System.Int32 | digit | the digit index |
System.Int32 | deviceId | the 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
Type | Name |
---|---|
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
Type | Name |
---|---|
System.Int32 | start |
System.Int32 | end |
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
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Is disposing |
Show(int, int, int, int)
Partial screen update
View Source
public void Show(int left, int top, int right, int bottom)
Parameters
Type | Name |
---|---|
System.Int32 | left |
System.Int32 | top |
System.Int32 | right |
System.Int32 | bottom |
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
Type | Name |
---|---|
System.Boolean | updateDisplay |
DrawPixel(int, int, Color)
Draw pixel at location
View Source
public void DrawPixel(int x, int y, Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | x position |
System.Int32 | y | y position |
Meadow.Color | color | color 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
Type | Name | Description |
---|---|---|
System.Int32 | x | x position in pixels |
System.Int32 | y | y position in pixels |
System.Boolean | enabled | True = 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
Type | Name | Description |
---|---|---|
System.Int32 | x | x position in pixels |
System.Int32 | y | y position in pixels |
Fill(Color, bool)
Fill with color
View Source
public void Fill(Color fillColor, bool updateDisplay = false)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Color | fillColor | color - converted to on/off |
System.Boolean | updateDisplay | should 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
Type | Name | Description |
---|---|---|
System.Int32 | x | x position |
System.Int32 | y | y position |
System.Int32 | width | width of region |
System.Int32 | height | height of region |
Meadow.Color | fillColor | color - converted to on/off |
WriteBuffer(int, int, IPixelBuffer)
Draw buffer at location
View Source
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | x position in pixels |
System.Int32 | y | y position in pixels |
Meadow.Foundation.Graphics.Buffers.IPixelBuffer | displayBuffer | buffer to draw |
Fill(Color)
Fill the display with a normalized color to on/off
View Source
public void Fill(Color color)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Color | color | The 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
Type | Name | Description |
---|---|---|
System.Int32 | x | The x position in pixels |
System.Int32 | y | The 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
Type | Name | Description |
---|---|---|
System.Int32 | x | The x position in pixels |
System.Int32 | y | The y position in pixels |
Meadow.Color | color | The pixel color normalized to on/off |
Implements
Meadow.Hardware.ISpiPeripheral
System.IDisposable
- Meadow.Foundation.Graphics.IGraphicsDisplay
- Meadow.Foundation.Graphics.Buffers.IPixelBuffer