Skip to content

Commit 39e8319

Browse files
committed
Remove all occurences of PinNumberingScheme from bindings
1 parent 57f509d commit 39e8319

File tree

40 files changed

+105
-138
lines changed

40 files changed

+105
-138
lines changed

samples/M5StackRemoteDisplay/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public static int Main(string[] args)
185185

186186
private static GpioController GetGpioControllerFromFt4222()
187187
{
188-
return new GpioController(PinNumberingScheme.Logical, new Ft4222Gpio());
188+
return new GpioController(new Ft4222Gpio());
189189
}
190190

191191
private static SpiDevice GetSpiFromFt4222()

samples/led-more-blinking-lights/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
volume = Volume.EnableVolume();
2424

2525
Console.WriteLine($"Let's blink some LEDs!");
26-
using GpioController controller = new GpioController(PinNumberingScheme.Logical);
26+
using GpioController controller = new GpioController();
2727
controller.OpenPin(ledOne, PinMode.Output);
2828
controller.OpenPin(ledTwo, PinMode.Output);
2929
controller.OpenPin(ledThree, PinMode.Output);

src/System.Device.Gpio.Tests/GpioControllerSoftwareTests.cs

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ public void Dispose()
2626
[Fact]
2727
public void PinCountReportedCorrectly()
2828
{
29-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
29+
var ctrl = new GpioController(_mockedGpioDriver.Object);
3030
Assert.Equal(28, ctrl.PinCount);
3131
}
3232

3333
[Fact]
3434
public void OpenTwiceGpioPinAndClosedTwiceThrows()
3535
{
36-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
36+
var ctrl = new GpioController(_mockedGpioDriver.Object);
3737
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
3838
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
3939
GpioPin gpioPin1 = ctrl.OpenPin(1);
@@ -50,7 +50,7 @@ public void WriteInputPinDoesNotThrow()
5050
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, It.IsAny<PinMode>())).Returns(true);
5151
_mockedGpioDriver.Setup(x => x.SetPinModeEx(1, It.IsAny<PinMode>()));
5252
_mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Input);
53-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
53+
var ctrl = new GpioController(_mockedGpioDriver.Object);
5454

5555
ctrl.OpenPin(1, PinMode.Input);
5656
ctrl.Write(1, PinValue.High);
@@ -64,7 +64,7 @@ public void GpioControllerCreateOpenClosePin()
6464
_mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Output);
6565
_mockedGpioDriver.Setup(x => x.WriteEx(1, PinValue.High));
6666
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
67-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
67+
var ctrl = new GpioController(_mockedGpioDriver.Object);
6868
Assert.NotNull(ctrl);
6969
ctrl.OpenPin(1, PinMode.Output);
7070
Assert.True(ctrl.IsPinOpen(1));
@@ -77,7 +77,7 @@ public void GpioControllerCreateOpenClosePin()
7777
public void IsPinModeSupported()
7878
{
7979
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Input)).Returns(true);
80-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
80+
var ctrl = new GpioController(_mockedGpioDriver.Object);
8181
Assert.NotNull(ctrl);
8282
Assert.True(ctrl.IsPinModeSupported(1, PinMode.Input));
8383
}
@@ -87,7 +87,7 @@ public void GetPinMode()
8787
{
8888
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
8989
_mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Output);
90-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
90+
var ctrl = new GpioController(_mockedGpioDriver.Object);
9191
Assert.NotNull(ctrl);
9292
// Not open
9393
Assert.Throws<InvalidOperationException>(() => ctrl.GetPinMode(1));
@@ -107,7 +107,7 @@ public void UsingBoardNumberingWorks()
107107
_mockedGpioDriver.Setup(x => x.WriteEx(1, PinValue.High));
108108
_mockedGpioDriver.Setup(x => x.ReadEx(1)).Returns(PinValue.High);
109109
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
110-
var ctrl = new GpioController(PinNumberingScheme.Board, _mockedGpioDriver.Object);
110+
var ctrl = new GpioController(_mockedGpioDriver.Object);
111111
ctrl.OpenPin(2, PinMode.Output);
112112
ctrl.Write(2, PinValue.High);
113113
Assert.Equal(PinValue.High, ctrl.Read(2));
@@ -122,36 +122,21 @@ public void UsingLogicalNumberingDisposesTheRightPin()
122122
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
123123
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Output)).Returns(true);
124124
_mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Output);
125-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
125+
var ctrl = new GpioController(_mockedGpioDriver.Object);
126126
ctrl.OpenPin(1, PinMode.Output);
127127
ctrl.Write(1, PinValue.High);
128128
// No close on the pin here, we want to check that the Controller's Dispose works correctly
129129
ctrl.Dispose();
130130
}
131131

132-
[Fact]
133-
public void UsingBoardNumberingDisposesTheRightPin()
134-
{
135-
// Our mock driver maps physical pin 2 to logical pin 1
136-
_mockedGpioDriver.Setup(x => x.ConvertPinNumberToLogicalNumberingSchemeEx(2)).Returns(1);
137-
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
138-
_mockedGpioDriver.Setup(x => x.SetPinModeEx(1, PinMode.Output));
139-
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
140-
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Output)).Returns(true);
141-
var ctrl = new GpioController(PinNumberingScheme.Board, _mockedGpioDriver.Object);
142-
ctrl.OpenPin(2, PinMode.Output);
143-
// No close on the pin here, we want to check that the Controller's Dispose works correctly
144-
ctrl.Dispose();
145-
}
146-
147132
[Fact]
148133
public void CallbackOnEventWorks()
149134
{
150135
// Our mock driver maps physical pin 2 to logical pin 1
151136
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
152137
_mockedGpioDriver.Setup(x => x.AddCallbackForPinValueChangedEventEx(1,
153138
PinEventTypes.Rising, It.IsAny<PinChangeEventHandler>()));
154-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
139+
var ctrl = new GpioController(_mockedGpioDriver.Object);
155140
ctrl.OpenPin(1); // logical pin 1 on our test board
156141
bool callbackSeen = false;
157142
PinChangeEventHandler eventHandler = (sender, args) =>
@@ -183,7 +168,7 @@ public void WriteSpan()
183168
_mockedGpioDriver.Setup(x => x.WriteEx(2, PinValue.Low));
184169
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
185170
_mockedGpioDriver.Setup(x => x.ClosePinEx(2));
186-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
171+
var ctrl = new GpioController(_mockedGpioDriver.Object);
187172
Assert.NotNull(ctrl);
188173
ctrl.OpenPin(1, PinMode.Output);
189174
ctrl.OpenPin(2, PinMode.Output);
@@ -208,7 +193,7 @@ public void ReadSpan()
208193
_mockedGpioDriver.Setup(x => x.ReadEx(2)).Returns(PinValue.High);
209194
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
210195
_mockedGpioDriver.Setup(x => x.ClosePinEx(2));
211-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
196+
var ctrl = new GpioController(_mockedGpioDriver.Object);
212197
Assert.NotNull(ctrl);
213198
ctrl.OpenPin(1, PinMode.Input);
214199
ctrl.OpenPin(2, PinMode.Input);
@@ -238,7 +223,7 @@ public void ReadSpan()
238223
[Fact]
239224
public async Task WaitForEventAsyncFail()
240225
{
241-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
226+
var ctrl = new GpioController(_mockedGpioDriver.Object);
242227
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
243228
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Input)).Returns(true);
244229
_mockedGpioDriver.Setup(x => x.WaitForEventEx(1, PinEventTypes.Rising | PinEventTypes.Falling, It.IsAny<CancellationToken>()))
@@ -260,7 +245,7 @@ public async Task WaitForEventAsyncFail()
260245
[Fact]
261246
public void WaitForEventSuccess()
262247
{
263-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
248+
var ctrl = new GpioController(_mockedGpioDriver.Object);
264249
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
265250
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Input)).Returns(true);
266251
_mockedGpioDriver.Setup(x => x.WaitForEventEx(1, PinEventTypes.Rising | PinEventTypes.Falling, It.IsAny<CancellationToken>()))

0 commit comments

Comments
 (0)