Skip to content

Commit 57f509d

Browse files
committed
Remove various usages of PinNumberingScheme
1 parent e3d5d57 commit 57f509d

File tree

20 files changed

+43
-106
lines changed

20 files changed

+43
-106
lines changed

src/devices/Arduino/ArduinoAnalogController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ internal class ArduinoAnalogController : AnalogController
1919
private readonly IReadOnlyList<SupportedPinConfiguration> _supportedPinConfigurations;
2020

2121
public ArduinoAnalogController(ArduinoBoard board,
22-
IReadOnlyList<SupportedPinConfiguration> supportedPinConfigurations, PinNumberingScheme scheme)
23-
: base(scheme)
22+
IReadOnlyList<SupportedPinConfiguration> supportedPinConfigurations)
23+
: base()
2424
{
2525
_board = board ?? throw new ArgumentNullException(nameof(board));
2626
_supportedPinConfigurations = supportedPinConfigurations ?? throw new ArgumentNullException(nameof(supportedPinConfigurations));

src/devices/Arduino/ArduinoBoard.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ public override GpioController CreateGpioController()
725725
throw new ObjectDisposedException(nameof(_firmata));
726726
}
727727

728-
return new GpioController(PinNumberingScheme.Logical, new ArduinoGpioControllerDriver(_firmata, _supportedPinConfigurations));
728+
return new GpioController(new ArduinoGpioControllerDriver(_firmata, _supportedPinConfigurations));
729729
}
730730

731731
/// <inheritdoc />
@@ -841,7 +841,7 @@ public virtual AnalogController CreateAnalogController(int chip)
841841
{
842842
Initialize();
843843

844-
return new ArduinoAnalogController(this, SupportedPinConfigurations, PinNumberingScheme.Logical);
844+
return new ArduinoAnalogController(this, SupportedPinConfigurations);
845845
}
846846

847847
/// <summary>

src/devices/Board/Board.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,6 @@ protected Board()
6767
/// </summary>
6868
protected bool Disposed => _disposed;
6969

70-
/// <summary>
71-
/// The default pin numbering scheme for this board.
72-
/// </summary>
73-
public PinNumberingScheme DefaultPinNumberingScheme
74-
{
75-
get
76-
{
77-
// This is currently hardcoded to logical numbering, since it makes the API simpler and there are few really useful cases where you would need it otherwise.
78-
return PinNumberingScheme.Logical;
79-
}
80-
}
81-
8270
/// <summary>
8371
/// Reserves a pin for a specific usage. This is done automatically if a known interface (i.e. GpioController) is
8472
/// used to open the pin, but may be used to block a pin explicitly, i.e. for UART.
@@ -507,9 +495,8 @@ internal bool RemoveBus(I2cBusManager bus)
507495
/// <param name="connectionSettings">Connection parameters (contains bus number and CS pin number)</param>
508496
/// <param name="pinAssignment">The set of pins to use for SPI. The parameter can be null if the hardware requires a fixed mapping from
509497
/// pins to SPI for the given bus.</param>
510-
/// <param name="pinNumberingScheme">The numbering scheme in which the <paramref name="pinAssignment"/> is given</param>
511498
/// <returns>An SPI device instance</returns>
512-
public SpiDevice CreateSpiDevice(SpiConnectionSettings connectionSettings, int[] pinAssignment, PinNumberingScheme pinNumberingScheme)
499+
public SpiDevice CreateSpiDevice(SpiConnectionSettings connectionSettings, int[] pinAssignment)
513500
{
514501
Initialize();
515502

@@ -539,7 +526,7 @@ public SpiDevice CreateSpiDevice(SpiConnectionSettings connectionSettings)
539526
// Returns logical pin numbers for the selected bus (or an exception if using a bus number > 1, because that
540527
// requires specifying the pins)
541528
int[] pinAssignment = GetDefaultPinAssignmentForSpi(connectionSettings);
542-
return CreateSpiDevice(connectionSettings, pinAssignment, PinNumberingScheme.Logical);
529+
return CreateSpiDevice(connectionSettings, pinAssignment);
543530
}
544531

545532
/// <summary>
@@ -560,10 +547,9 @@ public SpiDevice CreateSpiDevice(SpiConnectionSettings connectionSettings)
560547
/// <param name="frequency">Initial frequency</param>
561548
/// <param name="dutyCyclePercentage">Initial duty cycle</param>
562549
/// <param name="pin">The pin number for the pwm channel. Used if not hardwired (i.e. on the Raspi, it is possible to use different pins for the same PWM channel)</param>
563-
/// <param name="pinNumberingScheme">The pin numbering scheme for the pin</param>
564550
/// <returns>A pwm channel instance</returns>
565551
public PwmChannel CreatePwmChannel(int chip, int channel, int frequency, double dutyCyclePercentage,
566-
int pin, PinNumberingScheme pinNumberingScheme)
552+
int pin)
567553
{
568554
Initialize();
569555
return AddManager(new PwmChannelManager(this, pin, chip, channel, frequency, dutyCyclePercentage, CreateSimplePwmChannel));
@@ -585,7 +571,7 @@ public PwmChannel CreatePwmChannel(
585571
{
586572
Initialize();
587573
int pin = GetDefaultPinAssignmentForPwm(chip, channel);
588-
return CreatePwmChannel(chip, channel, frequency, dutyCyclePercentage, pin, PinNumberingScheme.Logical);
574+
return CreatePwmChannel(chip, channel, frequency, dutyCyclePercentage, pin);
589575
}
590576

591577
/// <summary>

src/devices/Board/RaspberryPiBoard.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,10 @@ public override int[] GetDefaultPinAssignmentForSpi(SpiConnectionSettings connec
374374
/// </summary>
375375
/// <param name="pinNumber">Pin number to use</param>
376376
/// <param name="usage">Requested usage</param>
377-
/// <param name="pinNumberingScheme">Pin numbering scheme for the pin provided (logical or physical)</param>
378377
/// <param name="bus">Optional bus argument, for SPI and I2C pins</param>
379378
/// <returns>
380379
/// A member of <see cref="RaspberryPi3Driver.AltMode"/> describing the mode the pin is in.</returns>
381-
private RaspberryPi3Driver.AltMode GetHardwareModeForPinUsage(int pinNumber, PinUsage usage, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, int bus = 0)
380+
private RaspberryPi3Driver.AltMode GetHardwareModeForPinUsage(int pinNumber, PinUsage usage, int bus = 0)
382381
{
383382
if (pinNumber >= PinCount)
384383
{
@@ -607,19 +606,19 @@ public override PinUsage DetermineCurrentPinUsage(int pinNumber)
607606

608607
// Do some heuristics: If the given pin number can be used for I2C with the same Alt mode, we can assume that's what it
609608
// it set to.
610-
var possibleAltMode = GetHardwareModeForPinUsage(pinNumber, PinUsage.I2c, DefaultPinNumberingScheme);
609+
var possibleAltMode = GetHardwareModeForPinUsage(pinNumber, PinUsage.I2c);
611610
if (possibleAltMode == pinMode)
612611
{
613612
return PinUsage.I2c;
614613
}
615614

616-
possibleAltMode = GetHardwareModeForPinUsage(pinNumber, PinUsage.Spi, DefaultPinNumberingScheme);
615+
possibleAltMode = GetHardwareModeForPinUsage(pinNumber, PinUsage.Spi);
617616
if (possibleAltMode == pinMode)
618617
{
619618
return PinUsage.Spi;
620619
}
621620

622-
possibleAltMode = GetHardwareModeForPinUsage(pinNumber, PinUsage.Pwm, DefaultPinNumberingScheme);
621+
possibleAltMode = GetHardwareModeForPinUsage(pinNumber, PinUsage.Pwm);
623622
if (possibleAltMode == pinMode)
624623
{
625624
return PinUsage.Pwm;

src/devices/Board/tests/BoardTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public void ThereIsAlwaysAMatchingBoard()
3636
Assert.NotNull(board);
3737
var property = board.GetType().GetProperty("Initialized", BindingFlags.Instance | BindingFlags.NonPublic)!;
3838
Assert.True((bool)property.GetValue(board)!);
39-
Assert.Equal(PinNumberingScheme.Logical, board.DefaultPinNumberingScheme);
4039
board.Dispose();
4140
}
4241

src/devices/Common/System/Device/Analog/AnalogController.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ public abstract class AnalogController : IDisposable
1919
/// <summary>
2020
/// Initializes a new instance of the <see cref="GpioController"/> class that will use the specified numbering scheme and driver.
2121
/// </summary>
22-
/// <param name="numberingScheme">The numbering scheme used to represent pins provided by the controller.</param>
23-
protected AnalogController(PinNumberingScheme numberingScheme)
22+
protected AnalogController()
2423
{
25-
NumberingScheme = numberingScheme;
2624
_openPins = new List<AnalogInputPin>();
2725
}
2826

src/devices/Dhtxx/Devices/Dht11.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ public class Dht11 : DhtBase
1818
/// Create a DHT11 sensor
1919
/// </summary>
2020
/// <param name="pin">The pin number (GPIO number)</param>
21-
/// <param name="pinNumberingScheme">The GPIO pin numbering scheme</param>
2221
/// <param name="gpioController"><see cref="GpioController"/> related with operations on pins</param>
2322
/// <param name="shouldDispose">True to dispose the Gpio Controller</param>
24-
public Dht11(int pin, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true)
25-
: base(pin, pinNumberingScheme, gpioController, shouldDispose)
23+
public Dht11(int pin, GpioController? gpioController = null, bool shouldDispose = true)
24+
: base(pin, gpioController, shouldDispose)
2625
{
2726
}
2827

src/devices/Dhtxx/Devices/Dht12.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ public class Dht12 : DhtBase
2424
/// Create a DHT12 sensor
2525
/// </summary>
2626
/// <param name="pin">The pin number (GPIO number)</param>
27-
/// <param name="pinNumberingScheme">The GPIO pin numbering scheme</param>
2827
/// <param name="gpioController"><see cref="GpioController"/> related with operations on pins</param>
2928
/// <param name="shouldDispose">True to dispose the Gpio Controller</param>
30-
public Dht12(int pin, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true)
31-
: base(pin, pinNumberingScheme, gpioController, shouldDispose)
29+
public Dht12(int pin, GpioController? gpioController = null, bool shouldDispose = true)
30+
: base(pin, gpioController, shouldDispose)
3231
{
3332
}
3433

src/devices/Dhtxx/Devices/Dht21.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ public class Dht21 : DhtBase
1818
/// Create a DHT22 sensor
1919
/// </summary>
2020
/// <param name="pin">The pin number (GPIO number)</param>
21-
/// <param name="pinNumberingScheme">The GPIO pin numbering scheme</param>
2221
/// <param name="gpioController"><see cref="GpioController"/> related with operations on pins</param>
2322
/// <param name="shouldDispose">True to dispose the Gpio Controller</param>
24-
public Dht21(int pin, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true)
25-
: base(pin, pinNumberingScheme, gpioController, shouldDispose)
23+
public Dht21(int pin, GpioController? gpioController = null, bool shouldDispose = true)
24+
: base(pin, gpioController, shouldDispose)
2625
{
2726
}
2827

src/devices/Dhtxx/Devices/Dht22.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ public class Dht22 : DhtBase
1818
/// Create a DHT22 sensor
1919
/// </summary>
2020
/// <param name="pin">The pin number (GPIO number)</param>
21-
/// <param name="pinNumberingScheme">The GPIO pin numbering scheme</param>
2221
/// <param name="gpioController"><see cref="GpioController"/> related with operations on pins</param>
2322
/// <param name="shouldDispose">True to dispose the Gpio Controller</param>
24-
public Dht22(int pin, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true)
25-
: base(pin, pinNumberingScheme, gpioController, shouldDispose)
23+
public Dht22(int pin, GpioController? gpioController = null, bool shouldDispose = true)
24+
: base(pin, gpioController, shouldDispose)
2625
{
2726
}
2827

0 commit comments

Comments
 (0)