Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/devices/Ads1115/Ads1115.cs
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,9 @@ public void Dispose()
if (_shouldDispose)
{
_gpioController?.Dispose();
_gpioController = null;
}

_gpioController = null;
}
}
}
3 changes: 2 additions & 1 deletion src/devices/Ak8963/Ak8963.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ public void Dispose()
if (_shouldDispose)
{
_i2cDevice?.Dispose();
_i2cDevice = null!;
}

_i2cDevice = null!;
}
}
}
3 changes: 2 additions & 1 deletion src/devices/Blinkt/Blinkt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public void Dispose()
if (_shouldDispose)
{
_gpioController?.Dispose();
_gpioController = null!;
}

_gpioController = null!;
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/devices/Bmm150/Bmm150.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ public void Dispose()
if (_shouldDispose)
{
_i2cDevice?.Dispose();
_i2cDevice = null!;
}

_i2cDevice = null!;
}
}
}
3 changes: 2 additions & 1 deletion src/devices/Bno055/Bno055Sensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,9 @@ public void Dispose()
if (_shouldDispose)
{
_i2cDevice?.Dispose();
_i2cDevice = null!;
}

_i2cDevice = null!;
}

private void WriteReg(Registers reg, byte param) => _i2cDevice.Write(new byte[] { (byte)reg, param });
Expand Down
3 changes: 2 additions & 1 deletion src/devices/Button/GpioButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,13 @@ protected override void Dispose(bool disposing)
if (_shouldDispose)
{
_gpioController?.Dispose();
_gpioController = null!;
}
else
{
_gpioController.ClosePin(_buttonPin);
}

_gpioController = null!;
}

base.Dispose(disposing);
Expand Down
3 changes: 2 additions & 1 deletion src/devices/Ccs811/Ccs811Sensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null;
}
else if (_controller is object)
{
Expand All @@ -479,6 +478,8 @@ public void Dispose()
_controller.ClosePin(_pinWake);
}
}

_controller = null;
}

#region I2C operations
Expand Down
3 changes: 2 additions & 1 deletion src/devices/CharacterLcd/LcdInterface.Gpio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,10 @@ protected override void Dispose(bool disposing)
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null!;
}

_controller = null!;

base.Dispose(disposing);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/devices/Charlieplex/CharlieplexSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ public void Dispose()
if (_shouldDispose)
{
_gpioController?.Dispose();
_gpioController = null!;
}

_gpioController = null!;
}

// IOutputSegment Implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null!;
}

_controller = null!;
}
}
}
3 changes: 2 additions & 1 deletion src/devices/DCMotor/DCMotor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ public virtual void Dispose()
if (_shouldDispose)
{
Controller?.Dispose();
Controller = null!;
}

Controller = null!;
}
}
}
2 changes: 1 addition & 1 deletion src/devices/Dhtxx/DhtBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,13 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null;
}
else if (_controller?.IsPinOpen(_pin) ?? false)
{
_controller.ClosePin(_pin);
}

_controller = null;
_i2cDevice?.Dispose();
_i2cDevice = null;
}
Expand Down
3 changes: 2 additions & 1 deletion src/devices/ExplorerHat/ExplorerHat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null!;
}

_controller = null!;
}
}
}
3 changes: 2 additions & 1 deletion src/devices/ExplorerHat/Led.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null!;
}

_controller = null!;
}
}
}
3 changes: 2 additions & 1 deletion src/devices/ExplorerHat/Lights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null!;
}

_controller = null!;
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/devices/ExplorerHat/Motors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null!;
}

_controller = null!;
}
}
}
3 changes: 2 additions & 1 deletion src/devices/GrovePi/GrovePi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public void Dispose()
if (_shouldDispose)
{
_i2cDevice?.Dispose();
_i2cDevice = null!;
}

_i2cDevice = null!;
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/devices/Hcsr04/Hcsr04.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null!;
}

_controller = null!;
}
}
}
3 changes: 2 additions & 1 deletion src/devices/Hcsr501/Hcsr501.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null!;
}

_controller = null!;
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/devices/Ht1632/Ht1632.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null;
}

_controller = null;
}

private void SetupPins()
Expand Down
3 changes: 2 additions & 1 deletion src/devices/KeyMatrix/KeyMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ public void Dispose()
if (_shouldDispose)
{
_gpioController?.Dispose();
_gpioController = null;
}
else
{
Expand All @@ -225,6 +224,8 @@ public void Dispose()
ClosePins();
}
}

_gpioController = null;
}

private void OpenPins()
Expand Down
3 changes: 2 additions & 1 deletion src/devices/LidarLiteV3/LidarLiteV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,10 @@ public void Dispose()
if (_shouldDispose)
{
_gpioController?.Dispose();
_gpioController = null;
}

_gpioController = null;

_i2cDevice?.Dispose();
_i2cDevice = null!;
}
Expand Down
3 changes: 2 additions & 1 deletion src/devices/LiquidLevel/LiquidLevelSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null!;
}

_controller = null!;
}
}
}
5 changes: 3 additions & 2 deletions src/devices/Mcp23xxx/Mcp23xxx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,14 @@ protected override void Dispose(bool disposing)
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null;

_pinValues.Clear();
_bus?.Dispose();
_bus = null!;
}

_controller = null;
_bus = null!;

base.Dispose(disposing);
}

Expand Down
3 changes: 2 additions & 1 deletion src/devices/Mcp25xxx/Mcp25xxx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,10 @@ public void Dispose()
if (_shouldDispose)
{
_gpioController?.Dispose();
_gpioController = null;
}

_gpioController = null;

_spiDevice?.Dispose();
_spiDevice = null!;
}
Expand Down
3 changes: 2 additions & 1 deletion src/devices/Mfrc522/Mfrc522.cs
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,9 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null;
}

_controller = null;
}

/// <inheritdoc/>
Expand Down
3 changes: 2 additions & 1 deletion src/devices/Mhz19b/Mhz19b.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,10 @@ public void Dispose()
if (_shouldDispose)
{
_serialPortStream?.Dispose();
_serialPortStream = null!;
}

_serialPortStream = null!;

if (_serialPort?.IsOpen ?? false)
{
_serialPort.Close();
Expand Down
3 changes: 2 additions & 1 deletion src/devices/Mpu6xxx9xxx/Mpu9250.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,9 @@ public Mpu9250(I2cDevice i2cDevice, bool shouldDispose = true, I2cDevice? i2CDev
if (_shouldDispose)
{
_i2cDevice?.Dispose();
_i2cDevice = null!;
}

_i2cDevice = null!;
}

}
Expand Down
3 changes: 2 additions & 1 deletion src/devices/Nrf24l01/Nrf24l01.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ public void Dispose()
if (_shouldDispose)
{
_gpio?.Dispose();
_gpio = null!;
}

_gpio = null!;
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/devices/Pca95x4/Pca95x4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null;
}

_controller = null;
}
}
}
2 changes: 1 addition & 1 deletion src/devices/Pcd8544/Pcd8544.cs
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,6 @@ protected override void Dispose(bool disposing)
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null!;
}
else
{
Expand All @@ -801,6 +800,7 @@ protected override void Dispose(bool disposing)
}
}

_controller = null!;
_spiDevice?.Dispose();
_spiDevice = null!;
_pwmBacklight?.Dispose();
Expand Down
3 changes: 2 additions & 1 deletion src/devices/PiJuice/PiJuice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ public void Dispose()
if (_shouldDispose)
{
_i2cDevice?.Dispose();
_i2cDevice = null!;
}

_i2cDevice = null!;
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/devices/ShiftRegister/ShiftRegister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,10 @@ public void Dispose()
if (_shouldDispose)
{
_controller?.Dispose();
_controller = null;
}

_controller = null;

// SPI devices are always disposed
_spiDevice?.Dispose();
_spiDevice = null;
Expand Down
Loading
Loading