From 0d1e95fbea3852ca4b49b1ab99f131dc7d2c8b18 Mon Sep 17 00:00:00 2001 From: Rich Lander Date: Fri, 16 Dec 2022 21:43:42 -0800 Subject: [PATCH] Add support for Micro Dot pHat --- src/devices/Is31fl3730/Bonnet5x7x6.cs | 61 --------- .../{Matrix3730.cs => DotMatrix5x7.cs} | 24 ++-- ...outPair5x7.cs => DotMatrixBreakout10x7.cs} | 66 ++++++---- src/devices/Is31fl3730/Is31fl3730.cs | 99 +++++++++----- src/devices/Is31fl3730/Is31fl3730.csproj | 5 +- src/devices/Is31fl3730/MatrixValues.cs | 22 +++- src/devices/Is31fl3730/MicroDotPhat30x7.cs | 123 ++++++++++++++++++ src/devices/Is31fl3730/MicroDotphat30x7.cs | 87 ------------- src/devices/Is31fl3730/Registers.cs | 24 ++-- src/devices/Is31fl3730/samples/Program.cs | 31 +++-- 10 files changed, 290 insertions(+), 252 deletions(-) delete mode 100644 src/devices/Is31fl3730/Bonnet5x7x6.cs rename src/devices/Is31fl3730/{Matrix3730.cs => DotMatrix5x7.cs} (67%) rename src/devices/Is31fl3730/{BreakoutPair5x7.cs => DotMatrixBreakout10x7.cs} (58%) create mode 100644 src/devices/Is31fl3730/MicroDotPhat30x7.cs delete mode 100644 src/devices/Is31fl3730/MicroDotphat30x7.cs diff --git a/src/devices/Is31fl3730/Bonnet5x7x6.cs b/src/devices/Is31fl3730/Bonnet5x7x6.cs deleted file mode 100644 index fb93e6dc47..0000000000 --- a/src/devices/Is31fl3730/Bonnet5x7x6.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Device.I2c; -using System.Threading; - -namespace Iot.Device.Display -{ - /// - /// Represents LED Dot Matrix Breakout - /// - // Datasheet: https://cdn-shop.adafruit.com/product-files/3017/31FL3730.pdf - // Product: https://shop.pimoroni.com/products/led-dot-matrix-breakout - // Related repo: https://github.com/pimoroni/microdot-phat - public class Matrix5x7 : IDisposable - { - private readonly Is31fl3730 _is31fl3730; - - /// - /// Initialize IS31FL3730 device - /// - /// The to create with. - /// The width of the LED matrix. - /// The height of the LED matrix. - public Matrix5x7(Is31fl3730 is31fl3730, int width, int height, int matrix) - { - _is31fl3730 = is31fl3730; - Width = width; - Height = height; - Matrix = matrix; - } - - /// - /// Indexer for matrix. - /// - public int this[int x, int y] - { - get => _is31fl3730.ReadLed(Matrix, x, y); - set => _is31fl3730.WriteLed(Matrix, x, y, value); - } - - public const int DefaultI2cAddress = 0x61; - - /// - /// Width of LED matrix (x axis). - /// - public readonly int Width = 5; - - /// - /// Height of LED matrix (y axis). - /// - public readonly int Height = 7; - - /// - /// Identification of matrix (of 2). - /// - public readonly int Matrix = 0; - } -} diff --git a/src/devices/Is31fl3730/Matrix3730.cs b/src/devices/Is31fl3730/DotMatrix5x7.cs similarity index 67% rename from src/devices/Is31fl3730/Matrix3730.cs rename to src/devices/Is31fl3730/DotMatrix5x7.cs index d527c05c70..7f810f33f8 100644 --- a/src/devices/Is31fl3730/Matrix3730.cs +++ b/src/devices/Is31fl3730/DotMatrix5x7.cs @@ -11,28 +11,29 @@ namespace Iot.Device.Display /// /// Represents LED Dot Matrix driven by IS31FL3730. /// - public class Matrix3730 + public class DotMatrix5x7 { private readonly Is31fl3730 _is31fl3730; + private readonly int _matrix; /// - /// Initialize IS31FL3730 device + /// Initialize Dot Matrix IS31FL3730 device. /// /// The to create with. /// The index of the matrix (of a pair). - public Matrix3730(Is31fl3730 is31fl3730, int matrix) + public DotMatrix5x7(Is31fl3730 is31fl3730, int matrix) { _is31fl3730 = is31fl3730; - Matrix = matrix; + _matrix = matrix; } /// - /// Indexer for matrix. + /// Indexer for matrix. x: 0..4; y: 0..6. /// public int this[int x, int y] { - get => _is31fl3730.ReadLed(Matrix, x, y); - set => _is31fl3730.WriteLed(Matrix, x, y, value); + get => _is31fl3730.Read(_matrix, x, y); + set => _is31fl3730.Write(_matrix, x, y, value); } /// @@ -45,19 +46,14 @@ public Matrix3730(Is31fl3730 is31fl3730, int matrix) /// public readonly int Height = 7; - /// - /// Identification of matrix (of 2). - /// - public readonly int Matrix = 0; - /// /// Fill matrix (0 is dark; 1 is lit). /// - public void Fill(int value) => _is31fl3730.Fill(Matrix, value); + public void Fill(int value) => _is31fl3730.Fill(_matrix, value); /// /// Fill matrix (0 is dark; 1 is lit). /// - public void UpdateDecimalPoint(int value) => _is31fl3730.UpdateDecimalPoint(Matrix, value); + public void WriteDecimalPoint(int value) => _is31fl3730.WriteDecimalPoint(_matrix, value); } } diff --git a/src/devices/Is31fl3730/BreakoutPair5x7.cs b/src/devices/Is31fl3730/DotMatrixBreakout10x7.cs similarity index 58% rename from src/devices/Is31fl3730/BreakoutPair5x7.cs rename to src/devices/Is31fl3730/DotMatrixBreakout10x7.cs index 14f4f7014e..7ea85e0432 100644 --- a/src/devices/Is31fl3730/BreakoutPair5x7.cs +++ b/src/devices/Is31fl3730/DotMatrixBreakout10x7.cs @@ -15,51 +15,43 @@ namespace Iot.Device.Display // Datasheet: https://cdn-shop.adafruit.com/product-files/3017/31FL3730.pdf // Product: https://shop.pimoroni.com/products/led-dot-matrix-breakout // Related repo: https://github.com/pimoroni/microdot-phat - public class BreakoutPair5x7 + public class DotMatrixBreakout10x7 { - private readonly Matrix3730[] _pair; + private readonly DotMatrix5x7[] _matrices; private Is31fl3730 _is31fl3730; /// - /// Initialize IS31FL3730 device + /// Initialize Dot Matrix Breakout IS31FL3730 device. /// /// The to create with. - public BreakoutPair5x7(I2cDevice i2cDevice) + public DotMatrixBreakout10x7(I2cDevice i2cDevice) { i2cDevice = i2cDevice ?? throw new ArgumentException($"{nameof(i2cDevice)} is null."); _is31fl3730 = new(i2cDevice); _is31fl3730.DisplayMode = DisplayMode.MatrixOneAndTwo; _is31fl3730.Initialize(); - _pair = new Matrix3730[] + _matrices = new DotMatrix5x7[] { - new Matrix3730(_is31fl3730, 0), - new Matrix3730(_is31fl3730, 1) + new DotMatrix5x7(_is31fl3730, 0), + new DotMatrix5x7(_is31fl3730, 1) }; } /// - /// Initialize IS31FL3730 device + /// Initialize Dot Matrix Breakout IS31FL3730 device. /// /// The to create with. - public BreakoutPair5x7(Is31fl3730 is31fl3730) + public DotMatrixBreakout10x7(Is31fl3730 is31fl3730) { is31fl3730 = is31fl3730 ?? throw new ArgumentException($"{nameof(is31fl3730)} is null."); _is31fl3730 = is31fl3730; - _pair = new Matrix3730[] + _matrices = new DotMatrix5x7[] { - new Matrix3730(_is31fl3730, 0), - new Matrix3730(_is31fl3730, 1) + new DotMatrix5x7(_is31fl3730, 0), + new DotMatrix5x7(_is31fl3730, 1) }; } - /// - /// Indexer for matrix pair. - /// - public Matrix3730 this[int matrix] - { - get => _pair[matrix]; - } - /// /// Default I2C address for device. /// @@ -76,13 +68,41 @@ public BreakoutPair5x7(Is31fl3730 is31fl3730) public readonly int Height = 7; /// - /// Identification of matrix (of 2). + /// Indexer for matrices. /// - public readonly int Matrix = 0; + public DotMatrix5x7 this[int matrix] => _matrices[matrix]; + + /// + /// Indexer for matrix pair. + /// + public int this[int x, int y] + { + get => x switch + { + < 5 => this[0][x, y], + < 10 => this[1][x - 5, y], + _ => throw new ArgumentException($"{nameof(x)} value out of range") + }; + set + { + if (x < 5) + { + this[0][x, y] = value; + } + else if (x < 10) + { + this[1][x - 5, y] = value; + } + else + { + throw new ArgumentException($"{nameof(x)} value out of range"); + } + } + } /// /// Fill All LEDs. /// - public void Fill(int value) => _is31fl3730.FillAll(value); + public void Fill(int value) => _is31fl3730.Fill(value); } } diff --git a/src/devices/Is31fl3730/Is31fl3730.cs b/src/devices/Is31fl3730/Is31fl3730.cs index c370fc5831..9ea5def10b 100644 --- a/src/devices/Is31fl3730/Is31fl3730.cs +++ b/src/devices/Is31fl3730/Is31fl3730.cs @@ -18,7 +18,7 @@ namespace Iot.Device.Display // Based on: https://github.com/pimoroni/microdot-phat/blob/master/library/microdotphat/matrix.py public class Is31fl3730 { - private readonly byte[] _matrix_registers = new byte[] { FunctionRegister.Matrix1, FunctionRegister.Matrix2 }; + private readonly byte[] _matrix_addresses = new byte[] { FunctionRegister.Matrix1, FunctionRegister.Matrix2 }; private readonly List _buffers = new List { new byte[8], @@ -68,24 +68,29 @@ public Is31fl3730(I2cDevice i2cDevice) public static readonly int[] SupportedI2cAddresses = new int[] { DefaultI2cAddress, 0x62, 0x63 }; /// - /// Brightness of LED matrix (override default value (128; max brightness)); set before calling Initialize method). + /// Brightness of LED matrix (override default value (128; max brightness); set before calling Initialize method). /// - public int Brightness = 0; + public int Brightness { get; set; } /// /// Full current setting for each row output of LED matrix (override default value (40 mA)); set before calling Initialize method). /// - public Current Current = 0; + public Current Current { get; set; } /// /// Matrix mode (override default value (8x8); set before calling Initialize method). /// - public MatrixMode MatrixMode = 0; + public MatrixMode MatrixMode { get; set; } /// - /// Display mode (override default value (Matrix 1 only); set before calling Initialize method). + /// Display mode (use to override default value (Matrix 1 only; right-most); set before calling Initialize method). /// - public DisplayMode DisplayMode = 0; + public DisplayMode DisplayMode { get; set; } + + /// + /// Enables or disables auto-buggering. + /// + public bool BufferingEnabled { get; set; } = true; /// /// Initialize LED driver. @@ -131,15 +136,8 @@ public void Initialize() /// The x dimension for the LED. /// The y dimension for the LED. /// The value to write. - public void WriteLed(int matrix, int x, int y, int value) + public void Write(int matrix, int x, int y, int value) { - if (matrix > 1 || - x > 4 || - y > 6) - { - throw new ArgumentException("Argument out of range."); - } - /* The following diagrams and information demonstrate how the matrix is structured. @@ -233,13 +231,20 @@ x x concern. It has nothing to do with byte structure. */ + if (matrix > 1 || + x > 4 || + y > 6) + { + throw new ArgumentException("Argument out of range."); + } + int logicalRow = matrix is 0 ? y : x; int logicalColumn = matrix is 0 ? x : y; byte mask = (byte)(1 << logicalColumn); byte[] buffer = _buffers[matrix]; buffer[logicalRow] = UpdateByte(buffer[logicalRow], mask, value); - UpdateMatrixRegister(matrix); + AutoFlush(matrix); } /// @@ -248,7 +253,7 @@ x x /// The matrix to use. /// The x dimension for the LED. /// The y dimension for the LED. - public int ReadLed(int matrix, int x, int y) + public int Read(int matrix, int x, int y) { int row = matrix is 0 ? y : x; int column = matrix is 0 ? x : y; @@ -261,19 +266,28 @@ public int ReadLed(int matrix, int x, int y) /// /// Update decimal point for matrix. /// - public void UpdateDecimalPoint(int matrix, int value) + public void WriteDecimalPoint(int matrix, int value) { byte[] buffer = _buffers[matrix]; - int row = matrix is 0 ? 6 : 7; + int row = matrix is 0 ? MatrixValues.MatrixOneDecimalRow : MatrixValues.MatrixTwoDecimalRow; byte mask = matrix is 0 ? MatrixValues.MatrixOneDecimalMask : MatrixValues.MatrixTwoDecimalMask; buffer[row] = UpdateByte(buffer[row], mask, value); - UpdateMatrixRegister(matrix); + AutoFlush(matrix); } /// - /// Fill all LEDs with value. + /// Fill LEDs with value, per matrix. /// - public void FillAll(int value) + public void Fill(int matrix, int value) + { + _buffers[matrix].AsSpan().Fill((byte)value); + AutoFlush(matrix); + } + + /// + /// Fill LEDs with value. + /// + public void Fill(int value) { foreach (int i in Range(0, 2)) { @@ -285,16 +299,28 @@ public void FillAll(int value) } /// - /// Fill all LEDs with value, per Matrix. + /// Fill LEDs with value, per matrix. /// - public void Fill(int matrix, int value) + public void Flush(int matrix) { - _buffers[matrix].AsSpan().Fill((byte)value); - UpdateMatrixRegister(matrix); + if (_enabled[matrix]) + { + Write(_matrix_addresses[matrix], _buffers[matrix]); + WriteUpdateRegister(); + } + } + + /// + /// Fill LEDs with value. + /// + public void Flush() + { + Flush(0); + Flush(1); } /// - /// Reset device. + /// Resets all registers to default value. /// public void Reset() => Write(FunctionRegister.Reset, MatrixValues.EightBitValue); @@ -343,16 +369,21 @@ private byte UpdateByte(byte data, byte mask, int value) return data; } - private void UpdateMatrixRegister(int matrix) + /* + Per the datasheet: + The data sent to the Data Registers will be stored in + temporary registers. A write operation of any 8-bit value + to the Update Column Register is required to update + the Data Registers (01h~0Bh, 0Eh~18h). + */ + private void WriteUpdateRegister() => Write(FunctionRegister.UpdateColumn, MatrixValues.EightBitValue); + + private void AutoFlush(int matrix) { - if (_enabled[matrix]) + if (BufferingEnabled) { - Write(_matrix_registers[matrix], _buffers[matrix]); + Flush(matrix); } - - WriteUpdateRegister(); } - - private void WriteUpdateRegister() => Write(FunctionRegister.UpdateColumn, MatrixValues.EightBitValue); } } diff --git a/src/devices/Is31fl3730/Is31fl3730.csproj b/src/devices/Is31fl3730/Is31fl3730.csproj index 7e89faae11..9151f68d22 100644 --- a/src/devices/Is31fl3730/Is31fl3730.csproj +++ b/src/devices/Is31fl3730/Is31fl3730.csproj @@ -13,7 +13,8 @@ - - + + + \ No newline at end of file diff --git a/src/devices/Is31fl3730/MatrixValues.cs b/src/devices/Is31fl3730/MatrixValues.cs index 96f70b2fd7..b5c8b10366 100644 --- a/src/devices/Is31fl3730/MatrixValues.cs +++ b/src/devices/Is31fl3730/MatrixValues.cs @@ -9,18 +9,34 @@ namespace Iot.Device.Display public static class MatrixValues { /// - /// Address for Configuration Register. + /// Arbitrary 8-bit value to write to Update Column Register, as required by datasheet. /// public static byte EightBitValue = 8; /// - /// Address for Configuration Register. + /// Matrix one decimal point mask. /// public static byte MatrixOneDecimalMask = 128; /// - /// Address for Configuration Register. + /// Matrix one decimal point row. + /// + public static byte MatrixOneDecimalRow = 6; + + /// + /// Matrix two mask for decimal point. /// public static byte MatrixTwoDecimalMask = 64; + + /// + /// Matrix two decimal point row. + /// + public static byte MatrixTwoDecimalRow = 7; + + /// + /// I2C addresses for Micro Dot pHat, right to left. + /// + public static int[] Addresses = new int[] { 0x63, 0x62, 0x61 }; + } } diff --git a/src/devices/Is31fl3730/MicroDotPhat30x7.cs b/src/devices/Is31fl3730/MicroDotPhat30x7.cs new file mode 100644 index 0000000000..ff56ff77d6 --- /dev/null +++ b/src/devices/Is31fl3730/MicroDotPhat30x7.cs @@ -0,0 +1,123 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Device.I2c; +using System.Linq; +using System.Threading; + +namespace Iot.Device.Display +{ + /// + /// Represents a Pimoroni Micro Dot pHat. + /// + // Datasheet: https://cdn-shop.adafruit.com/product-files/3017/31FL3730.pdf + // Product: https://shop.pimoroni.com/products/microdot-phat + // Product: https://shop.pimoroni.com/products/led-dot-matrix-breakout + // Related repo: https://github.com/pimoroni/microdot-phat + public class MicroDotPhat30x7 + { + private DotMatrixBreakout10x7[] _pairs; + private DotMatrix5x7[] _matrices = new DotMatrix5x7[6]; + + /// + /// Initialize Micro Dot pHAT IS31FL3730 device. + /// + public MicroDotPhat30x7() + { + _pairs = new DotMatrixBreakout10x7[3]; + + foreach (var pair in Enumerable.Range(0, 3)) + { + I2cDevice i2cDevice = I2cDevice.Create(new(1, MatrixValues.Addresses[pair])); + _pairs[pair] = new DotMatrixBreakout10x7(i2cDevice); + _matrices[pair * 2] = _pairs[pair][1]; + _matrices[pair * 2 + 1] = _pairs[pair][0]; + } + } + + /// + /// Initialize Micro Dot pHAT IS31FL3730 device. + /// + /// The first Dot Matrix pair. + /// The first Dot Matrix pair. + /// The first Dot Matrix pair. + public MicroDotPhat30x7(Is31fl3730 first, Is31fl3730 second, Is31fl3730 third) + { + if (first is null || second is null || third is null) + { + throw new ArgumentException($"Input argument is null."); + } + + _pairs = new DotMatrixBreakout10x7[] + { + new(first), + new(second), + new(third) + }; + + foreach (var pair in Enumerable.Range(0, 3)) + { + _matrices[pair * 2] = _pairs[pair][1]; + _matrices[pair * 2 + 1] = _pairs[pair][0]; + } + } + + /// + /// Width of LED matrix (x axis). + /// + public readonly int Width = 30; + + /// + /// Height of LED matrix (y axis). + /// + public readonly int Height = 7; + + /// + /// Indexer for matrices. + /// + public DotMatrix5x7 this[int matrix] => _matrices[matrix]; + + /// + /// Indexer for Micro Dot pHat matrix. + /// + public int this[int x, int y] + { + get + { + if (x >= 30 || y > 6) + { + throw new ArgumentException("Input value out of range."); + } + + int matrix = x % 5; + int modx = x - (matrix * 5); + return this[matrix][modx, y]; + } + set + { + if (x >= 30 || y > 6) + { + throw new ArgumentException("Input value out of range."); + } + + int matrix = x / 5; + int modx = x - (matrix * 5); + this[matrix][modx, y] = value; + } + } + + /// + /// Fill All LEDs. + /// + public void Fill(int value) + { + foreach (var pair in _pairs) + { + pair.Fill(value); + } + } + } +} diff --git a/src/devices/Is31fl3730/MicroDotphat30x7.cs b/src/devices/Is31fl3730/MicroDotphat30x7.cs deleted file mode 100644 index 5e1b6ef84e..0000000000 --- a/src/devices/Is31fl3730/MicroDotphat30x7.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Device.I2c; -using System.Threading; - -namespace Iot.Device.Display -{ - /// - /// Represents a Pimoroni Micro Dot pHat. - /// - // Datasheet: https://cdn-shop.adafruit.com/product-files/3017/31FL3730.pdf - // Product: https://shop.pimoroni.com/products/microdot-phat - // Product: https://shop.pimoroni.com/products/led-dot-matrix-breakout - // Related repo: https://github.com/pimoroni/microdot-phat - public class MicroDotPhat30x7 - { - private readonly Matrix3730 _matrixOne; - private readonly Matrix3730 _matrixTwo; - private readonly Matrix3730[] _pair = new Matrix3730[2]; - private Is31fl3730 _is31fl3730; - private I2cDevice? _i2cDevice; - - /// - /// Initialize IS31FL3730 device - /// - /// The to create with. - public MicroDotPhat30x7(I2cDevice i2cDevice) - { - i2cDevice = i2cDevice ?? throw new ArgumentException($"{nameof(i2cDevice)} is null."); - _is31fl3730 = new(_i2cDevice); - _is31fl3730.DisplayMode = DisplayMode.MatrixOneAndTwo; - _is31fl3730.Initialize(); - _matrixOne = new Matrix3730(_is31fl3730, 0); - _matrixTwo = new Matrix3730(_is31fl3730, 1); - _pair = new Matrix3730[] { _matrixOne, _matrixTwo }; - } - - /// - /// Initialize IS31FL3730 device - /// - /// The to create with. - public MicroDotPhat30x7(Is31fl3730 is31fl3730) - { - is31fl3730 = is31fl3730 ?? throw new ArgumentException($"{nameof(is31fl3730)} is null."); - _matrixOne = new Matrix3730(_is31fl3730, 0); - _matrixTwo = new Matrix3730(_is31fl3730, 1); - _pair = new Matrix3730[] { _matrixOne, _matrixTwo }; - } - - /// - /// Indexer for matrix pair. - /// - public Matrix3730 this[int matrix] - { - get => _pair[matrix]; - } - - /// - /// Default I2C address for device. - /// - public const int DefaultI2cAddress = 0x61; - - /// - /// Width of LED matrix (x axis). - /// - public readonly int Width = 10; - - /// - /// Height of LED matrix (y axis). - /// - public readonly int Height = 7; - - /// - /// Identification of matrix (of 2). - /// - public readonly int Matrix = 0; - - /// - /// Fill All LEDs. - /// - public void Fill(int value) => _is31fl3730.FillAll(value); - } -} diff --git a/src/devices/Is31fl3730/Registers.cs b/src/devices/Is31fl3730/Registers.cs index ee61563547..0e40030fff 100644 --- a/src/devices/Is31fl3730/Registers.cs +++ b/src/devices/Is31fl3730/Registers.cs @@ -12,36 +12,36 @@ public static class FunctionRegister /// Address for Configuration Register. /// public static byte Configuration = 0x0; - + /// /// Address for Matrix 1 Data Register. /// - public static byte Matrix1 = 0x1; - - /// - /// Address for Matrix 2 Data Register. - /// - public static byte Matrix2 = 0x0E; - + public static byte Matrix1 = 0x01; + /// /// Address for Update Column Register. /// public static byte UpdateColumn = 0x0C; - + /// /// Address for Lighting Effect Register. /// public static byte LightingEffect = 0x0D; - + + /// + /// Address for Matrix 2 Data Register. + /// + public static byte Matrix2 = 0x0E; + /// /// Address for PWM Register. /// public static byte Pwm = 0x19; - + /// /// Address for Reset Register. /// - public static byte Reset = 0x0C; + public static byte Reset = 0xFF; } /// diff --git a/src/devices/Is31fl3730/samples/Program.cs b/src/devices/Is31fl3730/samples/Program.cs index 483a7e074f..5a2165ae97 100644 --- a/src/devices/Is31fl3730/samples/Program.cs +++ b/src/devices/Is31fl3730/samples/Program.cs @@ -8,20 +8,10 @@ using System.Threading; using Iot.Device.Display; -using I2cDevice i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, BreakoutPair5x7.DefaultI2cAddress)); -BreakoutPair5x7 breakout = new(i2cDevice); - -breakout.Fill(0); -Thread.Sleep(100); -var mOne = breakout[0]; -var mTwo = breakout[1]; - -if (mOne is null || mTwo is null) -{ - return; -} - -var matrix = mOne; +// using I2cDevice i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, DotMatrixBreakout10x7.DefaultI2cAddress)); +// DotMatrixBreakout10x7 matrix = new(i2cDevice); +MicroDotPhat30x7 matrix = new(); +matrix.Fill(0); // Dimensions int width = matrix.Width - 1; @@ -165,6 +155,15 @@ void WriteColumnPixels(int column, IEnumerable pixels, int value) Thread.Sleep(1000); matrix.Fill(0); -matrix.UpdateDecimalPoint(1); -Thread.Sleep(1000); +// For single matrix demo +// matrix.WriteDecimalPoint(1); +// Thread.Sleep(1000); + +// For Micro Dot pHat demo +foreach (var index in Enumerable.Range(0, 6)) +{ + matrix[index].WriteDecimalPoint(1); + Thread.Sleep(250); +} + matrix.Fill(0);