Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianstevens committed Mar 28, 2024
1 parent 56446c0 commit c5e6452
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Source/C420R/Driver/C420R.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Meadow.Foundation.mikroBUS.Sensors
/// </summary>
public class C420R : PollingSensorBase<Current>
{
private IAnalogInputPort _adc;
private IAnalogInputPort analogInputPort = default!;

/// <summary>
/// Reference voltage (2.048V)
Expand Down Expand Up @@ -54,13 +54,13 @@ public C420R(ISpiBus spiBus,

private void InitializeMcp(int sampleCount = 1, TimeSpan? sampleInterval = null)
{
_adc = mcp3201.CreateAnalogInputPort(sampleCount, sampleInterval ?? TimeSpan.FromSeconds(5), ReferenceVoltage);
analogInputPort = mcp3201.CreateAnalogInputPort(sampleCount, sampleInterval ?? TimeSpan.FromSeconds(5), ReferenceVoltage);
}

/// <inheritdoc/>
protected override async Task<Current> ReadSensor()
{
var volts = await _adc.Read();
var volts = await analogInputPort.Read();
return new Current(volts.Volts / 100d);
}
}
Expand Down
3 changes: 3 additions & 0 deletions Source/C420T/Driver/C420T.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class C420T : IDisposable
private readonly IAnalogOutputPort dac;
private readonly bool portCreated;

/// <summary>
/// Gets a value indicating whether the object has been disposed
/// </summary>
public bool IsDisposed { get; private set; }

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Source/C8800Retro/Driver/C8800Retro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class C8800Retro : As1115
/// <param name="i2cBus">The I2C bus</param>
/// <param name="buttonInterruptPin">The interrupt pin</param>
/// <param name="address">The I2C address</param>
public C8800Retro(II2cBus i2cBus, IPin buttonInterruptPin, byte address = 0)
public C8800Retro(II2cBus i2cBus, IPin buttonInterruptPin, byte address = 0)
: base(i2cBus, buttonInterruptPin, address)
{ }

Expand All @@ -29,7 +29,7 @@ public IButton GetButton(ButtonColumn column, ButtonRow row)
{
KeyScanButtonType buttonType = KeyScanButtonType.None;

if(row == ButtonRow.A)
if (row == ButtonRow.A)
{
buttonType = column switch
{
Expand Down Expand Up @@ -74,7 +74,7 @@ public IButton GetButton(ButtonColumn column, ButtonRow row)
};
}

return KeyScanButtons[buttonType];
return KeyScanButtons![buttonType];
}
}
}
2 changes: 1 addition & 1 deletion Source/CACCurrent/Driver/CACCurrent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CACCurrent : CurrentTransducer
/// </summary>
public Voltage ReferenceVoltage { get; protected set; } = new Voltage(2.048, Voltage.UnitType.Volts);

readonly Mcp3201 mcp3201;
readonly Mcp3201 mcp3201 = default!;

/// <summary>
/// Creates a new CACCurrent object using the SPI bus for readings
Expand Down
4 changes: 2 additions & 2 deletions Source/CGNSS10/Driver/CGNSS10.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ public class CGNSS10 : NeoM8
/// <summary>
/// Creates a new CGNSS10 object
/// </summary>
public CGNSS10(ISpiBus spiBus, IDigitalOutputPort chipSelectPort, IDigitalOutputPort resetPort = null)
public CGNSS10(ISpiBus spiBus, IDigitalOutputPort chipSelectPort, IDigitalOutputPort? resetPort = null)
: base(spiBus, chipSelectPort, resetPort)
{ }

/// <summary>
/// Creates a new CGNSS10 object
/// </summary>
public CGNSS10(ISpiBus spiBus, IPin chipSelectPin, IPin resetPin = null)
public CGNSS10(ISpiBus spiBus, IPin chipSelectPin, IPin? resetPin = null)
: base(spiBus, chipSelectPin, resetPin)
{ }
}
Expand Down
4 changes: 2 additions & 2 deletions Source/CGNSS5/Driver/CGNSS5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ public class CGNSS5 : NeoM8
/// <summary>
/// Creates a new CGNSS5 object using serial
/// </summary>
public CGNSS5(IMeadowDevice device, SerialPortName serialPortName, IPin resetPin, IPin ppsPin = null)
public CGNSS5(IMeadowDevice device, SerialPortName serialPortName, IPin? resetPin, IPin? ppsPin = null)
: base(device, serialPortName, resetPin, ppsPin)
{ }

/// <summary>
/// Creates a new CGNSS5 object using I2C
/// </summary>
public CGNSS5(II2cBus i2cBus, IPin resetPin, IPin ppsPin = null)
public CGNSS5(II2cBus i2cBus, IPin? resetPin, IPin? ppsPin = null)
: base(i2cBus, (byte)Addresses.Default, resetPin: resetPin, ppsPin: ppsPin)
{ }
}
Expand Down
2 changes: 1 addition & 1 deletion Source/CLEM/Driver/CLEM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CLEM : CurrentTransducer
/// </summary>
public Voltage ReferenceVoltage { get; protected set; } = new Voltage(2.048, Voltage.UnitType.Volts);

readonly Mcp3201 mcp3201;
readonly Mcp3201 mcp3201 = default!;

/// <summary>
/// Creates a new CLEM object
Expand Down

0 comments on commit c5e6452

Please sign in to comment.