Skip to content

Commit e80a385

Browse files
committed
avoid instantiating an unused configured or default driver
1 parent dcb7dba commit e80a385

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Raspberry.IO.GeneralPurpose/GpioConnectionSettings.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,23 @@ public class GpioConnectionSettings
2727
/// <summary>
2828
/// Initializes a new instance of the <see cref="GpioConnectionSettings"/> class.
2929
/// </summary>
30-
public GpioConnectionSettings()
30+
/// <param name="driver">The driver to use.</param>
31+
public GpioConnectionSettings(IGpioConnectionDriver driver)
3132
{
32-
Driver = DefaultDriver;
33+
Driver = driver;
3334
BlinkDuration = DefaultBlinkDuration;
3435
PollInterval = DefaultPollInterval;
3536
Opened = true;
3637
}
3738

39+
/// <summary>
40+
/// Initializes a new instance of the <see cref="GpioConnectionSettings"/> class
41+
/// using the configured or default driver.
42+
/// </summary>
43+
public GpioConnectionSettings()
44+
: this(DefaultDriver)
45+
{}
46+
3847
#endregion
3948

4049
#region Constants

Tests/Test.Gpio.Chaser/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void Main(string[] args)
8383
});
8484

8585
// Create connection
86-
var settings = new GpioConnectionSettings {Driver = driver};
86+
var settings = new GpioConnectionSettings (driver);
8787

8888
using (var connection = new GpioConnection(settings, leds))
8989
{

0 commit comments

Comments
 (0)