Skip to content

Commit

Permalink
Update type names
Browse files Browse the repository at this point in the history
  • Loading branch information
richlander committed Jan 17, 2023
1 parent d0d0964 commit 0921724
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/devices/Is31fl3730/FunctionRegister.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Iot.Device.Display
namespace Iot.Device.Display.Internal
{
/// <summary>
/// Register addresses for the Function Register.
/// </summary>
internal static class FunctionRegister
internal static class Is31fl3730_FunctionRegister
{
/// <summary>
/// Address for Configuration Register.
Expand Down
17 changes: 9 additions & 8 deletions src/devices/Is31fl3730/Is31fl3730.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Device.Gpio;
using System.Device.I2c;
using Iot.Device.Display.Internal;
using static System.Linq.Enumerable;

namespace Iot.Device.Display
Expand All @@ -19,7 +20,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_addresses = new byte[] { FunctionRegister.Matrix1, FunctionRegister.Matrix2 };
private readonly byte[] _matrix_addresses = new byte[] { Is31fl3730_FunctionRegister.Matrix1, Is31fl3730_FunctionRegister.Matrix2 };
private readonly List<byte[]> _buffers = new List<byte[]>
{
new byte[8],
Expand Down Expand Up @@ -79,12 +80,12 @@ More detailed information about the structure of each pair follows (further down
// Set high bit for the 128th item
// Set high bit low for the remaining 127 items
// And then set lower bits as appropriate, to represent 0-127
public void UpdateBrightness(byte value) => Write(FunctionRegister.Pwm, value);
public void UpdateBrightness(byte value) => Write(Is31fl3730_FunctionRegister.Pwm, value);

/// <summary>
/// Update current setting for each row output of LED matrix (default value is 40 mA).
/// </summary>
public void UpdateCurrent(Current value) => Write(FunctionRegister.LightingEffect, (byte)value);
public void UpdateCurrent(Current value) => Write(Is31fl3730_FunctionRegister.LightingEffect, (byte)value);

/// <summary>
/// Update configuration register, which controls shutdown, matrix, and display modes.
Expand All @@ -95,7 +96,7 @@ public void UpdateConfiguration(ShowdownMode shutdown, MatrixMode matrix, Displa
configuration |= (byte)shutdown;
configuration |= (byte)matrix;
configuration |= (byte)display;
Write(FunctionRegister.Configuration, configuration);
Write(Is31fl3730_FunctionRegister.Configuration, configuration);

// Set number of and which supported matrices (either or both)
if (display is DisplayMode.MatrixOneOnly)
Expand All @@ -118,7 +119,7 @@ public void UpdateConfiguration(ShowdownMode shutdown, MatrixMode matrix, Displa
/// <summary>
/// Resets all registers to default value.
/// </summary>
public void ResetRegisters() => Write(FunctionRegister.Reset, MatrixValues.EightBitValue);
public void ResetRegisters() => Write(Is31fl3730_FunctionRegister.Reset, Is31fl3730_MatrixValues.EightBitValue);

/// <summary>
/// Write LED for matrix.
Expand Down Expand Up @@ -256,8 +257,8 @@ public void WriteDecimalPoint(int matrix, PinValue value)
{
CheckMatrixIndex(matrix);
byte[] buffer = _buffers[matrix];
int row = matrix is 0 ? MatrixValues.MatrixOneDecimalRow : MatrixValues.MatrixTwoDecimalRow;
byte mask = matrix is 0 ? MatrixValues.MatrixOneDecimalMask : MatrixValues.MatrixTwoDecimalMask;
int row = matrix is 0 ? Is31fl3730_MatrixValues.MatrixOneDecimalRow : Is31fl3730_MatrixValues.MatrixTwoDecimalRow;
byte mask = matrix is 0 ? Is31fl3730_MatrixValues.MatrixOneDecimalMask : Is31fl3730_MatrixValues.MatrixTwoDecimalMask;
buffer[row] = UpdateByte(buffer[row], mask, value);
AutoFlush(matrix);
}
Expand Down Expand Up @@ -340,7 +341,7 @@ 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 WriteUpdateRegister() => Write(Is31fl3730_FunctionRegister.UpdateColumn, Is31fl3730_MatrixValues.EightBitValue);

private void AutoFlush(int matrix)
{
Expand Down
4 changes: 2 additions & 2 deletions src/devices/Is31fl3730/MatrixValues.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Iot.Device.Display
namespace Iot.Device.Display.Internal
{
/// <summary>
/// IS31FL3730 matrix driver values.
/// </summary>
internal static class MatrixValues
internal static class Is31fl3730_MatrixValues
{
/// <summary>
/// Arbitrary 8-bit value to write to Update Column Register, as required by datasheet.
Expand Down

0 comments on commit 0921724

Please sign in to comment.