From 37291f6424dccb5876b70f1181f8a9128f7da71e Mon Sep 17 00:00:00 2001 From: Krzysztof Wicher Date: Thu, 14 Nov 2024 17:56:50 +0100 Subject: [PATCH] Obsolete PinNumberingScheme (#2358) * Obsolete PinNumberingScheme Let's see what breaks * Fixing using statement * share progress from triage meeting * Remove various usages of PinNumberingScheme * Remove all occurences of PinNumberingScheme from bindings * Fix some test errors * Checkout compatible version * There's a strange build error now * Add compat suppressions * Suppression update for Windows * Small review finding * Obsolete test instead of removing it --------- Co-authored-by: Jose Perez Rodriguez Co-authored-by: Patrick Grawehr Co-authored-by: Patrick Grawehr --- eng/ArduinoCsCI.cmd | 4 +- samples/M5StackRemoteDisplay/Program.cs | 2 +- samples/led-more-blinking-lights/Program.cs | 2 +- .../CompatibilitySuppressions.xml | 354 ++++++++++++------ .../GpioControllerSoftwareTests.cs | 26 +- .../GpioControllerTestBase.cs | 53 ++- src/System.Device.Gpio.Tests/GpioPinTests.cs | 6 +- .../LibGpiodV1DriverTests.cs | 20 +- .../LibGpiodV2DriverTests.cs | 3 +- .../RaspberryPiDriverTests.cs | 8 +- .../SysFsDriverTests.cs | 2 - .../WindowsDriverTests.cs | 2 - .../CompatibilitySuppressions.xml | 168 +++++++++ .../System/Device/Gpio/GpioController.cs | 23 ++ .../System/Device/Gpio/PinNumberingScheme.cs | 2 + src/devices/Ads1115/samples/Program.cs | 4 +- .../Arduino/ArduinoAnalogController.cs | 3 +- src/devices/Arduino/ArduinoBoard.cs | 4 +- src/devices/Board/Board.cs | 22 +- src/devices/Board/ManagedGpioController.cs | 2 +- src/devices/Board/RaspberryPiBoard.cs | 11 +- src/devices/Board/tests/BoardTests.cs | 1 - src/devices/Card/Ndef/samples/Program.cs | 2 +- src/devices/Ccs811/samples/Program.cs | 2 +- src/devices/CharacterLcd/LcdInterface.Gpio.cs | 2 +- .../CharacterLcd/samples/Pcf8574tSample.cs | 2 +- src/devices/CharacterLcd/samples/Program.cs | 2 +- .../System/Device/Analog/AnalogController.cs | 9 +- src/devices/Dhtxx/Devices/Dht11.cs | 5 +- src/devices/Dhtxx/Devices/Dht12.cs | 5 +- src/devices/Dhtxx/Devices/Dht21.cs | 5 +- src/devices/Dhtxx/Devices/Dht22.cs | 5 +- src/devices/Dhtxx/DhtBase.cs | 5 +- src/devices/Ft4222/samples/Program.cs | 4 +- src/devices/Gpio/samples/Program.cs | 2 +- src/devices/Hcsr04/Hcsr04.cs | 5 +- src/devices/Hcsr501/Hcsr501.cs | 5 +- src/devices/Hx711/HX711.cs | 6 +- src/devices/Ili934x/samples/Program.cs | 2 +- src/devices/Ili934x/tests/Ili934x.Tests.cs | 2 +- src/devices/LiquidLevel/LiquidLevelSwitch.cs | 5 +- src/devices/LiquidLevel/Llc200d3sh.cs | 5 +- src/devices/Mcp23xxx/samples/Program.cs | 2 +- .../Mcp23xxx/tests/EnableDisableTests.cs | 18 +- .../Mcp23xxx/tests/EventHandlingTests.cs | 10 +- src/devices/Mcp23xxx/tests/Mcp23xxxTest.cs | 2 +- src/devices/Nrf24l01/Nrf24l01.cs | 9 +- src/devices/Pcd8544/samples/Program.cs | 2 +- src/devices/Pcx857x/tests/Pcx857xTest.cs | 2 +- src/devices/Pn5180/Pn5180.cs | 2 +- src/devices/Pn5180/samples/Program.cs | 2 +- src/devices/RGBLedMatrix/RgbLedMatrix.cs | 2 +- .../Seesaw.Sample.BlinkingLights.cs | 2 +- .../samples/Encoder/Seesaw.Sample.Encoder.cs | 2 +- src/devices/Tm16xx/Tm1637.cs | 20 +- src/devices/Tm16xx/Tm1650.cs | 18 +- src/devices/Tm16xx/Tm16xxI2CLikeBase.cs | 20 +- .../Hal/ArduinoNativeBoard.cs | 2 +- .../tests/ArduinoNativeLibraryTest.cs | 2 +- .../Commands/Gpio/GpioBlinkLed.cs | 2 +- .../Commands/Gpio/GpioButtonEvent.cs | 6 +- .../Commands/Gpio/GpioButtonWait.cs | 8 +- .../Commands/Gpio/GpioCommand.cs | 7 +- .../Commands/Gpio/GpioReadPin.cs | 2 +- .../Commands/Gpio/GpioWritePin.cs | 2 +- 65 files changed, 594 insertions(+), 352 deletions(-) diff --git a/eng/ArduinoCsCI.cmd b/eng/ArduinoCsCI.cmd index f047cbcd0c..7f5db6c487 100644 --- a/eng/ArduinoCsCI.cmd +++ b/eng/ArduinoCsCI.cmd @@ -5,7 +5,7 @@ REM Second argument is either "Debug" or "Release" if %1!==! goto :usage REM Defines the revision to check out in the ExtendedConfigurableFirmata repo -set FIRMATA_SIMULATOR_CHECKOUT_REVISION=66b1863f3a4b0999f2c1cb7133332cbd25730252 +set FIRMATA_SIMULATOR_CHECKOUT_REVISION=18ef6b3a890b34904904663fb2cece9141600849 set RUN_COMPILER_TESTS=FALSE choco install -y --no-progress arduino-cli @@ -22,7 +22,7 @@ powershell -ExecutionPolicy ByPass -command "%~dp0common\Build.ps1" -restore -bu set ArduinoRootDir=%1\Documents\Arduino set acspath=%~dp0\..\artifacts\bin\Frontend\%2\net6.0\acs.exe -git clone https://github.com/firmata/ConfigurableFirmata %ArduinoRootDir%\libraries\ConfigurableFirmata +git clone https://github.com/firmata/ConfigurableFirmata %ArduinoRootDir%\libraries\ConfigurableFirmata --branch BuildIssueEsp git clone https://github.com/pgrawehr/ExtendedConfigurableFirmata %ArduinoRootDir%\ExtendedConfigurableFirmata arduino-cli core install esp32:esp32 diff --git a/samples/M5StackRemoteDisplay/Program.cs b/samples/M5StackRemoteDisplay/Program.cs index 7628cb6fd2..4d6b858cfe 100644 --- a/samples/M5StackRemoteDisplay/Program.cs +++ b/samples/M5StackRemoteDisplay/Program.cs @@ -185,7 +185,7 @@ public static int Main(string[] args) private static GpioController GetGpioControllerFromFt4222() { - return new GpioController(PinNumberingScheme.Logical, new Ft4222Gpio()); + return new GpioController(new Ft4222Gpio()); } private static SpiDevice GetSpiFromFt4222() diff --git a/samples/led-more-blinking-lights/Program.cs b/samples/led-more-blinking-lights/Program.cs index c527bcf246..52dd775ca3 100644 --- a/samples/led-more-blinking-lights/Program.cs +++ b/samples/led-more-blinking-lights/Program.cs @@ -23,7 +23,7 @@ volume = Volume.EnableVolume(); Console.WriteLine($"Let's blink some LEDs!"); -using GpioController controller = new GpioController(PinNumberingScheme.Logical); +using GpioController controller = new GpioController(); controller.OpenPin(ledOne, PinMode.Output); controller.OpenPin(ledTwo, PinMode.Output); controller.OpenPin(ledThree, PinMode.Output); diff --git a/src/Iot.Device.Bindings/CompatibilitySuppressions.xml b/src/Iot.Device.Bindings/CompatibilitySuppressions.xml index 36073fb0ce..8d82106cbf 100644 --- a/src/Iot.Device.Bindings/CompatibilitySuppressions.xml +++ b/src/Iot.Device.Bindings/CompatibilitySuppressions.xml @@ -45,434 +45,566 @@ CP0002 - F:Iot.Device.Axp192.BatteryStatus.Overwinered + F:Iot.Device.Ssd13xx.Ssd13xx._i2cDevice lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - F:Iot.Device.Axp192.Gpio0Behavior.MnosLeakOpenOutput + M:Iot.Device.Board.Board.CreatePwmChannel(System.Int32,System.Int32,System.Int32,System.Double,System.Int32,System.Device.Gpio.PinNumberingScheme) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - F:Iot.Device.Axp192.PowerStatus.VbuxExists + M:Iot.Device.Board.Board.CreateSpiDevice(System.Device.Spi.SpiConnectionSettings,System.Int32[],System.Device.Gpio.PinNumberingScheme) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - F:Iot.Device.Nmea0183.AisManager.CleanupLatency + M:Iot.Device.Board.Board.get_DefaultPinNumberingScheme lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - F:Iot.Device.Nmea0183.AisManager.WarningRepeatTimeout + M:Iot.Device.DHTxx.Dht11.#ctor(System.Int32,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - F:Iot.Device.Ssd13xx.Ssd13xx._i2cDevice + M:Iot.Device.DHTxx.Dht12.#ctor(System.Int32,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Axp192.Axp192.SetGPIO0(Iot.Device.Axp192.Gpio0Behavior,System.Byte) + M:Iot.Device.DHTxx.Dht21.#ctor(System.Int32,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Axp192.Axp192.SetLDO2Output(System.Byte) + M:Iot.Device.DHTxx.Dht22.#ctor(System.Int32,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Axp192.Axp192.SetLDO3Output(System.Byte) + M:Iot.Device.DHTxx.DhtBase.#ctor(System.Int32,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Ili934x.Ili9341.CreateBackBuffer + M:Iot.Device.Hcsr04.Hcsr04.#ctor(System.Int32,System.Int32,System.Device.Gpio.PinNumberingScheme) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Ili934x.Ili9341.DrawBitmap(Iot.Device.Graphics.BitmapImage,System.Drawing.Point,System.Drawing.Rectangle) + M:Iot.Device.Hcsr501.Hcsr501.#ctor(System.Int32,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Ili934x.Ili9341.DrawBitmap(Iot.Device.Graphics.BitmapImage,System.Drawing.Rectangle) + M:Iot.Device.Hx711.Hx711.#ctor(System.Int32,System.Int32,Iot.Device.Hx711.Hx711Options,System.Device.Gpio.GpioController,System.Device.Gpio.PinNumberingScheme,System.Boolean) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Nmea0183.AisManager.get_DeleteTargetAfterTimeout + M:Iot.Device.LiquidLevel.LiquidLevelSwitch.#ctor(System.Int32,System.Device.Gpio.PinValue,System.Device.Gpio.GpioController,System.Device.Gpio.PinNumberingScheme,System.Boolean) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Nmea0183.AisManager.SendWarningMessage(System.String,System.UInt32,System.String,System.DateTimeOffset) + M:Iot.Device.LiquidLevel.Llc200d3sh.#ctor(System.Int32,System.Device.Gpio.GpioController,System.Device.Gpio.PinNumberingScheme,System.Boolean) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Nmea0183.AisManager.set_DeleteTargetAfterTimeout(System.TimeSpan) + M:Iot.Device.Nmea0183.Sentences.WaterSpeedAndAngle.#ctor(UnitsNet.Angle,UnitsNet.Angle,UnitsNet.Speed) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Nmea0183.Sentences.EngineData.#ctor(System.Int32,System.Int32,UnitsNet.RotationalSpeed,UnitsNet.Ratio,System.TimeSpan,System.Nullable{UnitsNet.Temperature}) + M:Iot.Device.Nrf24l01.Nrf24l01.#ctor(System.Device.Spi.SpiDevice,System.Int32,System.Int32,System.Byte,System.Byte,Iot.Device.Nrf24l01.OutputPower,Iot.Device.Nrf24l01.DataRate,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Nmea0183.Sentences.SeaSmartEngineDetail.#ctor(System.Boolean,System.TimeSpan,UnitsNet.Temperature,System.Int32) + M:Iot.Device.Pn532.AsTarget.TargetModeInitialized.get_TargetBaudRate lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Nmea0183.Sentences.WaterSpeedAndAngle.#ctor(UnitsNet.Angle,UnitsNet.Angle,UnitsNet.Speed) + M:System.Device.Analog.AnalogController.#ctor(System.Device.Gpio.PinNumberingScheme) lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Ssd13xx.Ssd1306.#ctor(System.Device.I2c.I2cDevice) + M:System.Device.Analog.AnalogController.get_NumberingScheme lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Ssd13xx.Ssd1327.#ctor(System.Device.I2c.I2cDevice) - lib/net6.0/Iot.Device.Bindings.dll - lib/net6.0/Iot.Device.Bindings.dll + F:Iot.Device.Ssd13xx.Ssd13xx._i2cDevice + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Ssd13xx.Ssd1327.ClearDisplay - lib/net6.0/Iot.Device.Bindings.dll - lib/net6.0/Iot.Device.Bindings.dll + M:Iot.Device.Board.Board.CreatePwmChannel(System.Int32,System.Int32,System.Int32,System.Double,System.Int32,System.Device.Gpio.PinNumberingScheme) + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Ssd13xx.Ssd13xx.#ctor(System.Device.I2c.I2cDevice,System.Int32) - lib/net6.0/Iot.Device.Bindings.dll - lib/net6.0/Iot.Device.Bindings.dll + M:Iot.Device.Board.Board.CreateSpiDevice(System.Device.Spi.SpiConnectionSettings,System.Int32[],System.Device.Gpio.PinNumberingScheme) + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - F:Iot.Device.Axp192.BatteryStatus.Overwinered + M:Iot.Device.Board.Board.get_DefaultPinNumberingScheme lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - F:Iot.Device.Axp192.Gpio0Behavior.MnosLeakOpenOutput + M:Iot.Device.DHTxx.Dht11.#ctor(System.Int32,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - F:Iot.Device.Axp192.PowerStatus.VbuxExists + M:Iot.Device.DHTxx.Dht12.#ctor(System.Int32,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - F:Iot.Device.Nmea0183.AisManager.CleanupLatency + M:Iot.Device.DHTxx.Dht21.#ctor(System.Int32,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - F:Iot.Device.Nmea0183.AisManager.WarningRepeatTimeout + M:Iot.Device.DHTxx.Dht22.#ctor(System.Int32,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - F:Iot.Device.Ssd13xx.Ssd13xx._i2cDevice + M:Iot.Device.DHTxx.DhtBase.#ctor(System.Int32,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Axp192.Axp192.SetGPIO0(Iot.Device.Axp192.Gpio0Behavior,System.Byte) + M:Iot.Device.Hcsr04.Hcsr04.#ctor(System.Int32,System.Int32,System.Device.Gpio.PinNumberingScheme) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Axp192.Axp192.SetLDO2Output(System.Byte) + M:Iot.Device.Hcsr501.Hcsr501.#ctor(System.Int32,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Axp192.Axp192.SetLDO3Output(System.Byte) + M:Iot.Device.Hx711.Hx711.#ctor(System.Int32,System.Int32,Iot.Device.Hx711.Hx711Options,System.Device.Gpio.GpioController,System.Device.Gpio.PinNumberingScheme,System.Boolean) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Ili934x.Ili9341.CreateBackBuffer + M:Iot.Device.LiquidLevel.LiquidLevelSwitch.#ctor(System.Int32,System.Device.Gpio.PinValue,System.Device.Gpio.GpioController,System.Device.Gpio.PinNumberingScheme,System.Boolean) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Ili934x.Ili9341.DrawBitmap(Iot.Device.Graphics.BitmapImage,System.Drawing.Point,System.Drawing.Rectangle) + M:Iot.Device.LiquidLevel.Llc200d3sh.#ctor(System.Int32,System.Device.Gpio.GpioController,System.Device.Gpio.PinNumberingScheme,System.Boolean) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Ili934x.Ili9341.DrawBitmap(Iot.Device.Graphics.BitmapImage,System.Drawing.Rectangle) + M:Iot.Device.Nmea0183.Sentences.WaterSpeedAndAngle.#ctor(UnitsNet.Angle,UnitsNet.Angle,UnitsNet.Speed) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Nmea0183.AisManager.get_DeleteTargetAfterTimeout + M:Iot.Device.Nrf24l01.Nrf24l01.#ctor(System.Device.Spi.SpiDevice,System.Int32,System.Int32,System.Byte,System.Byte,Iot.Device.Nrf24l01.OutputPower,Iot.Device.Nrf24l01.DataRate,System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioController,System.Boolean) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Nmea0183.AisManager.SendWarningMessage(System.String,System.UInt32,System.String,System.DateTimeOffset) + M:Iot.Device.Pn532.AsTarget.TargetModeInitialized.get_TargetBaudRate lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Nmea0183.AisManager.set_DeleteTargetAfterTimeout(System.TimeSpan) + M:System.Device.Analog.AnalogController.#ctor(System.Device.Gpio.PinNumberingScheme) lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true CP0002 - M:Iot.Device.Nmea0183.Sentences.EngineData.#ctor(System.Int32,System.Int32,UnitsNet.RotationalSpeed,UnitsNet.Ratio,System.TimeSpan,System.Nullable{UnitsNet.Temperature}) + M:System.Device.Analog.AnalogController.get_NumberingScheme lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true - CP0002 - M:Iot.Device.Nmea0183.Sentences.SeaSmartEngineDetail.#ctor(System.Boolean,System.TimeSpan,UnitsNet.Temperature,System.Int32) + CP0005 + M:Iot.Device.Nmea0183.Ais.MovingTarget.{Clone}$ lib/netstandard2.0/Iot.Device.Bindings.dll - lib/netstandard2.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.ChargeIndicator + lib/net6.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll true - CP0002 - M:Iot.Device.Nmea0183.Sentences.WaterSpeedAndAngle.#ctor(UnitsNet.Angle,UnitsNet.Angle,UnitsNet.Speed) - lib/netstandard2.0/Iot.Device.Bindings.dll - lib/netstandard2.0/Iot.Device.Bindings.dll + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.CheckEngine + lib/net6.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll true - CP0002 - M:Iot.Device.Ssd13xx.Ssd1306.#ctor(System.Device.I2c.I2cDevice) - lib/netstandard2.0/Iot.Device.Bindings.dll - lib/netstandard2.0/Iot.Device.Bindings.dll + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.EgrSystem + lib/net6.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll true - CP0002 - M:Iot.Device.Ssd13xx.Ssd1327.#ctor(System.Device.I2c.I2cDevice) - lib/netstandard2.0/Iot.Device.Bindings.dll - lib/netstandard2.0/Iot.Device.Bindings.dll + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.EngineCommError + lib/net6.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll true - CP0002 - M:Iot.Device.Ssd13xx.Ssd1327.ClearDisplay - lib/netstandard2.0/Iot.Device.Bindings.dll - lib/netstandard2.0/Iot.Device.Bindings.dll + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.EngineEmergencyStopMode + lib/net6.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll true - CP0002 - M:Iot.Device.Ssd13xx.Ssd13xx.#ctor(System.Device.I2c.I2cDevice,System.Int32) - lib/netstandard2.0/Iot.Device.Bindings.dll - lib/netstandard2.0/Iot.Device.Bindings.dll + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.EngineShuttingDown + lib/net6.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll true - CP0005 - M:Iot.Device.Ssd13xx.Ssd13xx.SetStartAddress + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.HighBoostPressure lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true - CP0005 - M:Iot.Device.Ssd13xx.Ssd13xx.SetStartAddress - lib/netstandard2.0/Iot.Device.Bindings.dll - lib/netstandard2.0/Iot.Device.Bindings.dll + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.LowCoolantLevel + lib/net6.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll true - CP0007 - T:Iot.Device.Display.Pcd8544 + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.LowFuelPressure lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true - CP0007 - T:Iot.Device.Ili934x.Ili9341 + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.LowOilLevel lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true - CP0007 - T:Iot.Device.Ssd13xx.Ssd13xx + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.LowOilPressure lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true - CP0007 - T:Iot.Device.Display.Pcd8544 - lib/netstandard2.0/Iot.Device.Bindings.dll - lib/netstandard2.0/Iot.Device.Bindings.dll + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.LowSystemVoltage + lib/net6.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll true - CP0007 - T:Iot.Device.Ili934x.Ili9341 - lib/netstandard2.0/Iot.Device.Bindings.dll - lib/netstandard2.0/Iot.Device.Bindings.dll + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.MaintenanceNeeded + lib/net6.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll true - CP0007 - T:Iot.Device.Ssd13xx.Ssd13xx - lib/netstandard2.0/Iot.Device.Bindings.dll - lib/netstandard2.0/Iot.Device.Bindings.dll + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.NeutralStartProtect + lib/net6.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.OverTemperature + lib/net6.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.PreheatIndicator + lib/net6.0/Iot.Device.Bindings.dll + lib/net6.0/Iot.Device.Bindings.dll true - CP0012 - M:Iot.Device.Ili934x.Ili9341.Dispose(System.Boolean) + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.RevLimitExceeded lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true - CP0012 - M:Iot.Device.Ili934x.Ili9341.get_ScreenHeight + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.SecondaryThrottle lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true - CP0012 - M:Iot.Device.Ili934x.Ili9341.get_ScreenWidth + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.ThrottlePositionSensor lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true - CP0012 - P:Iot.Device.Ili934x.Ili9341.ScreenHeight + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.WaterFlow lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true - CP0012 - P:Iot.Device.Ili934x.Ili9341.ScreenWidth + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.WaterInFuel lib/net6.0/Iot.Device.Bindings.dll lib/net6.0/Iot.Device.Bindings.dll true - CP0012 - M:Iot.Device.Ili934x.Ili9341.Dispose(System.Boolean) + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.ChargeIndicator + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.CheckEngine + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.EgrSystem + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.EngineCommError + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.EngineEmergencyStopMode + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.EngineShuttingDown + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.HighBoostPressure + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.LowCoolantLevel + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.LowFuelPressure + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.LowOilLevel + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.LowOilPressure + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.LowSystemVoltage + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.MaintenanceNeeded + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.NeutralStartProtect + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.OverTemperature + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.PreheatIndicator + lib/netstandard2.0/Iot.Device.Bindings.dll + lib/netstandard2.0/Iot.Device.Bindings.dll + true + + + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.RevLimitExceeded lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true - CP0012 - M:Iot.Device.Ili934x.Ili9341.get_ScreenHeight + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.SecondaryThrottle lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true - CP0012 - M:Iot.Device.Ili934x.Ili9341.get_ScreenWidth + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.ThrottlePositionSensor lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true - CP0012 - P:Iot.Device.Ili934x.Ili9341.ScreenHeight + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.WaterFlow lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true - CP0012 - P:Iot.Device.Ili934x.Ili9341.ScreenWidth + CP0011 + F:Iot.Device.Nmea0183.Sentences.EngineStatus.WaterInFuel lib/netstandard2.0/Iot.Device.Bindings.dll lib/netstandard2.0/Iot.Device.Bindings.dll true diff --git a/src/System.Device.Gpio.Tests/GpioControllerSoftwareTests.cs b/src/System.Device.Gpio.Tests/GpioControllerSoftwareTests.cs index 7c8165a232..0f60f54453 100644 --- a/src/System.Device.Gpio.Tests/GpioControllerSoftwareTests.cs +++ b/src/System.Device.Gpio.Tests/GpioControllerSoftwareTests.cs @@ -26,14 +26,14 @@ public void Dispose() [Fact] public void PinCountReportedCorrectly() { - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); Assert.Equal(28, ctrl.PinCount); } [Fact] public void OpenTwiceGpioPinAndClosedTwiceThrows() { - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); _mockedGpioDriver.Setup(x => x.OpenPinEx(1)); _mockedGpioDriver.Setup(x => x.ClosePinEx(1)); GpioPin gpioPin1 = ctrl.OpenPin(1); @@ -50,7 +50,7 @@ public void WriteInputPinDoesNotThrow() _mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, It.IsAny())).Returns(true); _mockedGpioDriver.Setup(x => x.SetPinModeEx(1, It.IsAny())); _mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Input); - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); ctrl.OpenPin(1, PinMode.Input); ctrl.Write(1, PinValue.High); @@ -64,7 +64,7 @@ public void GpioControllerCreateOpenClosePin() _mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Output); _mockedGpioDriver.Setup(x => x.WriteEx(1, PinValue.High)); _mockedGpioDriver.Setup(x => x.ClosePinEx(1)); - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); Assert.NotNull(ctrl); ctrl.OpenPin(1, PinMode.Output); Assert.True(ctrl.IsPinOpen(1)); @@ -77,7 +77,7 @@ public void GpioControllerCreateOpenClosePin() public void IsPinModeSupported() { _mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Input)).Returns(true); - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); Assert.NotNull(ctrl); Assert.True(ctrl.IsPinModeSupported(1, PinMode.Input)); } @@ -87,7 +87,7 @@ public void GetPinMode() { _mockedGpioDriver.Setup(x => x.OpenPinEx(1)); _mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Output); - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); Assert.NotNull(ctrl); // Not open Assert.Throws(() => ctrl.GetPinMode(1)); @@ -96,6 +96,7 @@ public void GetPinMode() } [Fact] + [Obsolete("Tests an obsolete feature")] public void UsingBoardNumberingWorks() { // Our mock driver maps physical pin 2 to logical pin 1 @@ -122,7 +123,7 @@ public void UsingLogicalNumberingDisposesTheRightPin() _mockedGpioDriver.Setup(x => x.ClosePinEx(1)); _mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Output)).Returns(true); _mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Output); - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); ctrl.OpenPin(1, PinMode.Output); ctrl.Write(1, PinValue.High); // No close on the pin here, we want to check that the Controller's Dispose works correctly @@ -130,6 +131,7 @@ public void UsingLogicalNumberingDisposesTheRightPin() } [Fact] + [Obsolete("Tests obsolete features")] public void UsingBoardNumberingDisposesTheRightPin() { // Our mock driver maps physical pin 2 to logical pin 1 @@ -151,7 +153,7 @@ public void CallbackOnEventWorks() _mockedGpioDriver.Setup(x => x.OpenPinEx(1)); _mockedGpioDriver.Setup(x => x.AddCallbackForPinValueChangedEventEx(1, PinEventTypes.Rising, It.IsAny())); - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); ctrl.OpenPin(1); // logical pin 1 on our test board bool callbackSeen = false; PinChangeEventHandler eventHandler = (sender, args) => @@ -183,7 +185,7 @@ public void WriteSpan() _mockedGpioDriver.Setup(x => x.WriteEx(2, PinValue.Low)); _mockedGpioDriver.Setup(x => x.ClosePinEx(1)); _mockedGpioDriver.Setup(x => x.ClosePinEx(2)); - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); Assert.NotNull(ctrl); ctrl.OpenPin(1, PinMode.Output); ctrl.OpenPin(2, PinMode.Output); @@ -208,7 +210,7 @@ public void ReadSpan() _mockedGpioDriver.Setup(x => x.ReadEx(2)).Returns(PinValue.High); _mockedGpioDriver.Setup(x => x.ClosePinEx(1)); _mockedGpioDriver.Setup(x => x.ClosePinEx(2)); - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); Assert.NotNull(ctrl); ctrl.OpenPin(1, PinMode.Input); ctrl.OpenPin(2, PinMode.Input); @@ -238,7 +240,7 @@ public void ReadSpan() [Fact] public async Task WaitForEventAsyncFail() { - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); _mockedGpioDriver.Setup(x => x.OpenPinEx(1)); _mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Input)).Returns(true); _mockedGpioDriver.Setup(x => x.WaitForEventEx(1, PinEventTypes.Rising | PinEventTypes.Falling, It.IsAny())) @@ -260,7 +262,7 @@ public async Task WaitForEventAsyncFail() [Fact] public void WaitForEventSuccess() { - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); _mockedGpioDriver.Setup(x => x.OpenPinEx(1)); _mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Input)).Returns(true); _mockedGpioDriver.Setup(x => x.WaitForEventEx(1, PinEventTypes.Rising | PinEventTypes.Falling, It.IsAny())) diff --git a/src/System.Device.Gpio.Tests/GpioControllerTestBase.cs b/src/System.Device.Gpio.Tests/GpioControllerTestBase.cs index d21b3b51de..24dee97984 100644 --- a/src/System.Device.Gpio.Tests/GpioControllerTestBase.cs +++ b/src/System.Device.Gpio.Tests/GpioControllerTestBase.cs @@ -35,7 +35,7 @@ public void PinValueStaysSameAfterDispose(bool closeAsHigh) return; } - using (GpioController controller = new GpioController(GetTestNumberingScheme(), driver)) + using (GpioController controller = new GpioController(driver)) { controller.OpenPin(OutputPin, PinMode.Output); controller.OpenPin(InputPin, PinMode.Input); @@ -44,7 +44,7 @@ public void PinValueStaysSameAfterDispose(bool closeAsHigh) Assert.Equal(closeAsHigh, controller.Read(InputPin)); } - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { controller.OpenPin(InputPin, PinMode.Input); Assert.Equal(closeAsHigh, controller.Read(InputPin)); @@ -54,7 +54,7 @@ public void PinValueStaysSameAfterDispose(bool closeAsHigh) [Fact] public void PinValueReadAndWrite() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { controller.OpenPin(OutputPin, PinMode.Output); controller.OpenPin(InputPin, PinMode.Input); @@ -73,7 +73,7 @@ public void PinValueReadAndWrite() [Fact] public void PinCanChangeStateWhileItIsOpen() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { controller.OpenPin(OutputPin, PinMode.Input); Thread.SpinWait(100); @@ -87,7 +87,7 @@ public void PinCanChangeStateWhileItIsOpen() [Fact] public void ThrowsInvalidOperationExceptionWhenPinIsNotOpened() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { Assert.Throws(() => controller.Write(OutputPin, PinValue.High)); Assert.Throws(() => controller.Read(InputPin)); @@ -100,7 +100,7 @@ public void ThrowsInvalidOperationExceptionWhenPinIsNotOpened() [Fact] public void IsPinOpenOnInputTest() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { // Open pin in input mode (default) Assert.False(controller.IsPinOpen(LedPin)); @@ -115,7 +115,7 @@ public void IsPinOpenOnInputTest() public void IsPinOpenOnOutputTest() { // Separate test to check the IsPinOpen works also when the PinMode is Output, See Bug #776 - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { Assert.False(controller.IsPinOpen(LedPin)); @@ -135,7 +135,7 @@ public void IsPinOpenOnOutputTest() [Fact] public void AllowWritingOnInputPin() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { controller.OpenPin(InputPin, PinMode.Input); controller.Write(InputPin, PinValue.High); @@ -145,7 +145,7 @@ public void AllowWritingOnInputPin() [Fact] public void CanReadFromOutputPin() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { controller.OpenPin(OutputPin, PinMode.Output); @@ -160,7 +160,7 @@ public void CanReadFromOutputPin() [Fact] public void ThrowsIfReadingClosedPin() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { Assert.Throws(() => controller.Read(OutputPin)); } @@ -169,7 +169,7 @@ public void ThrowsIfReadingClosedPin() [Fact] public void ThrowsIfWritingClosedPin() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { Assert.Throws(() => controller.Write(OutputPin, PinValue.High)); } @@ -189,7 +189,7 @@ public void OpenPinDefaultsModeToLastMode(PinMode modeToTest) } // This works for input/output on most systems, but not on pullup/down, since sometimes the hardware doesn't have read possibilities for those (ie. the Raspi 3) - using (GpioController controller = new GpioController(GetTestNumberingScheme(), driver)) + using (GpioController controller = new GpioController(driver)) { controller.OpenPin(OutputPin); controller.SetPinMode(OutputPin, modeToTest); @@ -198,7 +198,7 @@ public void OpenPinDefaultsModeToLastMode(PinMode modeToTest) } // Close controller, to make sure we're not caching - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { controller.OpenPin(OutputPin); Thread.Sleep(100); @@ -210,7 +210,7 @@ public void OpenPinDefaultsModeToLastMode(PinMode modeToTest) public void AddCallbackTest() { bool wasCalled = false; - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { controller.OpenPin(InputPin, PinMode.Input); controller.OpenPin(OutputPin, PinMode.Output); @@ -240,7 +240,7 @@ public void AddCallbackFallingEdgeNotDetectedTest() bool wasCalled = false; AutoResetEvent ev = new AutoResetEvent(false); - using (GpioController controller = new GpioController(GetTestNumberingScheme(), driver)) + using (GpioController controller = new GpioController(driver)) { controller.OpenPin(InputPin, PinMode.Input); controller.OpenPin(OutputPin, PinMode.Output); @@ -272,7 +272,7 @@ void Callback(object sender, PinValueChangedEventArgs pinValueChangedEventArgs) public void AddCallbackRemoveCallbackTest() { int risingEventOccurredCount = 0, fallingEventOccurredCount = 0; - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { controller.OpenPin(InputPin, PinMode.Input); controller.OpenPin(OutputPin, PinMode.Output); @@ -328,7 +328,7 @@ public void AddCallbackRemoveAllCallbackTest() RetryHelper.Execute(() => { int risingEventOccurredCount = 0, fallingEventOccurredCount = 0; - using (GpioController controller = new GpioController(GetTestNumberingScheme(), testDriver)) + using (GpioController controller = new GpioController(testDriver)) { controller.OpenPin(InputPin, PinMode.Input); controller.OpenPin(OutputPin, PinMode.Output); @@ -382,7 +382,7 @@ void Callback4(object sender, PinValueChangedEventArgs e) public void AddCallbackRemoveAllCallbackAndAddCallbackAgainTest() { int callback1FiredTimes = 0, callback2FiredTimes = 0; - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { controller.OpenPin(InputPin, PinMode.Input); controller.OpenPin(OutputPin, PinMode.Output); @@ -421,7 +421,7 @@ void Callback2Falling(object sender, PinValueChangedEventArgs e) [Fact] public void WaitForEventCancelAfter10MillisecondsTest() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { CancellationTokenSource tokenSource = new CancellationTokenSource(WaitMilliseconds); controller.OpenPin(InputPin, PinMode.Input); @@ -439,7 +439,7 @@ public void WaitForEventCancelAfter10MillisecondsTest() [Fact] public void ThrowsIfWaitingOnClosedPin() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { Assert.Throws(() => controller.WaitForEvent(InputPin, PinEventTypes.Falling, CancellationToken.None)); } @@ -448,7 +448,7 @@ public void ThrowsIfWaitingOnClosedPin() [Fact] public void WaitForEventRisingEdgeTest() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { CancellationTokenSource tokenSource = new CancellationTokenSource(); controller.OpenPin(InputPin, PinMode.Input); @@ -473,7 +473,7 @@ public void WaitForEventFallingEdgeTest() { TimeoutHelper.CompletesInTime(() => { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { CancellationTokenSource tokenSource = new CancellationTokenSource(); controller.OpenPin(InputPin, PinMode.Input); @@ -498,7 +498,7 @@ public void WaitForEventFallingEdgeTest() [Fact] public async Task WaitForEventBothEdgesTest() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { CancellationTokenSource tokenSource = new CancellationTokenSource(); tokenSource.CancelAfter(2000); @@ -546,7 +546,7 @@ public void FastInterruptHandling() int numInterrupts = 0; int numRisingEdges = 0; - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { controller.OpenPin(InputPin, PinMode.Input); controller.OpenPin(OutputPin, PinMode.Output); @@ -598,7 +598,7 @@ void Callback(object sender, PinValueChangedEventArgs pinValueChangedEventArgs) [Fact] public void UsingPinAfterDriverDisposedCausesException() { - var controller = new GpioController(PinNumberingScheme.Logical, GetTestDriver()); + var controller = new GpioController(GetTestDriver()); var pin6 = controller.OpenPin(InputPin, PinMode.Input); controller.Dispose(); bool correctExceptionSeen = false; @@ -617,12 +617,11 @@ public void UsingPinAfterDriverDisposedCausesException() [Fact] public void UsingControllerAfterDisposeCausesException() { - var controller = new GpioController(PinNumberingScheme.Logical, GetTestDriver()); + var controller = new GpioController(GetTestDriver()); var pin6 = controller.OpenPin(InputPin, PinMode.Input); controller.Dispose(); Assert.Throws(() => controller.OpenPin(InputPin, PinMode.Input)); } protected abstract GpioDriver GetTestDriver(); - protected abstract PinNumberingScheme GetTestNumberingScheme(); } diff --git a/src/System.Device.Gpio.Tests/GpioPinTests.cs b/src/System.Device.Gpio.Tests/GpioPinTests.cs index beeabda5c0..1babe34a37 100644 --- a/src/System.Device.Gpio.Tests/GpioPinTests.cs +++ b/src/System.Device.Gpio.Tests/GpioPinTests.cs @@ -33,7 +33,7 @@ public void TestOpenPin() _mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(PinNumber, It.IsAny())).Returns(true); _mockedGpioDriver.Setup(x => x.SetPinModeEx(PinNumber, It.IsAny())); _mockedGpioDriver.Setup(x => x.GetPinModeEx(PinNumber)).Returns(PinMode.Input); - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); // Act GpioPin pin = ctrl.OpenPin(PinNumber, PinMode.Input); // Assert @@ -48,7 +48,7 @@ public void TestClosePin() _mockedGpioDriver.Setup(x => x.OpenPinEx(PinNumber)); _mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(PinNumber, It.IsAny())).Returns(true); _mockedGpioDriver.Setup(x => x.SetPinModeEx(PinNumber, It.IsAny())); - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); // Act GpioPin pin = ctrl.OpenPin(PinNumber, PinMode.Input); ctrl.ClosePin(PinNumber); @@ -67,7 +67,7 @@ public void TestToggleReadWrite() _mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(PinNumber, It.IsAny())).Returns(true); _mockedGpioDriver.Setup(x => x.SetPinModeEx(PinNumber, It.IsAny())); _mockedGpioDriver.Setup(x => x.ReadEx(PinNumber)).Returns(pinValue); - var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object); + var ctrl = new GpioController(_mockedGpioDriver.Object); // Act GpioPin pin = ctrl.OpenPin(PinNumber, PinMode.Input); pin.Write(pinValue); diff --git a/src/System.Device.Gpio.Tests/LibGpiodV1DriverTests.cs b/src/System.Device.Gpio.Tests/LibGpiodV1DriverTests.cs index a2ebf45c19..9f063651f0 100644 --- a/src/System.Device.Gpio.Tests/LibGpiodV1DriverTests.cs +++ b/src/System.Device.Gpio.Tests/LibGpiodV1DriverTests.cs @@ -9,6 +9,8 @@ namespace System.Device.Gpio.Tests; +#pragma warning disable SDGPIO0001 + [Trait("feature", "gpio")] [Trait("feature", "gpio-libgpiod")] [Trait("SkipOnTestRun", "Windows_NT")] @@ -21,12 +23,10 @@ public LibGpiodV1DriverTests(ITestOutputHelper testOutputHelper) protected override GpioDriver GetTestDriver() => new LibGpiodDriver(0, LibGpiodDriverVersion.V1); - protected override PinNumberingScheme GetTestNumberingScheme() => PinNumberingScheme.Logical; - [Fact] public void SetPinModeSetsDefaultValue() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { int testPin = OutputPin; // Set value to low prior to test, so that we have a defined start situation @@ -59,7 +59,7 @@ public void SetPinModeSetsDefaultValue() [Fact] public void UnregisterPinValueChangedShallNotThrow() { - using var gc = new GpioController(GetTestNumberingScheme(), GetTestDriver()); + using var gc = new GpioController(GetTestDriver()); gc.OpenPin(InputPin, PinMode.Input); static void PinChanged(object sender, PinValueChangedEventArgs args) @@ -80,21 +80,21 @@ static void PinChanged(object sender, PinValueChangedEventArgs args) [Fact] public void LeakingDriverDoesNotCrash() { - GpioController controller1 = new GpioController(PinNumberingScheme.Logical, new LibGpiodDriver()); + GpioController controller1 = new GpioController(new LibGpiodDriver()); controller1.OpenPin(10, PinMode.Output); - GpioController controller2 = new GpioController(PinNumberingScheme.Logical, new LibGpiodDriver()); + GpioController controller2 = new GpioController(new LibGpiodDriver()); controller2.OpenPin(11, PinMode.Output); - GpioController controller3 = new GpioController(PinNumberingScheme.Logical, new LibGpiodDriver()); + GpioController controller3 = new GpioController(new LibGpiodDriver()); controller3.OpenPin(12, PinMode.Output); - GpioController controller4 = new GpioController(PinNumberingScheme.Logical, new LibGpiodDriver()); + GpioController controller4 = new GpioController(new LibGpiodDriver()); controller4.OpenPin(13, PinMode.Output); - GpioController controller5 = new GpioController(PinNumberingScheme.Logical, new LibGpiodDriver()); + GpioController controller5 = new GpioController(new LibGpiodDriver()); controller5.OpenPin(14, PinMode.Output); for (int i = 0; i < 10; i++) { GC.Collect(); - GpioController controller6 = new GpioController(PinNumberingScheme.Logical, new LibGpiodDriver()); + GpioController controller6 = new GpioController(new LibGpiodDriver()); controller6.OpenPin(15, PinMode.Output); controller6.ClosePin(15); controller6.Dispose(); diff --git a/src/System.Device.Gpio.Tests/LibGpiodV2DriverTests.cs b/src/System.Device.Gpio.Tests/LibGpiodV2DriverTests.cs index d048d968ff..04cd2c7b42 100644 --- a/src/System.Device.Gpio.Tests/LibGpiodV2DriverTests.cs +++ b/src/System.Device.Gpio.Tests/LibGpiodV2DriverTests.cs @@ -7,6 +7,7 @@ using Xunit; using Xunit.Abstractions; +#pragma warning disable SDGPIO0001 namespace System.Device.Gpio.Tests; [Trait("feature", "gpio")] @@ -22,6 +23,4 @@ public LibGpiodV2DriverTests(ITestOutputHelper testOutputHelper) } protected override GpioDriver GetTestDriver() => new LibGpiodDriver(ChipNumber, LibGpiodDriverVersion.V2); - - protected override PinNumberingScheme GetTestNumberingScheme() => PinNumberingScheme.Logical; } diff --git a/src/System.Device.Gpio.Tests/RaspberryPiDriverTests.cs b/src/System.Device.Gpio.Tests/RaspberryPiDriverTests.cs index 2cf01ccd4b..c9323cf8f5 100644 --- a/src/System.Device.Gpio.Tests/RaspberryPiDriverTests.cs +++ b/src/System.Device.Gpio.Tests/RaspberryPiDriverTests.cs @@ -25,8 +25,6 @@ public RaspberryPiDriverTests(ITestOutputHelper testOutputHelper) protected override GpioDriver GetTestDriver() => new RaspberryPi3Driver(); - protected override PinNumberingScheme GetTestNumberingScheme() => PinNumberingScheme.Logical; - private bool IsRaspi4() { if (File.Exists("/proc/device-tree/model")) @@ -47,7 +45,7 @@ private bool IsRaspi4() [Fact] public void InputPullResistorsWork() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { controller.OpenPin(OpenPin, PinMode.InputPullUp); Assert.Equal(PinValue.High, controller.Read(OpenPin)); @@ -71,7 +69,7 @@ public void InputPullResistorsWork() public void OpenPinDefaultsModeToLastModeIncludingPulls() { // This is only fully supported on the Pi4 - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { controller.OpenPin(OutputPin); controller.SetPinMode(OutputPin, PinMode.InputPullDown); @@ -91,7 +89,7 @@ public void OpenPinDefaultsModeToLastModeIncludingPulls() [Fact] public void HighPulledPinDoesNotChangeToLowWhenChangedToOutput() { - using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver())) + using (GpioController controller = new GpioController(GetTestDriver())) { bool didTriggerToLow = false; int testPin = OutputPin; diff --git a/src/System.Device.Gpio.Tests/SysFsDriverTests.cs b/src/System.Device.Gpio.Tests/SysFsDriverTests.cs index 9430c987fd..10f4fd4dd8 100644 --- a/src/System.Device.Gpio.Tests/SysFsDriverTests.cs +++ b/src/System.Device.Gpio.Tests/SysFsDriverTests.cs @@ -19,6 +19,4 @@ public SysFsDriverTests(ITestOutputHelper testOutputHelper) } protected override GpioDriver GetTestDriver() => new SysFsDriver(); - - protected override PinNumberingScheme GetTestNumberingScheme() => PinNumberingScheme.Logical; } diff --git a/src/System.Device.Gpio.Tests/WindowsDriverTests.cs b/src/System.Device.Gpio.Tests/WindowsDriverTests.cs index 74dc82de45..49290dddd7 100644 --- a/src/System.Device.Gpio.Tests/WindowsDriverTests.cs +++ b/src/System.Device.Gpio.Tests/WindowsDriverTests.cs @@ -16,6 +16,4 @@ public WindowsDriverTests(ITestOutputHelper testOutputHelper) } protected override GpioDriver GetTestDriver() => new Windows10Driver(); - - protected override PinNumberingScheme GetTestNumberingScheme() => PinNumberingScheme.Logical; } diff --git a/src/System.Device.Gpio/CompatibilitySuppressions.xml b/src/System.Device.Gpio/CompatibilitySuppressions.xml index 1fc650add8..cc1c357495 100644 --- a/src/System.Device.Gpio/CompatibilitySuppressions.xml +++ b/src/System.Device.Gpio/CompatibilitySuppressions.xml @@ -1,6 +1,174 @@  + + CP0002 + F:System.Device.Gpio.Drivers.RaspberryPi3Driver.AltMode.Alt0 + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.Drivers.RaspberryPi3Driver.AltMode.Alt1 + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.Drivers.RaspberryPi3Driver.AltMode.Alt2 + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.Drivers.RaspberryPi3Driver.AltMode.Alt3 + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.Drivers.RaspberryPi3Driver.AltMode.Alt4 + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.Drivers.RaspberryPi3Driver.AltMode.Alt5 + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.Drivers.RaspberryPi3Driver.AltMode.Input + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.Drivers.RaspberryPi3Driver.AltMode.Output + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.Drivers.RaspberryPi3Driver.AltMode.Unknown + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.PinEventTypes.Falling + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.PinEventTypes.None + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.PinEventTypes.Rising + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.PinMode.Input + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.PinMode.InputPullDown + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.PinMode.InputPullUp + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.PinMode.Output + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.PinNumberingScheme.Board + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Gpio.PinNumberingScheme.Logical + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Spi.DataFlow.LsbFirst + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Spi.DataFlow.MsbFirst + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Spi.SpiMode.Mode0 + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Spi.SpiMode.Mode1 + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Spi.SpiMode.Mode2 + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + + + CP0002 + F:System.Device.Spi.SpiMode.Mode3 + lib/net6.0-windows10.0.17763/System.Device.Gpio.dll + lib/net6.0/System.Device.Gpio.dll + true + CP0002 M:System.Device.Gpio.Drivers.LibGpiodDriverVersion.#ctor diff --git a/src/System.Device.Gpio/System/Device/Gpio/GpioController.cs b/src/System.Device.Gpio/System/Device/Gpio/GpioController.cs index 985b41f72e..dabb555e42 100644 --- a/src/System.Device.Gpio/System/Device/Gpio/GpioController.cs +++ b/src/System.Device.Gpio/System/Device/Gpio/GpioController.cs @@ -40,15 +40,34 @@ public class GpioController : IDisposable /// Initializes a new instance of the class that will use the logical pin numbering scheme as default. /// public GpioController() +#pragma warning disable CS0612 // PinNumberingScheme is obsolete : this(PinNumberingScheme.Logical) +#pragma warning restore CS0612 { } + /// + /// Initializes a new instance of the class that will use the specified numbering scheme and driver. + /// + /// The driver that manages all of the pin operations for the controller. + public GpioController(GpioDriver driver) + { + _driver = driver; + +#pragma warning disable CS0612 // PinNumberingScheme is obsolete + NumberingScheme = PinNumberingScheme.Logical; +#pragma warning restore CS0612 + + _openPins = new ConcurrentDictionary(); + _gpioPins = new ConcurrentDictionary(); + } + /// /// Initializes a new instance of the class that will use the specified numbering scheme and driver. /// /// The numbering scheme used to represent pins provided by the controller. /// The driver that manages all of the pin operations for the controller. + [Obsolete] public GpioController(PinNumberingScheme numberingScheme, GpioDriver driver) { _driver = driver; @@ -62,6 +81,7 @@ public GpioController(PinNumberingScheme numberingScheme, GpioDriver driver) /// The controller will default to use the driver that best applies given the platform the program is executing on. /// /// The numbering scheme used to represent pins provided by the controller. + [Obsolete] public GpioController(PinNumberingScheme numberingScheme) : this(numberingScheme, GetBestDriverForBoard()) { @@ -70,6 +90,7 @@ public GpioController(PinNumberingScheme numberingScheme) /// /// The numbering scheme used to represent pins provided by the controller. /// + [Obsolete] public PinNumberingScheme NumberingScheme { get; } /// @@ -102,7 +123,9 @@ private IEnumerable OpenPins /// The logical pin number in the controller's numbering scheme. protected virtual int GetLogicalPinNumber(int pinNumber) { +#pragma warning disable CS0612 // PinNumberingScheme is obsolete return (NumberingScheme == PinNumberingScheme.Logical) ? pinNumber : _driver.ConvertPinNumberToLogicalNumberingScheme(pinNumber); +#pragma warning restore CS0612 } /// diff --git a/src/System.Device.Gpio/System/Device/Gpio/PinNumberingScheme.cs b/src/System.Device.Gpio/System/Device/Gpio/PinNumberingScheme.cs index bf7f4c326f..b46612884d 100644 --- a/src/System.Device.Gpio/System/Device/Gpio/PinNumberingScheme.cs +++ b/src/System.Device.Gpio/System/Device/Gpio/PinNumberingScheme.cs @@ -1,11 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; namespace System.Device.Gpio; /// /// Different numbering schemes supported by GPIO controllers and drivers. /// +[Obsolete] public enum PinNumberingScheme { /// diff --git a/src/devices/Ads1115/samples/Program.cs b/src/devices/Ads1115/samples/Program.cs index deb9f68d70..d22b2d9898 100644 --- a/src/devices/Ads1115/samples/Program.cs +++ b/src/devices/Ads1115/samples/Program.cs @@ -72,7 +72,7 @@ // Provide a callback that triggers each time the ADC has a new value available. The DataRate parameter will define the sample rate. // We are using pin 23 as interrupt input from the ADC, but note that the trigger signal from the ADC may be to short to be properly recognized by the Raspberry Pi and // some extra electronics is required to make this reliably work (see readme). -using (var controller = new GpioController(PinNumberingScheme.Logical)) +using (var controller = new GpioController()) { Console.Clear(); Console.WriteLine("This triggers an interrupt each time a new value is available on AIN0"); @@ -107,7 +107,7 @@ } // Use an interrupt handler, but this time when the value on AIN1 exceeds a threshold -using (var controller = new GpioController(PinNumberingScheme.Logical)) +using (var controller = new GpioController()) { Console.Clear(); Console.WriteLine("This triggers an interrupt as long as the value is above 2.0V (and then stays above 1.8V)"); diff --git a/src/devices/Arduino/ArduinoAnalogController.cs b/src/devices/Arduino/ArduinoAnalogController.cs index 06645d8eb1..62cac930c1 100644 --- a/src/devices/Arduino/ArduinoAnalogController.cs +++ b/src/devices/Arduino/ArduinoAnalogController.cs @@ -19,8 +19,7 @@ internal class ArduinoAnalogController : AnalogController private readonly IReadOnlyList _supportedPinConfigurations; public ArduinoAnalogController(ArduinoBoard board, - IReadOnlyList supportedPinConfigurations, PinNumberingScheme scheme) - : base(scheme) + IReadOnlyList supportedPinConfigurations) { _board = board ?? throw new ArgumentNullException(nameof(board)); _supportedPinConfigurations = supportedPinConfigurations ?? throw new ArgumentNullException(nameof(supportedPinConfigurations)); diff --git a/src/devices/Arduino/ArduinoBoard.cs b/src/devices/Arduino/ArduinoBoard.cs index 2bfedc9e26..75335bac2e 100644 --- a/src/devices/Arduino/ArduinoBoard.cs +++ b/src/devices/Arduino/ArduinoBoard.cs @@ -725,7 +725,7 @@ public override GpioController CreateGpioController() throw new ObjectDisposedException(nameof(_firmata)); } - return new GpioController(PinNumberingScheme.Logical, new ArduinoGpioControllerDriver(_firmata, _supportedPinConfigurations)); + return new GpioController(new ArduinoGpioControllerDriver(_firmata, _supportedPinConfigurations)); } /// @@ -841,7 +841,7 @@ public virtual AnalogController CreateAnalogController(int chip) { Initialize(); - return new ArduinoAnalogController(this, SupportedPinConfigurations, PinNumberingScheme.Logical); + return new ArduinoAnalogController(this, SupportedPinConfigurations); } /// diff --git a/src/devices/Board/Board.cs b/src/devices/Board/Board.cs index a6b896d4a7..d58d6faa39 100644 --- a/src/devices/Board/Board.cs +++ b/src/devices/Board/Board.cs @@ -67,18 +67,6 @@ protected Board() /// protected bool Disposed => _disposed; - /// - /// The default pin numbering scheme for this board. - /// - public PinNumberingScheme DefaultPinNumberingScheme - { - get - { - // 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. - return PinNumberingScheme.Logical; - } - } - /// /// Reserves a pin for a specific usage. This is done automatically if a known interface (i.e. GpioController) is /// 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) /// Connection parameters (contains bus number and CS pin number) /// The set of pins to use for SPI. The parameter can be null if the hardware requires a fixed mapping from /// pins to SPI for the given bus. - /// The numbering scheme in which the is given /// An SPI device instance - public SpiDevice CreateSpiDevice(SpiConnectionSettings connectionSettings, int[] pinAssignment, PinNumberingScheme pinNumberingScheme) + public SpiDevice CreateSpiDevice(SpiConnectionSettings connectionSettings, int[] pinAssignment) { Initialize(); @@ -539,7 +526,7 @@ public SpiDevice CreateSpiDevice(SpiConnectionSettings connectionSettings) // Returns logical pin numbers for the selected bus (or an exception if using a bus number > 1, because that // requires specifying the pins) int[] pinAssignment = GetDefaultPinAssignmentForSpi(connectionSettings); - return CreateSpiDevice(connectionSettings, pinAssignment, PinNumberingScheme.Logical); + return CreateSpiDevice(connectionSettings, pinAssignment); } /// @@ -560,10 +547,9 @@ public SpiDevice CreateSpiDevice(SpiConnectionSettings connectionSettings) /// Initial frequency /// Initial duty cycle /// 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) - /// The pin numbering scheme for the pin /// A pwm channel instance public PwmChannel CreatePwmChannel(int chip, int channel, int frequency, double dutyCyclePercentage, - int pin, PinNumberingScheme pinNumberingScheme) + int pin) { Initialize(); return AddManager(new PwmChannelManager(this, pin, chip, channel, frequency, dutyCyclePercentage, CreateSimplePwmChannel)); @@ -585,7 +571,7 @@ public PwmChannel CreatePwmChannel( { Initialize(); int pin = GetDefaultPinAssignmentForPwm(chip, channel); - return CreatePwmChannel(chip, channel, frequency, dutyCyclePercentage, pin, PinNumberingScheme.Logical); + return CreatePwmChannel(chip, channel, frequency, dutyCyclePercentage, pin); } /// diff --git a/src/devices/Board/ManagedGpioController.cs b/src/devices/Board/ManagedGpioController.cs index 4b79dfd546..df2822e92f 100644 --- a/src/devices/Board/ManagedGpioController.cs +++ b/src/devices/Board/ManagedGpioController.cs @@ -24,7 +24,7 @@ internal class ManagedGpioController : GpioController, IDeviceManager private readonly HashSet _openPins; public ManagedGpioController(Board board, GpioDriver driver) - : base(PinNumberingScheme.Logical, driver) + : base(driver) { _board = board ?? throw new ArgumentNullException(nameof(board)); _driver = driver ?? throw new ArgumentNullException(nameof(driver)); diff --git a/src/devices/Board/RaspberryPiBoard.cs b/src/devices/Board/RaspberryPiBoard.cs index 175cc0342f..43a916e464 100644 --- a/src/devices/Board/RaspberryPiBoard.cs +++ b/src/devices/Board/RaspberryPiBoard.cs @@ -374,11 +374,10 @@ public override int[] GetDefaultPinAssignmentForSpi(SpiConnectionSettings connec /// /// Pin number to use /// Requested usage - /// Pin numbering scheme for the pin provided (logical or physical) /// Optional bus argument, for SPI and I2C pins /// /// A member of describing the mode the pin is in. - private RaspberryPi3Driver.AltMode GetHardwareModeForPinUsage(int pinNumber, PinUsage usage, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, int bus = 0) + private RaspberryPi3Driver.AltMode GetHardwareModeForPinUsage(int pinNumber, PinUsage usage, int bus = 0) { if (pinNumber >= PinCount) { @@ -566,7 +565,7 @@ protected override void ActivatePinMode(int pinNumber, PinUsage usage) throw new NotSupportedException("Alternate pin mode setting not supported by driver"); } - var modeToSet = GetHardwareModeForPinUsage(pinNumber, usage, PinNumberingScheme.Logical); + var modeToSet = GetHardwareModeForPinUsage(pinNumber, usage); if (modeToSet != RaspberryPi3Driver.AltMode.Unknown) { _raspberryPi3Driver.SetAlternatePinMode(pinNumber, modeToSet); @@ -607,19 +606,19 @@ public override PinUsage DetermineCurrentPinUsage(int pinNumber) // 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 // it set to. - var possibleAltMode = GetHardwareModeForPinUsage(pinNumber, PinUsage.I2c, DefaultPinNumberingScheme); + var possibleAltMode = GetHardwareModeForPinUsage(pinNumber, PinUsage.I2c); if (possibleAltMode == pinMode) { return PinUsage.I2c; } - possibleAltMode = GetHardwareModeForPinUsage(pinNumber, PinUsage.Spi, DefaultPinNumberingScheme); + possibleAltMode = GetHardwareModeForPinUsage(pinNumber, PinUsage.Spi); if (possibleAltMode == pinMode) { return PinUsage.Spi; } - possibleAltMode = GetHardwareModeForPinUsage(pinNumber, PinUsage.Pwm, DefaultPinNumberingScheme); + possibleAltMode = GetHardwareModeForPinUsage(pinNumber, PinUsage.Pwm); if (possibleAltMode == pinMode) { return PinUsage.Pwm; diff --git a/src/devices/Board/tests/BoardTests.cs b/src/devices/Board/tests/BoardTests.cs index b9c15fb29f..a9c303e210 100644 --- a/src/devices/Board/tests/BoardTests.cs +++ b/src/devices/Board/tests/BoardTests.cs @@ -36,7 +36,6 @@ public void ThereIsAlwaysAMatchingBoard() Assert.NotNull(board); var property = board.GetType().GetProperty("Initialized", BindingFlags.Instance | BindingFlags.NonPublic)!; Assert.True((bool)property.GetValue(board)!); - Assert.Equal(PinNumberingScheme.Logical, board.DefaultPinNumberingScheme); board.Dispose(); } diff --git a/src/devices/Card/Ndef/samples/Program.cs b/src/devices/Card/Ndef/samples/Program.cs index 4b9aff3be5..c39cda364e 100644 --- a/src/devices/Card/Ndef/samples/Program.cs +++ b/src/devices/Card/Ndef/samples/Program.cs @@ -418,7 +418,7 @@ Pn5180 Ft4222Pn5180() var ftSpi = new Ft4222Spi(new SpiConnectionSettings(0, 1) { ClockFrequency = Pn5180.MaximumSpiClockFrequency, Mode = Pn5180.DefaultSpiMode, DataFlow = DataFlow.MsbFirst }); - var gpioController = new GpioController(PinNumberingScheme.Board, new Ft4222Gpio()); + var gpioController = new GpioController(new Ft4222Gpio()); // REset the device gpioController.OpenPin(0, PinMode.Output); diff --git a/src/devices/Ccs811/samples/Program.cs b/src/devices/Ccs811/samples/Program.cs index b94691803f..397a62db45 100644 --- a/src/devices/Ccs811/samples/Program.cs +++ b/src/devices/Ccs811/samples/Program.cs @@ -54,7 +54,7 @@ using (var i2cBus = Ft4222Device.GetFt4222()[0].CreateOrGetI2cBus(0)) { int deviceAddress = addressChoice.KeyChar == '1' ? Ccs811Sensor.I2cFirstAddress : Ccs811Sensor.I2cSecondAddress; - var gpioController = new GpioController(PinNumberingScheme.Board, new Ft4222Gpio()); + var gpioController = new GpioController(new Ft4222Gpio()); using (var ccs811 = new Ccs811Sensor(i2cBus.CreateDevice(deviceAddress), gpioController, pinWake, pinInterrupt, pinReset, false)) { Sample(ccs811); diff --git a/src/devices/CharacterLcd/LcdInterface.Gpio.cs b/src/devices/CharacterLcd/LcdInterface.Gpio.cs index 4c4688151c..396f341938 100644 --- a/src/devices/CharacterLcd/LcdInterface.Gpio.cs +++ b/src/devices/CharacterLcd/LcdInterface.Gpio.cs @@ -66,7 +66,7 @@ public Gpio(int registerSelectPin, int enablePin, int[] dataPins, int backlightP } _shouldDispose = shouldDispose || controller is null; - _controller = controller ?? new GpioController(PinNumberingScheme.Logical); + _controller = controller ?? new GpioController(); Initialize(); } diff --git a/src/devices/CharacterLcd/samples/Pcf8574tSample.cs b/src/devices/CharacterLcd/samples/Pcf8574tSample.cs index d6d59dd102..a68bb2f78d 100644 --- a/src/devices/CharacterLcd/samples/Pcf8574tSample.cs +++ b/src/devices/CharacterLcd/samples/Pcf8574tSample.cs @@ -26,7 +26,7 @@ public static void SampleEntryPoint() // for PCF8574AT i2c addresses can be between 0x3f and 0x38 depending on bridged solder jumpers var i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: 0x27)); var driver = new Pcf8574(i2cDevice); - var lcd = new Lcd1602(registerSelectPin: 0, enablePin: 2, dataPins: new int[] { 4, 5, 6, 7 }, backlightPin: 3, readWritePin: 1, controller: new GpioController(PinNumberingScheme.Logical, driver)); + var lcd = new Lcd1602(registerSelectPin: 0, enablePin: 2, dataPins: new int[] { 4, 5, 6, 7 }, backlightPin: 3, readWritePin: 1, controller: new GpioController(driver)); using (lcd) { diff --git a/src/devices/CharacterLcd/samples/Program.cs b/src/devices/CharacterLcd/samples/Program.cs index e52623cb47..acb6a782f2 100644 --- a/src/devices/CharacterLcd/samples/Program.cs +++ b/src/devices/CharacterLcd/samples/Program.cs @@ -36,7 +36,7 @@ void UsingMcp() int registerSelectPin = 1; int enablePin = 2; int backlight = 7; - using Lcd1602 lcd = new Lcd1602(registerSelectPin, enablePin, dataPins, backlight, controller: new GpioController(PinNumberingScheme.Logical, driver)); + using Lcd1602 lcd = new Lcd1602(registerSelectPin, enablePin, dataPins, backlight, controller: new GpioController(driver)); lcd.Clear(); lcd.Write("Hello World"); diff --git a/src/devices/Common/System/Device/Analog/AnalogController.cs b/src/devices/Common/System/Device/Analog/AnalogController.cs index 446b125df0..1dcd32eaf8 100644 --- a/src/devices/Common/System/Device/Analog/AnalogController.cs +++ b/src/devices/Common/System/Device/Analog/AnalogController.cs @@ -19,18 +19,11 @@ public abstract class AnalogController : IDisposable /// /// Initializes a new instance of the class that will use the specified numbering scheme and driver. /// - /// The numbering scheme used to represent pins provided by the controller. - protected AnalogController(PinNumberingScheme numberingScheme) + protected AnalogController() { - NumberingScheme = numberingScheme; _openPins = new List(); } - /// - /// The numbering scheme used to represent pins provided by the controller. - /// - public PinNumberingScheme NumberingScheme { get; } - /// /// The number of pins provided by the controller. /// diff --git a/src/devices/Dhtxx/Devices/Dht11.cs b/src/devices/Dhtxx/Devices/Dht11.cs index 481fbc1c54..46c38c77e5 100644 --- a/src/devices/Dhtxx/Devices/Dht11.cs +++ b/src/devices/Dhtxx/Devices/Dht11.cs @@ -18,11 +18,10 @@ public class Dht11 : DhtBase /// Create a DHT11 sensor /// /// The pin number (GPIO number) - /// The GPIO pin numbering scheme /// related with operations on pins /// True to dispose the Gpio Controller - public Dht11(int pin, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true) - : base(pin, pinNumberingScheme, gpioController, shouldDispose) + public Dht11(int pin, GpioController? gpioController = null, bool shouldDispose = true) + : base(pin, gpioController, shouldDispose) { } diff --git a/src/devices/Dhtxx/Devices/Dht12.cs b/src/devices/Dhtxx/Devices/Dht12.cs index 6e7003e9ea..9c35a139eb 100644 --- a/src/devices/Dhtxx/Devices/Dht12.cs +++ b/src/devices/Dhtxx/Devices/Dht12.cs @@ -24,11 +24,10 @@ public class Dht12 : DhtBase /// Create a DHT12 sensor /// /// The pin number (GPIO number) - /// The GPIO pin numbering scheme /// related with operations on pins /// True to dispose the Gpio Controller - public Dht12(int pin, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true) - : base(pin, pinNumberingScheme, gpioController, shouldDispose) + public Dht12(int pin, GpioController? gpioController = null, bool shouldDispose = true) + : base(pin, gpioController, shouldDispose) { } diff --git a/src/devices/Dhtxx/Devices/Dht21.cs b/src/devices/Dhtxx/Devices/Dht21.cs index e7aee73992..957fe11105 100644 --- a/src/devices/Dhtxx/Devices/Dht21.cs +++ b/src/devices/Dhtxx/Devices/Dht21.cs @@ -18,11 +18,10 @@ public class Dht21 : DhtBase /// Create a DHT22 sensor /// /// The pin number (GPIO number) - /// The GPIO pin numbering scheme /// related with operations on pins /// True to dispose the Gpio Controller - public Dht21(int pin, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true) - : base(pin, pinNumberingScheme, gpioController, shouldDispose) + public Dht21(int pin, GpioController? gpioController = null, bool shouldDispose = true) + : base(pin, gpioController, shouldDispose) { } diff --git a/src/devices/Dhtxx/Devices/Dht22.cs b/src/devices/Dhtxx/Devices/Dht22.cs index 5b37dff9db..21b8d4fad3 100644 --- a/src/devices/Dhtxx/Devices/Dht22.cs +++ b/src/devices/Dhtxx/Devices/Dht22.cs @@ -18,11 +18,10 @@ public class Dht22 : DhtBase /// Create a DHT22 sensor /// /// The pin number (GPIO number) - /// The GPIO pin numbering scheme /// related with operations on pins /// True to dispose the Gpio Controller - public Dht22(int pin, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true) - : base(pin, pinNumberingScheme, gpioController, shouldDispose) + public Dht22(int pin, GpioController? gpioController = null, bool shouldDispose = true) + : base(pin, gpioController, shouldDispose) { } diff --git a/src/devices/Dhtxx/DhtBase.cs b/src/devices/Dhtxx/DhtBase.cs index da3dba9e74..5b0a5b1cf0 100644 --- a/src/devices/Dhtxx/DhtBase.cs +++ b/src/devices/Dhtxx/DhtBase.cs @@ -126,14 +126,13 @@ public TimeSpan MinTimeBetweenReads /// Create a DHT sensor /// /// The pin number (GPIO number) - /// The GPIO pin numbering scheme /// related with operations on pins /// True to dispose the Gpio Controller - public DhtBase(int pin, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true) + public DhtBase(int pin, GpioController? gpioController = null, bool shouldDispose = true) { _protocol = CommunicationProtocol.OneWire; _shouldDispose = shouldDispose || gpioController is null; - _controller = gpioController ?? new GpioController(pinNumberingScheme); + _controller = gpioController ?? new GpioController(); _pin = pin; // These sensors typically require 2.5 seconds between read attempts, or the result will be garbage diff --git a/src/devices/Ft4222/samples/Program.cs b/src/devices/Ft4222/samples/Program.cs index 30487bbfce..20ec0caba0 100644 --- a/src/devices/Ft4222/samples/Program.cs +++ b/src/devices/Ft4222/samples/Program.cs @@ -101,7 +101,7 @@ void TestSpi() void TestGpio() { const int Gpio2 = 2; - using GpioController gpioController = new(PinNumberingScheme.Board, new Ft4222Gpio()); + using GpioController gpioController = new(new Ft4222Gpio()); // Opening GPIO2 gpioController.OpenPin(Gpio2); @@ -130,7 +130,7 @@ void TestGpio() void TestEvents() { const int Gpio2 = 2; - using GpioController gpioController = new(PinNumberingScheme.Board, new Ft4222Gpio()); + using GpioController gpioController = new(new Ft4222Gpio()); // Opening GPIO2 gpioController.OpenPin(Gpio2); diff --git a/src/devices/Gpio/samples/Program.cs b/src/devices/Gpio/samples/Program.cs index 88400c9648..5a06292d0c 100644 --- a/src/devices/Gpio/samples/Program.cs +++ b/src/devices/Gpio/samples/Program.cs @@ -18,7 +18,7 @@ private static void Main(string[] args) Console.WriteLine($"Let's blink an on-board LED!"); - using GpioController controller = new GpioController(PinNumberingScheme.Board, new OrangePiZeroDriver()); + using GpioController controller = new GpioController(new OrangePiZeroDriver()); using BoardLed led = new BoardLed("orangepi:red:status"); controller.OpenPin(pin, PinMode.InputPullUp); diff --git a/src/devices/Hcsr04/Hcsr04.cs b/src/devices/Hcsr04/Hcsr04.cs index d28f57efac..2da29f38dc 100644 --- a/src/devices/Hcsr04/Hcsr04.cs +++ b/src/devices/Hcsr04/Hcsr04.cs @@ -61,9 +61,8 @@ public Hcsr04(GpioController? gpioController, int triggerPin, int echoPin, bool /// /// Trigger pulse input. /// Trigger pulse output. - /// Pin Numbering Scheme - public Hcsr04(int triggerPin, int echoPin, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical) - : this(new GpioController(pinNumberingScheme), triggerPin, echoPin) + public Hcsr04(int triggerPin, int echoPin) + : this(new GpioController(), triggerPin, echoPin) { } diff --git a/src/devices/Hcsr501/Hcsr501.cs b/src/devices/Hcsr501/Hcsr501.cs index 5894adfcc0..4629dd2400 100644 --- a/src/devices/Hcsr501/Hcsr501.cs +++ b/src/devices/Hcsr501/Hcsr501.cs @@ -21,15 +21,14 @@ public class Hcsr501 : IDisposable /// Creates a new instance of the HC-SCR501. /// /// OUT Pin - /// Pin Numbering Scheme /// related with operations on pins /// True to dispose the Gpio Controller - public Hcsr501(int outPin, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true) + public Hcsr501(int outPin, GpioController? gpioController = null, bool shouldDispose = true) { _outPin = outPin; _shouldDispose = shouldDispose || gpioController is null; - _controller = gpioController ?? new GpioController(pinNumberingScheme); + _controller = gpioController ?? new GpioController(); _controller.OpenPin(outPin, PinMode.Input); _controller.RegisterCallbackForPinValueChangedEvent(outPin, PinEventTypes.Falling, Sensor_ValueChanged); _controller.RegisterCallbackForPinValueChangedEvent(outPin, PinEventTypes.Rising, Sensor_ValueChanged); diff --git a/src/devices/Hx711/HX711.cs b/src/devices/Hx711/HX711.cs index 08f1dbe927..d138ebd4b4 100644 --- a/src/devices/Hx711/HX711.cs +++ b/src/devices/Hx711/HX711.cs @@ -59,16 +59,14 @@ public Mass TareValue /// Trigger pulse input. (Power Down control and Serial Clock input) /// How to use the Hx711 module. /// GPIO controller related with the pins. - /// Scheme and numeration used by controller. /// True to dispose the Gpio Controller. - public Hx711(int pinDout, int pinPdSck, Hx711Options? options = null, GpioController? gpioController = null, - PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, bool shouldDispose = true) + public Hx711(int pinDout, int pinPdSck, Hx711Options? options = null, GpioController? gpioController = null, bool shouldDispose = true) { _pinDout = pinDout; _pinPdSck = pinPdSck; _shouldDispose = shouldDispose || gpioController is null; - _gpioController = gpioController ?? new(pinNumberingScheme); + _gpioController = gpioController ?? new(); // Mutex for reading from the Hx711, in case multiple threads in client // software try to access get values from the class at the same time. diff --git a/src/devices/Ili934x/samples/Program.cs b/src/devices/Ili934x/samples/Program.cs index 408bdb10d6..eca2416dec 100644 --- a/src/devices/Ili934x/samples/Program.cs +++ b/src/devices/Ili934x/samples/Program.cs @@ -62,7 +62,7 @@ GpioController GetGpioControllerFromFt4222() { - return new GpioController(PinNumberingScheme.Logical, new Ft4222Gpio()); + return new GpioController(new Ft4222Gpio()); } SpiDevice GetSpiFromFt4222() diff --git a/src/devices/Ili934x/tests/Ili934x.Tests.cs b/src/devices/Ili934x/tests/Ili934x.Tests.cs index e0bbf551cb..72d430bd94 100644 --- a/src/devices/Ili934x/tests/Ili934x.Tests.cs +++ b/src/devices/Ili934x/tests/Ili934x.Tests.cs @@ -28,7 +28,7 @@ public Ili9342Test() _imageFactoryMock = new Mock(MockBehavior.Strict); BitmapImage.RegisterImageFactory(_imageFactoryMock.Object); _gpioDriverMock.CallBase = true; - _gpioController = new GpioController(PinNumberingScheme.Logical, _gpioDriverMock.Object); + _gpioController = new GpioController(_gpioDriverMock.Object); } public void Dispose() diff --git a/src/devices/LiquidLevel/LiquidLevelSwitch.cs b/src/devices/LiquidLevel/LiquidLevelSwitch.cs index 9b06a5f55b..c02fd5c15b 100644 --- a/src/devices/LiquidLevel/LiquidLevelSwitch.cs +++ b/src/devices/LiquidLevel/LiquidLevelSwitch.cs @@ -22,12 +22,11 @@ public class LiquidLevelSwitch : IDisposable /// Creates a new instance of the LiquidLevelSwitch. /// The data pin /// Data pin state representing liquid being present - /// Use the logical or physical pin layout /// A Gpio Controller if you want to use a specific one /// True to dispose the Gpio Controller - public LiquidLevelSwitch(int dataPin, PinValue liquidPresentPinState, GpioController? gpioController = null, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, bool shouldDispose = true) + public LiquidLevelSwitch(int dataPin, PinValue liquidPresentPinState, GpioController? gpioController = null, bool shouldDispose = true) { - _controller = gpioController ?? new GpioController(pinNumberingScheme); + _controller = gpioController ?? new GpioController(); _shouldDispose = shouldDispose || gpioController is null; _dataPin = dataPin; _liquidPresentPinState = liquidPresentPinState; diff --git a/src/devices/LiquidLevel/Llc200d3sh.cs b/src/devices/LiquidLevel/Llc200d3sh.cs index ffa2895355..e1e38e6eb9 100644 --- a/src/devices/LiquidLevel/Llc200d3sh.cs +++ b/src/devices/LiquidLevel/Llc200d3sh.cs @@ -12,11 +12,10 @@ public class Llc200d3sh : LiquidLevelSwitch { /// Creates a new instance of the Llc200d3sh. /// The data pin - /// Use the logical or physical pin layout /// A Gpio Controller if you want to use a specific one /// True to dispose the Gpio Controller - public Llc200d3sh(int pin, GpioController? gpioController = null, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, bool shouldDispose = true) - : base(pin, PinValue.Low, gpioController, pinNumberingScheme, shouldDispose) + public Llc200d3sh(int pin, GpioController? gpioController = null, bool shouldDispose = true) + : base(pin, PinValue.Low, gpioController, shouldDispose) { } } diff --git a/src/devices/Mcp23xxx/samples/Program.cs b/src/devices/Mcp23xxx/samples/Program.cs index 5777a4d19e..723d7c4aa5 100644 --- a/src/devices/Mcp23xxx/samples/Program.cs +++ b/src/devices/Mcp23xxx/samples/Program.cs @@ -13,7 +13,7 @@ Console.WriteLine("Hello Mcp23xxx!"); using Mcp23xxx mcp23xxx = GetMcp23xxxDevice(Mcp23xxxDevice.Mcp23017); -using GpioController controllerUsingMcp = new(PinNumberingScheme.Logical, mcp23xxx); +using GpioController controllerUsingMcp = new(mcp23xxx); // Samples are currently written specifically for the 16 bit variant if (mcp23xxx is Mcp23x1x mcp23x1x) { diff --git a/src/devices/Mcp23xxx/tests/EnableDisableTests.cs b/src/devices/Mcp23xxx/tests/EnableDisableTests.cs index cacb2e7b24..8e8e38b562 100644 --- a/src/devices/Mcp23xxx/tests/EnableDisableTests.cs +++ b/src/devices/Mcp23xxx/tests/EnableDisableTests.cs @@ -11,7 +11,7 @@ namespace Iot.Device.Mcp23xxx.Tests public class EnableDisableTests : Mcp23xxxTest { private static readonly GpioDriverMock s_driverMock = new GpioDriverMock(); - private static readonly GpioController s_gpioMock = new GpioController(PinNumberingScheme.Logical, s_driverMock); + private static readonly GpioController s_gpioMock = new GpioController(s_driverMock); [Theory] [MemberData(nameof(ResetTestDevices))] @@ -85,22 +85,22 @@ public static TheoryData ResetTestDevices // Don't want to use the same bus mock for each I2cDeviceMock i2c = new I2cDeviceMock(1); - devices.Add(new TestDevice(new Mcp23008(i2c, reset: 1, controller: new GpioController(PinNumberingScheme.Logical, s_driverMock)), i2c.DeviceMock)); + devices.Add(new TestDevice(new Mcp23008(i2c, reset: 1, controller: new GpioController(s_driverMock)), i2c.DeviceMock)); i2c = new I2cDeviceMock(1); - devices.Add(new TestDevice(new Mcp23009(i2c, reset: 1, controller: new GpioController(PinNumberingScheme.Logical, s_driverMock)), i2c.DeviceMock)); + devices.Add(new TestDevice(new Mcp23009(i2c, reset: 1, controller: new GpioController(s_driverMock)), i2c.DeviceMock)); i2c = new I2cDeviceMock(2); - devices.Add(new TestDevice(new Mcp23017(i2c, reset: 1, controller: new GpioController(PinNumberingScheme.Logical, s_driverMock)), i2c.DeviceMock)); + devices.Add(new TestDevice(new Mcp23017(i2c, reset: 1, controller: new GpioController(s_driverMock)), i2c.DeviceMock)); i2c = new I2cDeviceMock(2); - devices.Add(new TestDevice(new Mcp23018(i2c, reset: 1, controller: new GpioController(PinNumberingScheme.Logical, s_driverMock)), i2c.DeviceMock)); + devices.Add(new TestDevice(new Mcp23018(i2c, reset: 1, controller: new GpioController(s_driverMock)), i2c.DeviceMock)); SpiDeviceMock spi = new SpiDeviceMock(1); - devices.Add(new TestDevice(new Mcp23s08(spi, 0x20, reset: 1, controller: new GpioController(PinNumberingScheme.Logical, s_driverMock)), spi.DeviceMock)); + devices.Add(new TestDevice(new Mcp23s08(spi, 0x20, reset: 1, controller: new GpioController(s_driverMock)), spi.DeviceMock)); spi = new SpiDeviceMock(1); - devices.Add(new TestDevice(new Mcp23s09(spi, reset: 1, controller: new GpioController(PinNumberingScheme.Logical, s_driverMock)), spi.DeviceMock)); + devices.Add(new TestDevice(new Mcp23s09(spi, reset: 1, controller: new GpioController(s_driverMock)), spi.DeviceMock)); spi = new SpiDeviceMock(2); - devices.Add(new TestDevice(new Mcp23s17(spi, 0x20, reset: 1, controller: new GpioController(PinNumberingScheme.Logical, s_driverMock)), spi.DeviceMock)); + devices.Add(new TestDevice(new Mcp23s17(spi, 0x20, reset: 1, controller: new GpioController(s_driverMock)), spi.DeviceMock)); spi = new SpiDeviceMock(2); - devices.Add(new TestDevice(new Mcp23s18(spi, reset: 1, controller: new GpioController(PinNumberingScheme.Logical, s_driverMock)), spi.DeviceMock)); + devices.Add(new TestDevice(new Mcp23s18(spi, reset: 1, controller: new GpioController(s_driverMock)), spi.DeviceMock)); return devices; } } diff --git a/src/devices/Mcp23xxx/tests/EventHandlingTests.cs b/src/devices/Mcp23xxx/tests/EventHandlingTests.cs index 37392a3fd2..08596b7b31 100644 --- a/src/devices/Mcp23xxx/tests/EventHandlingTests.cs +++ b/src/devices/Mcp23xxx/tests/EventHandlingTests.cs @@ -28,7 +28,7 @@ public EventHandlingTests() _callbackNo = 0; _mockI2c = new I2cDeviceMock(2, null); _driverMock = new GpioDriverMock(); - _gpioController = new GpioController(PinNumberingScheme.Logical, _driverMock); + _gpioController = new GpioController(_driverMock); _device = new Mcp23017(_mockI2c, -1, 11, 22, _gpioController, false); } @@ -42,7 +42,7 @@ public void EnableDisableEvents() [Fact] public void AddEventHandlerPortA() { - GpioController theDeviceController = new GpioController(PinNumberingScheme.Logical, _device); + GpioController theDeviceController = new GpioController(_device); theDeviceController.OpenPin(1, PinMode.Input); theDeviceController.RegisterCallbackForPinValueChangedEvent(1, PinEventTypes.Rising, Callback); @@ -59,7 +59,7 @@ public void AddEventHandlerPortA() [Fact] public void AddEventHandlerPortB() { - GpioController theDeviceController = new GpioController(PinNumberingScheme.Logical, _device); + GpioController theDeviceController = new GpioController(_device); theDeviceController.OpenPin(10, PinMode.Input); theDeviceController.RegisterCallbackForPinValueChangedEvent(10, PinEventTypes.Rising, Callback); @@ -77,7 +77,7 @@ public void AddEventHandlerPortB() public void AddMultipleEventHandlers() { _callbackNo = 0; - GpioController theDeviceController = new GpioController(PinNumberingScheme.Logical, _device); + GpioController theDeviceController = new GpioController(_device); theDeviceController.OpenPin(0, PinMode.Input); theDeviceController.RegisterCallbackForPinValueChangedEvent(0, PinEventTypes.Rising | PinEventTypes.Falling, Callback2); @@ -94,7 +94,7 @@ public void AddMultipleEventHandlers() [Fact] public void AddRemoveEventHandler() { - GpioController theDeviceController = new GpioController(PinNumberingScheme.Logical, _device); + GpioController theDeviceController = new GpioController(_device); theDeviceController.OpenPin(1, PinMode.Input); theDeviceController.RegisterCallbackForPinValueChangedEvent(1, PinEventTypes.Rising, Callback); theDeviceController.UnregisterCallbackForPinValueChangedEvent(1, Callback); diff --git a/src/devices/Mcp23xxx/tests/Mcp23xxxTest.cs b/src/devices/Mcp23xxx/tests/Mcp23xxxTest.cs index 79cf335a80..4d658624aa 100644 --- a/src/devices/Mcp23xxx/tests/Mcp23xxxTest.cs +++ b/src/devices/Mcp23xxx/tests/Mcp23xxxTest.cs @@ -52,7 +52,7 @@ public TestDevice(Mcp23xxx device, Mcp23xxxChipMock chipMock) { Device = device; ChipMock = chipMock; - Controller = new GpioController(PinNumberingScheme.Logical, Device); + Controller = new GpioController(Device); } } diff --git a/src/devices/Nrf24l01/Nrf24l01.cs b/src/devices/Nrf24l01/Nrf24l01.cs index 00ee90acd1..10068c9e91 100644 --- a/src/devices/Nrf24l01/Nrf24l01.cs +++ b/src/devices/Nrf24l01/Nrf24l01.cs @@ -145,11 +145,10 @@ public WorkingMode WorkingMode /// Working Channel /// Output Power /// Send Data Rate - /// Pin Numbering Scheme /// related with operations on pins /// True to dispose the Gpio Controller public Nrf24l01(SpiDevice sensor, int ce, int irq, byte packetSize, byte channel = 2, - OutputPower outputPower = OutputPower.N00dBm, DataRate dataRate = DataRate.Rate2Mbps, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true) + OutputPower outputPower = OutputPower.N00dBm, DataRate dataRate = DataRate.Rate2Mbps, GpioController? gpioController = null, bool shouldDispose = true) { _sensor = sensor ?? throw new ArgumentNullException(nameof(sensor)); _ce = ce; @@ -157,7 +156,7 @@ public Nrf24l01(SpiDevice sensor, int ce, int irq, byte packetSize, byte channel PacketSize = packetSize; _shouldDispose = shouldDispose || gpioController is null; - Initialize(pinNumberingScheme, outputPower, dataRate, channel, gpioController); + Initialize(outputPower, dataRate, channel, gpioController); InitializePipe(); #if !NET5_0_OR_GREATER if (_gpio is null || @@ -263,10 +262,10 @@ private void Irq_ValueChanged(object sender, PinValueChangedEventArgs args) #if NET5_0_OR_GREATER [MemberNotNull(nameof(_gpio))] #endif - private void Initialize(PinNumberingScheme pinNumberingScheme, OutputPower outputPower, DataRate dataRate, byte channel, GpioController? gpioController) + private void Initialize(OutputPower outputPower, DataRate dataRate, byte channel, GpioController? gpioController) { // open pins - _gpio = gpioController ?? new GpioController(pinNumberingScheme); + _gpio = gpioController ?? new GpioController(); _gpio.OpenPin(_ce, PinMode.Output); _gpio.OpenPin(_irq, PinMode.Input); _gpio.RegisterCallbackForPinValueChangedEvent(_irq, PinEventTypes.Falling, Irq_ValueChanged); diff --git a/src/devices/Pcd8544/samples/Program.cs b/src/devices/Pcd8544/samples/Program.cs index 0a7b97ce87..1091676ef8 100644 --- a/src/devices/Pcd8544/samples/Program.cs +++ b/src/devices/Pcd8544/samples/Program.cs @@ -84,7 +84,7 @@ } else { - gpio = new(PinNumberingScheme.Logical, new Ft4222Gpio()); + gpio = new(new Ft4222Gpio()); Ft4222Spi ft4222Spi = new(spiConnection); SoftwarePwmChannel? softPwm = pwmPin >= 0 ? new(pwmPin, 1000, usePrecisionTimer: true, controller: gpio, shouldDispose: false, dutyCycle: 0) : null; lcd = new(dataCommandPin, ft4222Spi, resetPin, softPwm, gpio, false); diff --git a/src/devices/Pcx857x/tests/Pcx857xTest.cs b/src/devices/Pcx857x/tests/Pcx857xTest.cs index 41047f0462..659794d7e4 100644 --- a/src/devices/Pcx857x/tests/Pcx857xTest.cs +++ b/src/devices/Pcx857x/tests/Pcx857xTest.cs @@ -42,7 +42,7 @@ public TestDevice(Pcx857x device, Pcx857xChipMock chipMock) { Device = device; ChipMock = chipMock; - Controller = new GpioController(PinNumberingScheme.Logical, Device); + Controller = new GpioController(Device); } } diff --git a/src/devices/Pn5180/Pn5180.cs b/src/devices/Pn5180/Pn5180.cs index 73f6f8e8ad..b8795432ae 100644 --- a/src/devices/Pn5180/Pn5180.cs +++ b/src/devices/Pn5180/Pn5180.cs @@ -90,7 +90,7 @@ public Pn5180(SpiDevice spiDevice, int pinBusy, int pinNss, GpioController? gpio _logger = this.GetCurrentClassLogger(); _logger.LogDebug($"Opening PN5180, pin busy: {pinBusy}, pin NSS: {pinNss}"); _spiDevice = spiDevice ?? throw new ArgumentNullException(nameof(spiDevice)); - _gpioController = gpioController ?? new GpioController(PinNumberingScheme.Logical); + _gpioController = gpioController ?? new GpioController(); _shouldDispose = shouldDispose || gpioController is null; _pinBusy = pinBusy; _pinNss = pinNss; diff --git a/src/devices/Pn5180/samples/Program.cs b/src/devices/Pn5180/samples/Program.cs index fe6139862f..ee2a2aa07d 100644 --- a/src/devices/Pn5180/samples/Program.cs +++ b/src/devices/Pn5180/samples/Program.cs @@ -124,7 +124,7 @@ Pn5180 Ft4222() Ft4222Spi ftSpi = new Ft4222Spi(new SpiConnectionSettings(0, 1) { ClockFrequency = Pn5180.MaximumSpiClockFrequency, Mode = Pn5180.DefaultSpiMode, DataFlow = DataFlow.MsbFirst }); - GpioController gpioController = new(PinNumberingScheme.Board, new Ft4222Gpio()); + GpioController gpioController = new(new Ft4222Gpio()); // Reset the device gpioController.OpenPin(0, PinMode.Output); diff --git a/src/devices/RGBLedMatrix/RgbLedMatrix.cs b/src/devices/RGBLedMatrix/RgbLedMatrix.cs index a76a0a4896..1425b153de 100644 --- a/src/devices/RGBLedMatrix/RgbLedMatrix.cs +++ b/src/devices/RGBLedMatrix/RgbLedMatrix.cs @@ -65,7 +65,7 @@ public RGBLedMatrix(PinMapping mapping, int width, int height, int chainRows = 1 _deviceRows = height / chainRows; _gpio = new Gpio(mapping, _deviceRows); - _controller = new GpioController(PinNumberingScheme.Logical, _gpio); + _controller = new GpioController(_gpio); OpenAndWriteToPin(_mapping.A, PinValue.Low); OpenAndWriteToPin(_mapping.B, PinValue.Low); diff --git a/src/devices/Seesaw/samples/BlinkingLights/Seesaw.Sample.BlinkingLights.cs b/src/devices/Seesaw/samples/BlinkingLights/Seesaw.Sample.BlinkingLights.cs index c09bc4d91c..aafa821a6a 100644 --- a/src/devices/Seesaw/samples/BlinkingLights/Seesaw.Sample.BlinkingLights.cs +++ b/src/devices/Seesaw/samples/BlinkingLights/Seesaw.Sample.BlinkingLights.cs @@ -29,7 +29,7 @@ using Seesaw seesawDevice = new Seesaw(I2cDevice.Create(new I2cConnectionSettings(1, 0x49))); using SeesawGpioDriver seesawGpioDevice = new SeesawGpioDriver(seesawDevice); -using GpioController controller = new GpioController(PinNumberingScheme.Logical, seesawGpioDevice); +using GpioController controller = new GpioController(seesawGpioDevice); // this line should only be enabled if a trimpot is connected volume = Volume.EnableVolume(seesawDevice); diff --git a/src/devices/Seesaw/samples/Encoder/Seesaw.Sample.Encoder.cs b/src/devices/Seesaw/samples/Encoder/Seesaw.Sample.Encoder.cs index 7df8fc41b3..e38063193f 100644 --- a/src/devices/Seesaw/samples/Encoder/Seesaw.Sample.Encoder.cs +++ b/src/devices/Seesaw/samples/Encoder/Seesaw.Sample.Encoder.cs @@ -13,7 +13,7 @@ const int EncoderPositionInitialValue = 100; const int HostInterruptPin = 6; -using GpioController gpioController = new(PinNumberingScheme.Logical); +using GpioController gpioController = new(); using Seesaw seesawDevice = new(I2cDevice.Create(new I2cConnectionSettings(AdafruitSeesawRotaryEncoderI2cBus, AdafruitSeesawRotaryEncoderI2cAddress))); // set initial encoder position value diff --git a/src/devices/Tm16xx/Tm1637.cs b/src/devices/Tm16xx/Tm1637.cs index f923db5c57..a4b651cf7f 100644 --- a/src/devices/Tm16xx/Tm1637.cs +++ b/src/devices/Tm16xx/Tm1637.cs @@ -121,31 +121,19 @@ public Tm1637(int pinClk, int pinDio, GpioController controller) /// The clock pin. /// The data pin. public Tm1637(int pinClk, int pinDio) - : this(pinClk, pinDio, PinNumberingScheme.Logical, null, true) + : this(pinClk, pinDio, null, true) { } - /// - /// Initializes an instance of TM1637 with new Gpio controller which will be disposed with this object. - /// - /// The clock pin. - /// The data pin. - /// Uses the logical or physical pin layout for new created Gpio controller. - public Tm1637(int pinClk, int pinDio, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical) - : this(pinClk, pinDio, pinNumberingScheme, null, true) - { - } - - /// + /// /// Initializes an instance of TM1637. /// /// The clock pin. /// The data pin. - /// Uses the logical or physical pin layout for new created Gpio controller. /// The instance of the gpio controller. Set to to create a new one. /// Sets to to dispose the Gpio controller with this object. If the is set to , this parameter will be ignored and the new created Gpio controller will always be disposed with this object. - public Tm1637(int pinClk, int pinDio, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true) - : base(pinClk, pinDio, ClockWidthMicroseconds, pinNumberingScheme, gpioController, shouldDispose) + public Tm1637(int pinClk, int pinDio, GpioController? gpioController = null, bool shouldDispose = true) + : base(pinClk, pinDio, ClockWidthMicroseconds, gpioController, shouldDispose) { _maxCharacters = 6; _brightness = 7; diff --git a/src/devices/Tm16xx/Tm1650.cs b/src/devices/Tm16xx/Tm1650.cs index 2c97fa3c6b..43bdaf8a3c 100644 --- a/src/devices/Tm16xx/Tm1650.cs +++ b/src/devices/Tm16xx/Tm1650.cs @@ -113,18 +113,7 @@ public Tm1650(int pinClk, int pinDio, GpioController controller) /// The clock pin. /// The data pin. public Tm1650(int pinClk, int pinDio) - : this(pinClk, pinDio, PinNumberingScheme.Logical, null, true) - { - } - - /// - /// Initializes an instance of TM1650 with new Gpio controller which will be disposed with this object. - /// - /// The clock pin. - /// The data pin. - /// Uses the logical or physical pin layout for new created Gpio controller. - public Tm1650(int pinClk, int pinDio, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical) - : this(pinClk, pinDio, pinNumberingScheme, null, true) + : this(pinClk, pinDio, null, true) { } @@ -133,11 +122,10 @@ public Tm1650(int pinClk, int pinDio, PinNumberingScheme pinNumberingScheme = Pi /// /// The clock pin. /// The data pin. - /// Uses the logical or physical pin layout for new created Gpio controller. /// The instance of the gpio controller. Set to to create a new one. /// Sets to to dispose the Gpio controller with this object. If the is set to , this parameter will be ignored and the new created Gpio controller will always be disposed with this object. - public Tm1650(int pinClk, int pinDio, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true) - : base(pinClk, pinDio, ClockWidthMicroseconds, pinNumberingScheme, gpioController, shouldDispose) + public Tm1650(int pinClk, int pinDio, GpioController? gpioController = null, bool shouldDispose = true) + : base(pinClk, pinDio, ClockWidthMicroseconds, gpioController, shouldDispose) { _maxCharacters = 4; _characterOrder = new byte[4] { 0, 1, 2, 3 }; diff --git a/src/devices/Tm16xx/Tm16xxI2CLikeBase.cs b/src/devices/Tm16xx/Tm16xxI2CLikeBase.cs index 2dd1029dbf..888a4e58e6 100644 --- a/src/devices/Tm16xx/Tm16xxI2CLikeBase.cs +++ b/src/devices/Tm16xx/Tm16xxI2CLikeBase.cs @@ -112,7 +112,7 @@ public override byte ScreenBrightness /// Waiting time between clock up and down. /// The instance of the Gpio controller which will not be disposed with this object. protected Tm16xxI2CLikeBase(int pinClk, int pinDio, int clockWidthMicroseconds, GpioController controller) - : this(pinClk, pinDio, clockWidthMicroseconds, PinNumberingScheme.Logical, controller, false) + : this(pinClk, pinDio, clockWidthMicroseconds, controller, false) { } @@ -123,19 +123,7 @@ protected Tm16xxI2CLikeBase(int pinClk, int pinDio, int clockWidthMicroseconds, /// The data pin. /// Waiting time between clock up and down. protected Tm16xxI2CLikeBase(int pinClk, int pinDio, int clockWidthMicroseconds) - : this(pinClk, pinDio, clockWidthMicroseconds, PinNumberingScheme.Logical, null, true) - { - } - - /// - /// Initializes an instance with new Gpio controller which will be disposed with this object. - /// - /// The clock pin. - /// The data pin. - /// Waiting time between clock up and down. - /// Uses the logical or physical pin layout for new created Gpio controller. - protected Tm16xxI2CLikeBase(int pinClk, int pinDio, int clockWidthMicroseconds, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical) - : this(pinClk, pinDio, clockWidthMicroseconds, pinNumberingScheme, null, true) + : this(pinClk, pinDio, clockWidthMicroseconds, null, true) { } @@ -145,17 +133,15 @@ protected Tm16xxI2CLikeBase(int pinClk, int pinDio, int clockWidthMicroseconds, /// The clock pin. /// The data pin. /// Waiting time between clock up and down. - /// Uses the logical or physical pin layout for new created Gpio controller. /// The instance of the gpio controller. Set to to create a new one. /// Sets to to dispose the Gpio controller with this object. If the is set to , this parameter will be ignored and the new created Gpio controller will always be disposed with this object. protected Tm16xxI2CLikeBase(int pinClk, int pinDio, int clockWidthMicroseconds, - PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, GpioController? gpioController = null, bool shouldDispose = true) { PinClk = pinClk; PinDio = pinDio; _clockWidthMicroseconds = clockWidthMicroseconds; - Controller = gpioController ?? new GpioController(pinNumberingScheme); + Controller = gpioController ?? new GpioController(); _shouldDispose = shouldDispose || gpioController is null; Controller.OpenPin(pinClk, PinMode.Output); Controller.OpenPin(pinDio, PinMode.Output); diff --git a/tools/ArduinoCsCompiler/Hal/ArduinoNativeBoard.cs b/tools/ArduinoCsCompiler/Hal/ArduinoNativeBoard.cs index d31f6f1d8f..7a1211fe89 100644 --- a/tools/ArduinoCsCompiler/Hal/ArduinoNativeBoard.cs +++ b/tools/ArduinoCsCompiler/Hal/ArduinoNativeBoard.cs @@ -63,7 +63,7 @@ public override int GetDefaultI2cBusNumber() public override GpioController CreateGpioController() { - return new GpioController(PinNumberingScheme.Logical, new ArduinoNativeGpioDriver()); + return new GpioController(new ArduinoNativeGpioDriver()); } protected override SpiDevice CreateSimpleSpiDevice(SpiConnectionSettings settings, int[] pins) diff --git a/tools/ArduinoCsCompiler/tests/ArduinoNativeLibraryTest.cs b/tools/ArduinoCsCompiler/tests/ArduinoNativeLibraryTest.cs index 02d4fcb19d..6a483edf55 100644 --- a/tools/ArduinoCsCompiler/tests/ArduinoNativeLibraryTest.cs +++ b/tools/ArduinoCsCompiler/tests/ArduinoNativeLibraryTest.cs @@ -54,7 +54,7 @@ public SimpleLedBinding(GpioController controller, int pin, int delay) public static int RunBlink(int pin, int delay) { - var gpioController = new GpioController(PinNumberingScheme.Logical, new ArduinoNativeGpioDriver()); + var gpioController = new GpioController(new ArduinoNativeGpioDriver()); SimpleLedBinding blink = new SimpleLedBinding(gpioController, pin, delay); blink.Loop(); return 1; diff --git a/tools/DevicesApiTester/Commands/Gpio/GpioBlinkLed.cs b/tools/DevicesApiTester/Commands/Gpio/GpioBlinkLed.cs index 071b0c7e66..e6cccda0b4 100644 --- a/tools/DevicesApiTester/Commands/Gpio/GpioBlinkLed.cs +++ b/tools/DevicesApiTester/Commands/Gpio/GpioBlinkLed.cs @@ -41,7 +41,7 @@ public async Task ExecuteAsync() OnValue = 1; } - Console.WriteLine($"Driver={Driver}, Scheme={Scheme}, LedPin ={LedPin}, Count={Count}, TimeOn={TimeOn} ms, TimeOff={TimeOff} ms"); + Console.WriteLine($"Driver={Driver}, LedPin ={LedPin}, Count={Count}, TimeOn={TimeOn} ms, TimeOff={TimeOff} ms"); using (GpioController controller = CreateGpioController()) { diff --git a/tools/DevicesApiTester/Commands/Gpio/GpioButtonEvent.cs b/tools/DevicesApiTester/Commands/Gpio/GpioButtonEvent.cs index 61971541d3..e07007784f 100644 --- a/tools/DevicesApiTester/Commands/Gpio/GpioButtonEvent.cs +++ b/tools/DevicesApiTester/Commands/Gpio/GpioButtonEvent.cs @@ -41,17 +41,17 @@ public Task ExecuteAsync() if (LedPin != null) { - Console.WriteLine($"Driver={Driver}, Scheme={Scheme}, ButtonPin={ButtonPin}, LedPin={LedPin}, PressedValue={PressedValue}, OnValue={OnValue}"); + Console.WriteLine($"Driver={Driver}, ButtonPin={ButtonPin}, LedPin={LedPin}, PressedValue={PressedValue}, OnValue={OnValue}"); } else { - Console.WriteLine($"Driver={Driver}, Scheme={Scheme}, ButtonPin={ButtonPin}, PressedValue={PressedValue}, OnValue={OnValue}"); + Console.WriteLine($"Driver={Driver}, ButtonPin={ButtonPin}, PressedValue={PressedValue}, OnValue={OnValue}"); } using GpioController controller = CreateGpioController(); using var cancelEvent = new ManualResetEvent(false); int count = 0; - Console.WriteLine($"Listening for button presses on GPIO {Enum.GetName(typeof(PinNumberingScheme), Scheme)} pin {ButtonPin} . . ."); + Console.WriteLine($"Listening for button presses on GPIO pin {ButtonPin} . . ."); // This example runs until Ctrl+C (or Ctrl+Break) is pressed, so register a local function handler. Console.CancelKeyPress += Console_CancelKeyPress; diff --git a/tools/DevicesApiTester/Commands/Gpio/GpioButtonWait.cs b/tools/DevicesApiTester/Commands/Gpio/GpioButtonWait.cs index 621358c71a..10f08e99f6 100644 --- a/tools/DevicesApiTester/Commands/Gpio/GpioButtonWait.cs +++ b/tools/DevicesApiTester/Commands/Gpio/GpioButtonWait.cs @@ -36,16 +36,16 @@ public async Task ExecuteAsync() { if (LedPin != null) { - Console.WriteLine($"Driver={Driver}, Scheme={Scheme}, ButtonPin={ButtonPin}, LedPin={LedPin}, PressedValue={PressedValue}, OnValue={OnValue}"); + Console.WriteLine($"Driver={Driver}, ButtonPin={ButtonPin}, LedPin={LedPin}, PressedValue={PressedValue}, OnValue={OnValue}"); } else { - Console.WriteLine($"Driver={Driver}, Scheme={Scheme}, ButtonPin={ButtonPin}, PressedValue={PressedValue}, OnValue={OnValue}"); + Console.WriteLine($"Driver={Driver}, ButtonPin={ButtonPin}, PressedValue={PressedValue}, OnValue={OnValue}"); } using GpioController controller = CreateGpioController(); using CancellationTokenSource cancellationTokenSource = new(); - Console.WriteLine($"Listening for button presses on GPIO {Enum.GetName(typeof(PinNumberingScheme), Scheme)} pin {ButtonPin} . . ."); + Console.WriteLine($"Listening for button presses on GPIO pin {ButtonPin} . . ."); // This example runs until Ctrl+C (or Ctrl+Break) is pressed, so register a local function handler. Console.CancelKeyPress += Console_CancelKeyPress; @@ -71,7 +71,7 @@ public async Task ExecuteAsync() if (!waitResult.TimedOut) { var pressedOrReleased = waitResult.EventTypes == PressedValue ? "pressed" : "released"; - Console.WriteLine($"[{count++}] Button {pressedOrReleased}: GPIO {Enum.GetName(typeof(PinNumberingScheme), Scheme)} pin number {ButtonPin}, ChangeType={waitResult.EventTypes}"); + Console.WriteLine($"[{count++}] Button {pressedOrReleased}: GPIO pin number {ButtonPin}, ChangeType={waitResult.EventTypes}"); if (LedPin != null) { diff --git a/tools/DevicesApiTester/Commands/Gpio/GpioCommand.cs b/tools/DevicesApiTester/Commands/Gpio/GpioCommand.cs index e566640f9b..89cf108ea7 100644 --- a/tools/DevicesApiTester/Commands/Gpio/GpioCommand.cs +++ b/tools/DevicesApiTester/Commands/Gpio/GpioCommand.cs @@ -9,9 +9,6 @@ namespace DeviceApiTester.Commands.Gpio { public abstract class GpioCommand : DebuggableCommand { - [Option('s', "scheme", HelpText = "The pin numbering scheme: { Logical | Board }", Required = false, Default = PinNumberingScheme.Logical)] - public PinNumberingScheme Scheme { get; set; } - [Option('d', "driver", HelpText = "The GpioDriver to use: { Default | Windows | UnixSysFs | HummingBoard | RPi3 }", Required = false, Default = GpioDriverType.Default)] public GpioDriverType Driver { get; set; } @@ -20,8 +17,8 @@ protected GpioController CreateGpioController() GpioDriver? gpioDriver = DriverFactory.CreateFromEnum(Driver); return gpioDriver != null - ? new GpioController(Scheme, gpioDriver) - : new GpioController(Scheme); + ? new GpioController(gpioDriver) + : new GpioController(); } } } diff --git a/tools/DevicesApiTester/Commands/Gpio/GpioReadPin.cs b/tools/DevicesApiTester/Commands/Gpio/GpioReadPin.cs index 8f979e6598..b4b5d35c80 100644 --- a/tools/DevicesApiTester/Commands/Gpio/GpioReadPin.cs +++ b/tools/DevicesApiTester/Commands/Gpio/GpioReadPin.cs @@ -23,7 +23,7 @@ public class GpioReadPin : GpioCommand, ICommandVerb /// public int Execute() { - Console.WriteLine($"Driver={Driver}, Scheme={Scheme}, Pin={Pin}"); + Console.WriteLine($"Driver={Driver}, Pin={Pin}"); using (GpioController controller = CreateGpioController()) { diff --git a/tools/DevicesApiTester/Commands/Gpio/GpioWritePin.cs b/tools/DevicesApiTester/Commands/Gpio/GpioWritePin.cs index e6cb89f3c2..84e8855b86 100644 --- a/tools/DevicesApiTester/Commands/Gpio/GpioWritePin.cs +++ b/tools/DevicesApiTester/Commands/Gpio/GpioWritePin.cs @@ -26,7 +26,7 @@ public class GpioWritePin : GpioCommand, ICommandVerb /// public int Execute() { - Console.WriteLine($"Driver={Driver}, Scheme={Scheme}, Pin={Pin}, Value={Value}"); + Console.WriteLine($"Driver={Driver}, Pin={Pin}, Value={Value}"); using (GpioController controller = CreateGpioController()) {