private void InitGpio() { var gpio = GpioController.GetDefault(); if (gpio == null) { _gpio18 = null; _gpio23 = null; return; } _gpio18 = gpio.OpenPin(18); _gpio23 = gpio.OpenPin(23); if (_gpio18 == null || _gpio23 == null) { return; } _gpio18.SetDriveMode(GpioPinDriveMode.Output); _gpio23.SetDriveMode(GpioPinDriveMode.Output); ThreadPoolTimer.CreatePeriodicTimer(TimerOnTick, TimeSpan.FromMilliseconds(500)); }
private void MainPage_Loaded(object sender, RoutedEventArgs e) { // GPIOの初期化 RPi.gpio = GpioController.GetDefault(); if (RPi.gpio != null) { motorLeft = new Motor(23, 24); motorRight = new Motor(27, 22); /// 停止状態 motorLeft.Direction = 0; motorRight.Direction = 0; // LED led = new Led(4); led.Off(); } this.KeyLFront.PointerPressed += Key_PointerPressed; this.KeyLBack.PointerPressed += Key_PointerPressed; this.KeyRFront.PointerPressed += Key_PointerPressed; this.KeyRBack.PointerPressed += Key_PointerPressed; this.sw1.Toggled += Sw1_Toggled; // バインド _model = new DataModel(); this.DataContext = _model; }
public Temperature() { var pin = GpioController.GetDefault().OpenPin(4, GpioSharingMode.Exclusive); Dht = new Dht11(pin, GpioPinDriveMode.Input); _timer.Tick += (sender, o) => { // Get Temperature and Humidity Reading GetReading(); }; _timer.Interval = TimeSpan.FromSeconds(1); _timer.Start(); try { _deviceClient = DeviceClient.Create(iotHubUri, new DeviceAuthenticationWithRegistrySymmetricKey(deviceName, deviceKey), TransportType.Http1); } catch (Exception) { //nothing } }
public TallyHandler(UDPDuplex behringer, GpioController controller, TallySetting tallySetting) { var levelPathBuilder = new StringBuilder(); levelPathBuilder.Append("/ch/"); levelPathBuilder.Append(tallySetting.channel.ToString("D2")); levelPathBuilder.Append("/mix/fader"); levelPath = levelPathBuilder.ToString(); var mutePathBuilder = new StringBuilder(); mutePathBuilder.Append("/ch/"); mutePathBuilder.Append(tallySetting.channel.ToString("D2")); mutePathBuilder.Append("/mix/on"); mutePath = mutePathBuilder.ToString(); level = 0; muted = true; this.tallySetting = tallySetting; this.behringer = behringer; this.controller = controller; try { controller.OpenPin(tallySetting.gpio, PinMode.Output); } catch (Exception e) { log.Info(e, $"Could not connect to pin {tallySetting.gpio}"); throw; } behringer.OscPacketCallback += Callback; ForceUpdate(); }
/// <summary> /// Dispose the sensor /// </summary> public void Dispose() { _running = false; while (_isRunning) { Thread.Sleep(1); } if (_pinInterruption >= 0) { _controller.UnregisterCallbackForPinValueChangedEvent(_pinInterruption, InterruptReady); } if (_shouldDispose) { _controller?.Dispose(); _controller = null; } else { if (_pinInterruption >= 0) { _controller.ClosePin(_pinInterruption); } if (_pinReset >= 0) { _controller.ClosePin(_pinReset); } if (_pinWake >= 0) { _controller.ClosePin(_pinWake); } } }
private static void Spi_Pressure_Lcd(GpioDriver driver) { const int registerSelectPinNumber = 0; const int enablePinNumber = 5; const int chipSelectLinePinNumber = 8; int[] dataPinNumbers = { 6, 16, 20, 21 }; using (var controller = new GpioController(driver)) { GpioPin registerSelectPin = controller.OpenPin(registerSelectPinNumber); GpioPin enablePin = controller.OpenPin(enablePinNumber); GpioPin[] dataPins = controller.OpenPins(dataPinNumbers); var lcd = new LcdController(registerSelectPin, enablePin, dataPins); lcd.Begin(16, 2); GpioPin chipSelectLinePin = controller.OpenPin(chipSelectLinePinNumber); var settings = new SpiConnectionSettings(s_spiBusId, 0); var sensor = new PressureTemperatureHumiditySensor(chipSelectLinePin, settings); Pressure_Lcd(lcd, sensor); } }
private void initGPIO() { var gpio = GpioController.GetDefault(); buttonGPIO = gpio.OpenPin(buttonPin); // Check if input pull-up resistors are supported if (buttonGPIO.IsDriveModeSupported(GpioPinDriveMode.InputPullUp)) { buttonGPIO.SetDriveMode(GpioPinDriveMode.InputPullUp); } else { buttonGPIO.SetDriveMode(GpioPinDriveMode.Input); } // Set a debounce timeout to filter out switch bounce noise from a button press buttonGPIO.DebounceTimeout = TimeSpan.FromMilliseconds(50); // Register for the ValueChanged event so our buttonPin_ValueChanged // function is called when the button is pressed buttonGPIO.ValueChanged += buttonPin_ValueChanged; }
public TinyBitController(I2cController i2cController, PwmChannel buzzer, AdcChannel voiceSensor, GpioPin leftLineSensor, GpioPin rightLineSensor, GpioPin distanceTrigger, GpioPin distanceEcho, int colorLedPin) { this.i2c = i2cController.GetDevice(new I2cConnectionSettings(0x01, 400_000)); this.buzzer = buzzer; this.voiceSensor = voiceSensor; this.leftLineSensor = leftLineSensor; this.leftLineSensor.SetDriveMode(GpioPinDriveMode.Input); this.rightLineSensor = rightLineSensor; this.rightLineSensor.SetDriveMode(GpioPinDriveMode.Input); var sg = new SignalGenerator(GpioController.GetDefault().OpenPin(colorLedPin)); this.ws2812 = new WS2812Controller(sg, 2); this.distanceEcho = distanceEcho; this.distanceTrigger = distanceTrigger; this.pulseFeedback = new PulseFeedback(this.distanceTrigger, this.distanceEcho, PulseFeedbackMode.EchoDuration) { DisableInterrupts = false, Timeout = TimeSpan.FromSeconds(1), PulseLength = TimeSpan.FromTicks(100), PulseValue = GpioPinValue.High, EchoValue = GpioPinValue.High, }; }
public void Run(IBackgroundTaskInstance taskInstance) { GpioController gpioController = GpioController.GetDefault(); GpioPin chipSelectGpioPin = null; chipSelectGpioPin = gpioController.OpenPin(25); // DIY CS for Dragino if (chipSelectGpioPin != null) { chipSelectGpioPin.SetDriveMode(GpioPinDriveMode.Output); chipSelectGpioPin.Write(GpioPinValue.High); } SpiController spiController = SpiController.GetDefaultAsync().AsTask().GetAwaiter().GetResult(); var settings = new SpiConnectionSettings(0) // Unused pin which shouldn't intefer { ClockFrequency = 500000, Mode = SpiMode.Mode0, // From SemTech docs pg 80 CPOL=0, CPHA=0 }; SpiDevice Device = spiController.GetDevice(settings); while (true) { byte[] writeBuffer = new byte[] { 0x42 }; // RegVersion byte[] readBuffer = new byte[1]; chipSelectGpioPin.Write(GpioPinValue.Low); Device.TransferSequential(writeBuffer, readBuffer); chipSelectGpioPin.Write(GpioPinValue.High); byte registerValue = readBuffer[0]; Debug.WriteLine("Register 0x{0:x2} - Value 0X{1:x2} - Bits {2}", 0x42, registerValue, Convert.ToString(registerValue, 2).PadLeft(8, '0')); Thread.Sleep(10000); } }
public static void Main() { // L3GD20 MEMS gyroscope in STM32F429 DISCOVERY board is connected to SPI5... // ... and its chip select it's connected to PC1 _gyro = new L3GD20("SPI5", GpioController.GetDefault().OpenPin(PinNumber('C', 1))); // initialize L3GD20 _gyro.Initialize(); // output the ID and revision of the device Console.WriteLine("ChipID " + _gyro.ChipID.ToString("X2")); // infinite loop to keep main thread active for (; ;) { Thread.Sleep(1000); var readings = _gyro.GetXYZ(); Console.WriteLine("X: " + readings[0]); Console.WriteLine("Y: " + readings[1]); Console.WriteLine("Z: " + readings[2]); } }
private void InitGPIO() { var gpio = GpioController.GetDefault(); // Show an error if there is no GPIO controller if (gpio == null) { //GpioStatus.Text = "There is no GPIO controller on this device."; return; } doorSensor = gpio.OpenPin(DOOR_PIN); pinTrigger = gpio.OpenPin(TRIGGER_PIN); pinEcho = gpio.OpenPin(ECHO_PIN); relayPin = gpio.OpenPin(RELAY_PIN); relayPin.Write(GpioPinValue.Low); relayPin.SetDriveMode(GpioPinDriveMode.Output); doorSensor.SetDriveMode(GpioPinDriveMode.InputPullUp); pinTrigger.SetDriveMode(GpioPinDriveMode.Output); pinEcho.SetDriveMode(GpioPinDriveMode.Input); pinTrigger.Write(GpioPinValue.Low); doorSensor.ValueChanged += DoorSensor_ValueChanged; }
/// <summary> /// Configures the <see cref="HardwareProvider"/>. /// </summary> /// <remarks> /// Not thread safe, must be called in a thread safe context. /// </remarks> public static void Initialize() { // Do nothing when already configured if (_initialized) { return; } lock (_lock) { // Thread-safe double-check lock if (_initialized) { return; } //Spi = SpiController.GetDefault(); Gpio = GpioController.GetDefault(); //Uart = UartController.GetDefault(); // Flag initialized _initialized = true; } }
public MuteGroupHandler(UDPDuplex behringer, GpioController controller, MuteGroupSetting muteGroupSetting) { this.muteGroupSetting = muteGroupSetting; this.behringer = behringer; this.controller = controller; var mutePathBuilder = new StringBuilder(); mutePathBuilder.Append("/config/mute/"); mutePathBuilder.Append(muteGroupSetting.group.ToString("D1")); mutePath = mutePathBuilder.ToString(); try { controller.OpenPin(muteGroupSetting.gpio, PinMode.InputPullUp); controller.RegisterCallbackForPinValueChangedEvent(muteGroupSetting.gpio, PinEventTypes.Falling, MuteEnabled); controller.RegisterCallbackForPinValueChangedEvent(muteGroupSetting.gpio, PinEventTypes.Rising, MuteDisabled); } catch (Exception e) { log.Info(e, $"Could not connect to pin {muteGroupSetting.gpio}"); throw; } }
private static void OnPinValueChanged2(object sender, PinValueChangedEventArgs e) { const int ledPinNumber = 26; s_currentLedValue = s_currentLedValue == PinValue.High ? PinValue.Low : PinValue.High; Console.WriteLine($"Button pressed! Led value {s_currentLedValue}"); if (sender is GpioDriver) { GpioDriver driver = sender as GpioDriver; driver.Output(ledPinNumber, s_currentLedValue); } else if (sender is Pin) { Pin button = sender as Pin; GpioController controller = button.Controller; Pin led = controller[ledPinNumber]; led.Write(s_currentLedValue); } else { throw new ArgumentException(nameof(sender)); } }
/// <summary> /// Constructs a new <see cref="AquaGPIO"/> object by initialzing the gpio pins for the raspberry pi /// </summary> public AquaGPIO() { _timer_fill = new DispatcherTimer(); _timer_fill.Interval = TimeSpan.FromSeconds(15); _timer_fill.Tick += Timer_fill_Tick; _timer_drain = new DispatcherTimer(); _timer_drain.Interval = TimeSpan.FromSeconds(15); _timer_drain.Tick += Timer_drain_Tick; _timer_pumpOnDelay = new Timer(_timer_pumpOnDelay_Tick, null, Timeout.Infinite, Timeout.Infinite); _timer_pumpOffDelay = new Timer(_timer_pumpOffDelay_Tick, null, Timeout.Infinite, Timeout.Infinite); GpioController gpio = GpioController.GetDefault(); // Below are the separate pins being used from the raspberry pi and how they are setup // need to assign pins, values, and driver output _pumppinValue = GpioPinValue.High; InitializePin(gpio, out _pumpPin, _pumpPinID); InitializePin(gpio, out _fillPin, _fillPinID); InitializePin(gpio, out _wastePin, _wastePinID); InitializePin(gpio, out _inPin, _inPinID); InitializePin(gpio, out _outPin, _outPinID); InitializePin(gpio, out _inPin1, _in1ID); InitializePin(gpio, out _inPin2, _in2ID); InitializePin(gpio, out _inPin3, _in3ID); InitializePin(gpio, out _inPin4, _in4ID); }
private void InitGpio() { var gpio = GpioController.GetDefault(); if (gpio == null) { throw new Exception("此設備上沒有GPIO控制器"); } else { pin26 = gpio.OpenPin(26); pin26.SetDriveMode(GpioPinDriveMode.Output); pin26.Write(GpioPinValue.Low); pin = 0; pin13 = gpio.OpenPin(13); pin13.SetDriveMode(GpioPinDriveMode.Output); pin13.Write(GpioPinValue.Low); pin2 = 0; pin19 = gpio.OpenPin(19); pin19.SetDriveMode(GpioPinDriveMode.Output); pin19.Write(GpioPinValue.Low); pin3 = 0; } }
public static async Task <GpioPin> Initialize(int gpioPinNumber) { Debug.WriteLine("GPIOSlave::Initialize on GPIO-Pin: " + gpioPinNumber); GpioPin gpioPin = null; try { gpio = GpioController.GetDefault(); if (gpio == null) { Debug.WriteLine("There is no GPIO controller on this device."); return(null); } gpioPin = gpio.OpenPin(gpioPinNumber); } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } return(gpioPin); }
/// <summary> /// Enable normal mode. /// Requires use of GPIO controller. /// </summary> public void EnableNormalMode() { if (GpioController is null || _pinMapping.Clk < 0 || _pinMapping.OE < 0 || _pinMapping.LE < 0) { throw new Exception($"{nameof(EnableDetectionMode)}: GpioController was not provided or {nameof(_pinMapping.Clk)}, {nameof(_pinMapping.LE)}, or {nameof(_pinMapping.OE)} not mapped to pin"); } /* Required timing waveform * 1 2 3 4 5 * CLK _↑‾|_↑‾|_↑‾|_↑‾|_↑‾| * * OE ‾‾‾|___|‾‾‾‾‾‾‾‾‾‾‾‾ * 1 0 1 1 1 * LE ____________________ * 0 0 0 0 0 */ ChangeModeSignal(1, 0); ChangeModeSignal(0, 0); ChangeModeSignal(1, 0); ChangeModeSignal(1, 0); ChangeModeSignal(1, 0); GpioController.Write(_pinMapping.OE, 0); }
static void Main(string[] args) { var ledPin = 21; var controller = new GpioController(); controller.OpenPin(ledPin, PinMode.Output); int lightTimeInMs = 500; int dimTimeInMs = 200; while (true) { Console.WriteLine($"LED1 on for {lightTimeInMs}ms"); // turn on the LED controller.Write(ledPin, PinValue.Low); Thread.Sleep(lightTimeInMs); Console.WriteLine($"LED1 off for {dimTimeInMs}ms"); // turn off the LED controller.Write(ledPin, PinValue.High); Thread.Sleep(dimTimeInMs); } }
public PushButton(int pinNumber, ButtonType type = ButtonType.PullDown) { controller = GpioController.GetDefault(); pin = controller.OpenPin(pinNumber); if (type == ButtonType.PullUp) { actualHighPinValue = GpioPinValue.High; actualLowPinValue = GpioPinValue.Low; } else { actualHighPinValue = GpioPinValue.Low; actualLowPinValue = GpioPinValue.High; } pin.Write(actualLowPinValue); pin.SetDriveMode(GpioPinDriveMode.Input); lastPinValue = actualLowPinValue; pin.DebounceTimeout = TimeSpan.FromMilliseconds(20); pin.ValueChanged += Pin_ValueChanged; }
//public event DeviceStartedEvent OnDeviceStartedEvent; //public event CommandResponseEvent OnCommandResponseEvent; public BlepModule(int resetPin, int reqnPin, int rdyPin, int activatePin, int misoPin, int mosiPin, int sckPin, int dummyPin) { _setupIndex = 0; GpioController controller = GpioController.GetDefault(); _reset = controller.OpenPin(resetPin); _reset.SetDriveMode(GpioPinDriveMode.Output); _reset.Write(GpioPinValue.High); _reqn = controller.OpenPin(reqnPin); _reqn.SetDriveMode(GpioPinDriveMode.Output); _reqn.Write(GpioPinValue.High); _rdy = controller.OpenPin(rdyPin); _rdy.SetDriveMode(GpioPinDriveMode.InputPullUp); _activate = controller.OpenPin(activatePin); _activate.SetDriveMode(GpioPinDriveMode.InputPullUp); SpiSoftwareProvider spp = new SpiSoftwareProvider(misoPin, mosiPin, sckPin); var controllers = SpiController.GetControllers(spp); _spi = controllers[0].GetDevice(new SpiConnectionSettings(dummyPin) { ClockFrequency = 100000, DataBitLength = 8, Mode = SpiMode.Mode0, SharingMode = SpiSharingMode.Exclusive }); // Reset device State = Nrf8001State.Unknown; Reset(); _rdy.ValueChanged += _rdy_ValueChanged; Debug.WriteLine("RDY value: " + (_rdy.Read() == GpioPinValue.High ? "1" : "0")); }
private void InitGpio() { var gpio = GpioController.GetDefault(); if (gpio == null) { _gpio23 = null; _gpio24 = null; return; } _gpio23 = gpio.OpenPin(23); _gpio24 = gpio.OpenPin(24); if (_gpio23 == null || _gpio24 == null) { return; } _gpio23.SetDriveMode(GpioPinDriveMode.Input); // Pullup-Wiederstand an GPIO Pin ausschalten _gpio24.SetDriveMode(GpioPinDriveMode.Output); ThreadPoolTimer.CreatePeriodicTimer(TimerOnTick, TimeSpan.FromMilliseconds(200)); }
public MainPage() { this.InitializeComponent(); GpioController = GpioController.GetDefault(); if (null != GpioController) { ReedPin = GpioController.OpenPin(5); ReedPin.SetDriveMode(GpioPinDriveMode.Input); ReedPin.ValueChanged += (sender, args) => { if (ReedPin.Read() == GpioPinValue.Low) { IsLightOn = !IsLightOn; LedPin.Write(IsLightOn ? GpioPinValue.Low : GpioPinValue.High); } }; LedPin = GpioController.OpenPin(6); LedPin.SetDriveMode(GpioPinDriveMode.Output); LedPin.Write(GpioPinValue.High); } }
public void StartBlinking(int neededQuantity) { if (_blinkTask != null) { return; } _tokenSource = new CancellationTokenSource(); _token = _tokenSource.Token; _blinkTask = new Task(() => { using (var controller = new GpioController(PinNumberingScheme.Board)) { controller.OpenPin(LedPin, PinMode.Output); _isBlinking = true; Console.WriteLine("Entered custom"); while (true) { if (_token.IsCancellationRequested) { break; } Console.WriteLine("Drop quantity " + neededQuantity); controller.Write(LedPin, PinValue.Low); Thread.Sleep(neededQuantity); controller.Write(LedPin, PinValue.High); Thread.Sleep(neededQuantity); } _isBlinking = false; } }); _blinkTask.Start(); }
static void Main() { var adcController = AdcController.FromName(SC20100.AdcChannel.Controller1.Id); var adcChannel = adcController.OpenChannel(SC20100.AdcChannel.Controller1.PA0); var strobePin = GpioController.GetDefault().OpenPin(SC20100.GpioPin.PE1); var resetPin = GpioController.GetDefault().OpenPin(SC20100.GpioPin.PE0); var msgeq7 = new Msgeq7(adcChannel, strobePin, resetPin); InitializeSPIDisplay(); while (true) { msgeq7.UpdateBands(); DrawEqualizer(msgeq7.Data); GC.Collect(); GC.WaitForPendingFinalizers(); } }
static void Main() { _buzzer = new GHIElectronics.TinyCLR.BrainPad.Buzzer(); //Setup wifi and remote computer connection _connection = new Connection { SSID = "MOTOROLA-3258C", Password = "******", Target = "192.168.0.6" }; //_connection = new Connection { SSID = "K7 8181", Password = "******", Target = "192.168.43.133" }; GpioController gpioController = GpioController.GetDefault(); var display = new GHIElectronics.TinyCLR.BrainPad.Display(); display.DrawSmallText(0, 0, "Hi there!"); display.RefreshScreen(); _pin1 = gpioController.OpenPin(BrainPad.Expansion.GpioPin.Int); _pin1.SetDriveMode(GpioPinDriveMode.Output); _pin1.Write(GpioPinValue.Low); _pins.Add(_pin1); InitializeButtonComponents(gpioController); GpioPin CH_PD = gpioController.OpenPin(BrainPad.Expansion.GpioPin.Cs); InitializeEsp8266Wifi(display, CH_PD); _buzzer.Beep(); Thread.Sleep(-1); }
/// <summary> /// Internal cleanup. /// </summary> /// <param name="disposing">Disposing.</param> protected override void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { _gpioController.UnregisterCallbackForPinValueChangedEvent(_buttonPin, PinStateChanged); if (_shouldDispose) { _gpioController?.Dispose(); _gpioController = null !; } else { _gpioController.ClosePin(_buttonPin); } } base.Dispose(disposing); _disposed = true; }
internal async Task InitIO() { try { IoController = GpioController.GetDefault(); _resetPowerDown = IoController.OpenPin(RESET_PIN); _resetPowerDown.Write(GpioPinValue.High); _resetPowerDown.SetDriveMode(GpioPinDriveMode.Output); } /* If initialization fails, throw an exception */ catch (Exception ex) { throw new Exception("GPIO initialization failed", ex); } try { var settings = new SpiConnectionSettings(SPI_CHIP_SELECT_LINE); settings.ClockFrequency = 1000000; settings.Mode = SpiMode.Mode0; String spiDeviceSelector = SpiDevice.GetDeviceSelector(); IReadOnlyList <DeviceInformation> devices = await DeviceInformation.FindAllAsync(spiDeviceSelector); _spi = await SpiDevice.FromIdAsync(devices[0].Id, settings); } /* If initialization fails, display the exception and stop running */ catch (Exception ex) { throw new Exception("SPI Initialization Failed", ex); } Reset(); }
/// <summary> /// Instantiates a GPIO pin which can be switched on or off. /// See <a href="https://docs.microsoft.com/en-us/windows/iot-core/learn-about-hardware/pinmappings/pinmappingsrpi#gpio-pin-overview"> see Raspberry Pi3 pin-mappings</a> for list of pins and their default pull-direction (0-8 up, 9-27 down). /// </summary> /// <param name="gpioNumber">This is GPIO number (not physical pin number). Default pull-direction for Raspberry Pi: 0-8 up, 9-27 down.</param> /// <param name="driveMode">If pin should be configured for input or output</param> /// <param name="setInitialValueHigh">Sets the initial state for the pin. Default is Low</param> public PhysicalGpioPin(int gpioNumber, GpioPinDriveMode driveMode, bool setInitialValueHigh = false) { try { PinNumber = gpioNumber; _gpioPin = GpioController.GetDefault().OpenPin(PinNumber); _gpioPin.Write(setInitialValueHigh ? GpioPinValue.High : GpioPinValue.Low); _gpioPin.SetDriveMode(driveMode); _isInputPin = driveMode == GpioPinDriveMode.Input || driveMode == GpioPinDriveMode.InputPullUp || driveMode == GpioPinDriveMode.InputPullDown; ErrorWhenOpeningPin = false; if (_isInputPin) { _gpioPin.ValueChanged += ValueChangedOnInputPin; } } catch (Exception e) { ErrorWhenOpeningPin = true; _exceptionWhenOpeningPin = e; } }
private static Pn5180 Ft4222() { var devices = FtCommon.GetDevices(); Console.WriteLine($"{devices.Count} FT4222 elements found"); foreach (var device in devices) { Console.WriteLine($" Description: {device.Description}"); Console.WriteLine($" Flags: {device.Flags}"); Console.WriteLine($" Id: {device.Id}"); Console.WriteLine($" Location Id: {device.LocId}"); Console.WriteLine($" Serial Number: {device.SerialNumber}"); Console.WriteLine($" Device type: {device.Type}"); Console.WriteLine(); } var(chip, dll) = FtCommon.GetVersions(); Console.WriteLine($"Chip version: {chip}"); Console.WriteLine($"Dll version: {dll}"); 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()); // REset the device gpioController.OpenPin(0, PinMode.Output); gpioController.Write(0, PinValue.Low); Thread.Sleep(10); gpioController.Write(0, PinValue.High); Thread.Sleep(10); return(new Pn5180(ftSpi, 2, 3, gpioController, true)); }
public Led(GpioController gpio, int PinNumber, bool StartOn) { PinId = PinNumber; Pin = gpio.OpenPin(PinId); Pin.Write(StartOn ? GpioPinValue.Low : GpioPinValue.High); Pin.SetDriveMode(GpioPinDriveMode.Output); }