Skip to content

Commit

Permalink
Merge pull request #823 from WildernessLabs/cleanup
Browse files Browse the repository at this point in the history
More warning fixes
  • Loading branch information
jorgedevs authored Oct 30, 2023
2 parents f9a5b56 + df97c25 commit 18017a0
Show file tree
Hide file tree
Showing 39 changed files with 132 additions and 132 deletions.
54 changes: 27 additions & 27 deletions Source/Meadow.Foundation.Peripherals/RTCs.Ds323x/Driver/Ds323x.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,14 @@ protected Ds323x(I2cCommunications i2cComms, IPin? interruptPin)
/// <summary>
/// Create a new Ds323x object
/// </summary>
protected Ds323x(I2cCommunications i2cComms, IDigitalInterruptPort interruptPort)
protected Ds323x(I2cCommunications i2cComms, IDigitalInterruptPort? interruptPort)
{
this.i2cComms = i2cComms;

Initialize(interruptPort);
if (interruptPort != null)
{
Initialize(interruptPort);
}
}

/// <summary>
Expand All @@ -107,36 +110,33 @@ public void Dispose()

private void Initialize(IDigitalInterruptPort interruptPort)
{
if (interruptPort != null)
switch (interruptPort.InterruptMode)
{
switch (interruptPort.InterruptMode)
{
case InterruptMode.EdgeFalling:
case InterruptMode.EdgeBoth:
// we need a rising edge, so all good;
break;
default:
throw new DeviceConfigurationException("RTC alarms require a falling-edge enabled interrupt port");
}
case InterruptMode.EdgeFalling:
case InterruptMode.EdgeBoth:
// we need a rising edge, so all good;
break;
default:
throw new DeviceConfigurationException("RTC alarms require a falling-edge enabled interrupt port");
}

InterruptPort = interruptPort;
InterruptPort.Changed += (s, cr) =>
InterruptPort = interruptPort;
InterruptPort.Changed += (s, cr) =>
{
//Alarm interrupt has been raised, work out which one and raise the necessary event.
if ((alarm1Delegate != null) || (alarm2Delegate != null))
{
//Alarm interrupt has been raised, work out which one and raise the necessary event.
if ((alarm1Delegate != null) || (alarm2Delegate != null))
var alarm = WhichAlarm;
if (((alarm == Alarm.Alarm1Raised) || (alarm == Alarm.BothAlarmsRaised)) && (alarm1Delegate != null))
{
var alarm = WhichAlarm;
if (((alarm == Alarm.Alarm1Raised) || (alarm == Alarm.BothAlarmsRaised)) && (alarm1Delegate != null))
{
alarm1Delegate(this);
}
if (((alarm == Alarm.Alarm2Raised) || (alarm == Alarm.BothAlarmsRaised)) && (alarm2Delegate != null))
{
alarm2Delegate(this);
}
alarm1Delegate(this);
}
};
}
if (((alarm == Alarm.Alarm2Raised) || (alarm == Alarm.BothAlarmsRaised)) && (alarm2Delegate != null))
{
alarm2Delegate(this);
}
}
};
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,6 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Pressure? Pressure,
}

async Task<Pressure> ISensor<Pressure>.Read()
=> (await ReadSensor()).Pressure.Value;
=> (await ReadSensor()).Pressure!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,12 @@ public override void StartUpdating(TimeSpan? updateInterval = null)
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<RelativeHumidity> ISensor<RelativeHumidity>.Read()
=> (await Read()).Humidity.Value;
=> (await Read()).Humidity!.Value;

async Task<Pressure> ISensor<Pressure>.Read()
=> (await Read()).Pressure.Value;
=> (await Read()).Pressure!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,12 @@ byte CalculateHeaterDuration(TimeSpan duration)
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<RelativeHumidity> ISensor<RelativeHumidity>.Read()
=> (await Read()).Humidity.Value;
=> (await Read()).Humidity!.Value;

async Task<Pressure> ISensor<Pressure>.Read()
=> (await Read()).Pressure.Value;
=> (await Read()).Pressure!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ private short ReadShort(byte address)
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<Pressure> ISensor<Pressure>.Read()
=> (await Read()).Pressure.Value;
=> (await Read()).Pressure!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ private short ReadShort(byte address)
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<Pressure> ISensor<Pressure>.Read()
=> (await Read()).Pressure.Value;
=> (await Read()).Pressure!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,6 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Concentration? Co2,
}

async Task<Concentration> ISensor<Concentration>.Read()
=> (await Read()).Voc.Value;
=> (await Read()).Voc!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Units.Temperature? T
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<RelativeHumidity> ISensor<RelativeHumidity>.Read()
=> (await Read()).Humidity.Value;
=> (await Read()).Humidity!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Units.RelativeHumidi
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<Units.RelativeHumidity> ISensor<Units.RelativeHumidity>.Read()
=> (await Read()).Humidity.Value;
=> (await Read()).Humidity!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Units.Temperature? T
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<RelativeHumidity> ISensor<RelativeHumidity>.Read()
=> (await Read()).Humidity.Value;
=> (await Read()).Humidity!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Units.Temperature? T
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<RelativeHumidity> ISensor<RelativeHumidity>.Read()
=> (await Read()).Humidity.Value;
=> (await Read()).Humidity!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ public void Reset()
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<Pressure> ISensor<Pressure>.Read()
=> (await Read()).Pressure.Value;
=> (await Read()).Pressure!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ int ReadPressure()
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<Pressure> ISensor<Pressure>.Read()
=> (await Read()).Pressure.Value;
=> (await Read()).Pressure!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Units.Temperature? T
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<RelativeHumidity> ISensor<RelativeHumidity>.Read()
=> (await Read()).Humidity.Value;
=> (await Read()).Humidity!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ protected int GetDelayForPrecision(Precision precision)
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<RelativeHumidity> ISensor<RelativeHumidity>.Read()
=> (await Read()).Humidity.Value;
=> (await Read()).Humidity!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ void SetResolution(SensorResolution resolution)
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<RelativeHumidity> ISensor<RelativeHumidity>.Read()
=> (await Read()).Humidity.Value;
=> (await Read()).Humidity!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Units.Temperature? T
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<RelativeHumidity> ISensor<RelativeHumidity>.Read()
=> (await Read()).Humidity.Value;
=> (await Read()).Humidity!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public bool IsPhotoAvailable()
/// Retrieve the image data from the camera
/// </summary>
/// <returns>The image data as a jpeg in a MemoryStream</returns>
public Task<MemoryStream> GetPhotoStream()
public Task<MemoryStream?> GetPhotoStream()
{
return Task.Run(() =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public void MeasureDistance()
/// Returns the current distance/range
/// </summary>
/// <returns>The distance in the specified Units. Default mm. Returns -1 if the shutdown pin is used and is off</returns>
protected override async Task<Length?> ReadSensor()
protected override async Task<Length> ReadSensor()
{
//Resolver.Log.Info("ReadSensor");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected override Task<Concentration> ReadSensor()
WriteBuffer.Span[0] = ASG_DATA_MSB;
WriteBuffer.Span[1] = ASG_DATA_LSB;

BusComms.Exchange(WriteBuffer.Span[0..1], ReadBuffer.Span);
BusComms!.Exchange(WriteBuffer.Span[0..1], ReadBuffer.Span);

var value = ReadBuffer.Span[0] << 8 | ReadBuffer.Span[1];

Expand All @@ -75,7 +75,7 @@ public byte GetVersion()
WriteBuffer.Span[0] = ASG_VERSION_MSB;
WriteBuffer.Span[1] = ASG_VERSION_LSB;

BusComms.Exchange(WriteBuffer.Span[0..1], ReadBuffer.Span[0..1]);
BusComms!.Exchange(WriteBuffer.Span[0..1], ReadBuffer.Span[0..1]);

// CRC check
if (!CheckCrc8(ReadBuffer[..1].ToArray(), 1, ReadBuffer.Span[1]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,6 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Concentration? CO2Co
}

async Task<Concentration> ISensor<Concentration>.Read()
=> (await Read()).CO2Concentration.Value;
=> (await Read()).CO2Concentration!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ protected void RaiseChangedAndNotify(IChangeResult<(Concentration? Concentration
}

async Task<Units.Temperature> ISensor<Units.Temperature>.Read()
=> (await Read()).Temperature.Value;
=> (await Read()).Temperature!.Value;

async Task<RelativeHumidity> ISensor<RelativeHumidity>.Read()
=> (await Read()).Humidity.Value;
=> (await Read()).Humidity!.Value;

async Task<Concentration> ISensor<Concentration>.Read()
=> (await Read()).Concentration.Value;
=> (await Read()).Concentration!.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public DigitalJoystickPosition? DigitalPosition
/// <param name="i2cBus">the I2C bus</param>
/// <param name="address">the device I2C address</param>
/// <param name="interruptPort">port connected to the interrupt pin</param>
public As5013(II2cBus i2cBus, byte address = (byte)Addresses.Default, IDigitalInterruptPort interruptPort = null)
public As5013(II2cBus i2cBus, byte address = (byte)Addresses.Default, IDigitalInterruptPort? interruptPort = null)
{
i2cComms = new I2cCommunications(i2cBus, address);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial class BBQ10Keyboard : II2cPeripheral
/// I2C Communication bus used to communicate with the peripheral
/// </summary>
protected readonly II2cCommunications i2cComms;
private readonly IDigitalInterruptPort interruptPort;
private readonly IDigitalInterruptPort? interruptPort;

/// <summary>
/// Raised when a key press is detected
Expand Down Expand Up @@ -53,7 +53,7 @@ public byte BackLight2
/// <param name="i2cBus">The I2C bus</param>
/// <param name="interruptPin">The interrupt pin</param>
/// <param name="address">The I2C address</param>
public BBQ10Keyboard(II2cBus i2cBus, IPin interruptPin = null, byte address = (byte)Addresses.Default)
public BBQ10Keyboard(II2cBus i2cBus, IPin? interruptPin = null, byte address = (byte)Addresses.Default)
{
i2cComms = new I2cCommunications(i2cBus, address);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public int RefreshPeriod
/// <summary>
/// Create a new MPR121 keypad object.
/// </summary>
public Mpr121(II2cBus i2cBus, byte address = (byte)Addresses.Default, int refreshPeriod = -1, Mpr121Configuration configuration = null)
public Mpr121(II2cBus i2cBus, byte address = (byte)Addresses.Default, int refreshPeriod = -1, Mpr121Configuration? configuration = null)
{
this.refreshPeriod = refreshPeriod;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public override void Update()
if (useHighResolutionMode)
{
i2cComms.WriteRegister(0, 0);
i2cComms.Read(readBuffer[..8]);
i2cComms.Read(ReadBuffer[..8]);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public override void Update()
if (useHighResolutionMode)
{
i2cComms.WriteRegister(0, 0);
i2cComms.Read(readBuffer[..8]);
i2cComms.Read(ReadBuffer[..8]);
}
else
{
Expand Down
Loading

0 comments on commit 18017a0

Please sign in to comment.