public MainPageViewModel() { var pins = new List <GpioPin>(); gpioController = GpioController.GetDefault(); //Inicializa 15 pinos for (int i = 2; i <= 13; i++) { var pin = gpioController?.OpenPin(i); pin?.SetDriveMode(GpioPinDriveMode.Output); pins.Add(pin); } for (int i = 17; i <= 18; i++) { var pin = gpioController?.OpenPin(i); pin?.SetDriveMode(GpioPinDriveMode.Output); pins.Add(pin); } var pin20 = gpioController?.OpenPin(20); pin20?.SetDriveMode(GpioPinDriveMode.Output); pins.Add(pin20); CarroPins = pins.Take(3).ToViewModelArray(); //Pins 0-2 PedestrePins = pins.Skip(3).Take(2).ToViewModelArray(); //Pins 3-4 DisplayPins = pins.Skip(5).Take(7).ToViewModelArray(); //Pins 5-11 DisplayControlPins = pins.Skip(12).Take(2).ToViewModelArray(); //Pins 12-13 ScreenDigit1Pins = new GpioPin[7].ToViewModelArray(); ScreenDigit2Pins = new GpioPin[7].ToViewModelArray(); ButtonPin = pins.Last(); //Pin 14 ButtonPin?.SetDriveMode(GpioPinDriveMode.InputPullUp); _numbers = new int[][] { new[] { 0, 1, 2, 3, 4, 5 }, // 0 new[] { 1, 2 }, // 1 new[] { 0, 1, 3, 4, 6 }, // 2 new[] { 0, 1, 2, 3, 6 }, // 3 new[] { 1, 2, 5, 6 }, // 4 new[] { 0, 2, 3, 5, 6 }, // 5 new[] { 2, 3, 4, 5, 6 }, // 6 new[] { 0, 1, 2, 5 }, // 7 new[] { 0, 1, 2, 3, 4, 5, 6 }, // 8 new[] { 0, 1, 2, 3, 5, 6 } // 9 }; Reset(); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); ParametresPortSerie parametresGps = new ParametresPortSerie("", @"\\?\ACPI#BCM2837#4#", 9600, SerialParity.None, SerialStopBitCount.One, 8, SerialHandshake.None, 100, 0); _gps = new GpsNMEA(parametresGps, true, 1024); InfosGpsCTRL.DataContext = new GpsNMEAVM(_gps); GpioController gpc = GpioController.GetDefault(); GpioPin ledOccupe = gpc?.OpenPin(24); try { _appareilPhoto = new AppareilPhotoGps(ledOccupe, _gps); if (await _appareilPhoto.Initialiser(1280, 960, "MJPG")) { PrendrePhotoBTN.Visibility = Visibility.Visible; if (gpc != null) { _poussoirDecl = gpc.OpenPin(18); _poussoirDecl.SetDriveMode(GpioPinDriveMode.InputPullUp); _poussoirDecl.DebounceTimeout = new TimeSpan(0, 0, 0, 0, 5); _poussoirDecl.ValueChanged += _poussoirDecl_ValueChanged; _ledEnMarche = gpc.OpenPin(23); _ledEnMarche.SetDriveMode(GpioPinDriveMode.Output); _ledEnMarche.Write(GpioPinValue.High); } } } finally { PeripheriqueSerie.PeripheriquesSerie.DemarrerSurveillance(); } }
private async Task InitGpio() { _gpioController = await GpioController.GetDefaultAsync(); if (_gpioController == null) { return; } _pinLed = _gpioController?.OpenPin(26); _pinLed.SetDriveMode(GpioPinDriveMode.Output); _pinSensor = _gpioController?.OpenPin(18); _pinSensor.DebounceTimeout = TimeSpan.FromMilliseconds(200); _pinSensor.SetDriveMode(GpioPinDriveMode.InputPullDown); _pinSensor.ValueChanged += _pinSensor_ValueChanged; }
public GpioPin OpenPin(int pin, GpioSharingMode mode) { if (_pins.ContainsKey(pin)) { var gpioPin = _pins[pin]; if (gpioPin.SharingMode == mode) { return gpioPin; } throw new ArgumentException($"Pin '{pin}' is already configured in mode '{gpioPin.SharingMode}'"); } else { var gpioPin = _gpioController?.OpenPin(pin, mode); _pins[pin] = gpioPin; return gpioPin; } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { GpioController gpc = GpioController.GetDefault(); GpioPin ledOccupe = gpc?.OpenPin(24); _appareilPhoto = new AppareilPhoto(ledOccupe); if (await _appareilPhoto.Initialiser(1280, 960, "MJPG")) { PrendrePhotoBTN.Visibility = Visibility.Visible; if (gpc != null) { _poussoirDecl = gpc.OpenPin(18); _poussoirDecl.SetDriveMode(GpioPinDriveMode.InputPullUp); _poussoirDecl.DebounceTimeout = new TimeSpan(0, 0, 0, 0, 5); _ledEnMarche = gpc.OpenPin(23); _ledEnMarche.SetDriveMode(GpioPinDriveMode.Output); _ledEnMarche.Write(GpioPinValue.High); } } }
public IEnumerable <string> Get() { GpioController controller = new GpioController(PinNumberingScheme.Board); var pin = 11; var lightTime = 800; controller.OpenPin(pin, PinMode.Output); try { while (true) { controller.Write(pin, PinValue.High); Thread.Sleep(lightTime); controller.Write(pin, PinValue.Low); Thread.Sleep(lightTime); } } finally { controller.ClosePin(pin); } }
private async Task InitGPIO() { // Get the GPIO controller try { gpioController = await GpioController.GetDefaultAsync(); } catch (Exception ex) { throw new Exception("GPIO Initialization failed.", ex); } // Setup the GPIO pins for the display pinReset = CreateWritePin(RESET_PIN); pinPanel = CreateWritePin(PANEL_PIN); pinDischarge = CreateWritePin(DISCHARGE_PIN); pinBorder = CreateWritePin(BORDER_PIN); // Setup the Busy pin as a read pinBusy = gpioController.OpenPin(BUSY_PIN, GpioSharingMode.Exclusive); pinBusy.SetDriveMode(GpioPinDriveMode.Input); }
public async Task InitializeAsync() { lock (this) { isInitialized.CheckIfFulfills("OutputDevice", "initialized", false); isInitialized = true; } await Task.Run(() => { try { pin = gpio.OpenPin(pinNumber); pin.SetDriveMode(GpioPinDriveMode.Output); pin.Write(GpioPinValue.Low); } catch (Exception ex) { throw new Exception($"Output device could not be initialized: { ex.Message }. { Logger.GetExceptionLocalization(this) }"); } }); }
//Method to initialize the TCS34725 sensor public async Task Initialize() { Debug.WriteLine("TCS34725::Initialize"); try { //Instantiate the I2CConnectionSettings using the device address of the TCS34725 I2cConnectionSettings settings = new I2cConnectionSettings(TCS34725_Address); //Set the I2C bus speed of connection to fast mode settings.BusSpeed = I2cBusSpeed.FastMode; //Use the I2CBus device selector to create an advanced query syntax string string aqs = I2cDevice.GetDeviceSelector(I2CControllerName); //Use the Windows.Devices.Enumeration.DeviceInformation class to create a //collection using the advanced query syntax string DeviceInformationCollection dis = await DeviceInformation.FindAllAsync(aqs); //Instantiate the the TCS34725 I2C device using the device id of the I2CBus //and the I2CConnectionSettings colorSensor = await I2cDevice.FromIdAsync(dis[0].Id, settings); //Create a default GPIO controller gpio = GpioController.GetDefault(); //Open the LED control pin using the GPIO controller LedControlGPIOPin = gpio.OpenPin(LedControlPin); //Set the pin to output LedControlGPIOPin.SetDriveMode(GpioPinDriveMode.Output); //Initialize the known color list initColorList(); } catch (Exception e) { Debug.WriteLine("Exception: " + e.Message + "\n" + e.StackTrace); throw; } }
public Rfm9XDevice(int busId, int chipSelectPin, int resetPin) { var settings = new SpiConnectionSettings(busId, chipSelectPin) { ClockFrequency = 500000, //DataBitLength = 8, Mode = SpiMode.Mode0,// From SemTech docs pg 80 CPOL=0, CPHA=0 SharingMode = SpiSharingMode.Shared, }; rfm9XLoraModem = new SpiDevice(settings); // Factory reset pin configuration GpioController gpioController = new GpioController(); GpioPin resetGpioPin = gpioController.OpenPin(resetPin); resetGpioPin.SetPinMode(PinMode.Output); resetGpioPin.Write(PinValue.Low); Thread.Sleep(10); resetGpioPin.Write(PinValue.High); Thread.Sleep(10); }
public void WaitForEventAsyncFail() { var ctrl = new GpioController(PinNumberingScheme.Logical, _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 <CancellationToken>())) .Returns(new WaitForEventResult() { EventTypes = PinEventTypes.None, TimedOut = true }); Assert.NotNull(ctrl); ctrl.OpenPin(1, PinMode.Input); var task = ctrl.WaitForEventAsync(1, PinEventTypes.Falling | PinEventTypes.Rising, TimeSpan.FromSeconds(0.01)).AsTask(); task.Wait(CancellationToken.None); Assert.True(task.IsCompleted); Assert.Null(task.Exception); Assert.True(task.Result.TimedOut); Assert.Equal(PinEventTypes.None, task.Result.EventTypes); }
private static GpioPin GetPin(int pinNumber) { if (!Valid()) { return(null); } if (!pins.ContainsKey(pinNumber)) { try { var pin = controller.OpenPin(pinNumber); pin.Write(GpioPinValue.Low); pin.SetDriveMode(GpioPinDriveMode.Output); pins[pinNumber] = pin; } catch { pins[pinNumber] = null; } } return(pins[pinNumber]); }
public void CacheInvalidatesWhenReset(TestDevice testDevice) { Mcp23xxx device = testDevice.Device; GpioController controller = testDevice.Controller; // Check the output latches after enabling and setting // different bits. device.Enable(); for (int i = 0; i < 4; i++) { controller.OpenPin(i, PinMode.Output); } controller.Write(0, PinValue.High); Assert.Equal(1, device.ReadByte(Register.OLAT)); controller.Write(1, PinValue.High); Assert.Equal(3, device.ReadByte(Register.OLAT)); // Flush OLAT device.WriteByte(Register.OLAT, 0x00); Assert.Equal(0, device.ReadByte(Register.OLAT)); // Now setting the next bit will pick back up our cached 3 controller.Write(2, PinValue.High); Assert.Equal(7, device.ReadByte(Register.OLAT)); // Re-enabling will reset the cache device.WriteByte(Register.OLAT, 0x00); device.Disable(); device.Enable(); controller.Write(3, PinValue.High); Assert.Equal(8, device.ReadByte(Register.OLAT)); device.WriteByte(Register.OLAT, 0x02); device.Disable(); device.Enable(); controller.Write(0, PinValue.High); Assert.Equal(3, device.ReadByte(Register.OLAT)); }
public MainPage() { this.InitializeComponent(); timer.Tick += Timer_Tick; Gamepad.GamepadAdded += Gamepad_GamepadAdded; Gamepad.GamepadRemoved += Gamepad_GamepadRemoved; if (ApiInformation.IsTypePresent("Windows.Devices.Gpio.GpioController")) { gpio = GpioController.GetDefault(); if (gpio == null) { TextMain.Text = "No GPIO"; return; } led1 = gpio.OpenPin(12); // Left motor motor1A = gpio.OpenPin(23); motor1B = gpio.OpenPin(24); motor1E = gpio.OpenPin(25); // Right motor motor2A = gpio.OpenPin(5); motor2B = gpio.OpenPin(6); motor2E = gpio.OpenPin(13); led1.SetDriveMode(GpioPinDriveMode.Output); motor1A.SetDriveMode(GpioPinDriveMode.Output); motor1B.SetDriveMode(GpioPinDriveMode.Output); motor1E.SetDriveMode(GpioPinDriveMode.Output); motor2A.SetDriveMode(GpioPinDriveMode.Output); motor2B.SetDriveMode(GpioPinDriveMode.Output); motor2E.SetDriveMode(GpioPinDriveMode.Output); TextMain.Text = "GPIO set"; ledTimer.Tick += LedTimer_Tick; } }
public ENER314(GpioController gpioController) { _gpioController = gpioController; if (_gpioController.NumberingScheme == PinNumberingScheme.Board) { PIN_MODE_SELECT = BOARD_PIN_MODE_SELECT; PIN_ENCODER_SIGNAL_D0 = BOARD_PIN_ENCODER_SIGNAL_D0; PIN_ENCODER_SIGNAL_D1 = BOARD_PIN_ENCODER_SIGNAL_D1; PIN_ENCODER_SIGNAL_D2 = BOARD_PIN_ENCODER_SIGNAL_D2; PIN_ENCODER_SIGNAL_D3 = BOARD_PIN_ENCODER_SIGNAL_D3; PIN_MODULATOR_ON_OFF = BOARD_PIN_MODULATOR_ON_OFF; } else { PIN_MODE_SELECT = LOGICAL_PIN_MODE_SELECT; PIN_ENCODER_SIGNAL_D0 = LOGICAL_PIN_ENCODER_SIGNAL_D0; PIN_ENCODER_SIGNAL_D1 = LOGICAL_PIN_ENCODER_SIGNAL_D1; PIN_ENCODER_SIGNAL_D2 = LOGICAL_PIN_ENCODER_SIGNAL_D2; PIN_ENCODER_SIGNAL_D3 = LOGICAL_PIN_ENCODER_SIGNAL_D3; PIN_MODULATOR_ON_OFF = LOGICAL_PIN_MODULATOR_ON_OFF; } PINS = new[] { PIN_ENCODER_SIGNAL_D3, PIN_ENCODER_SIGNAL_D2, PIN_ENCODER_SIGNAL_D1, PIN_ENCODER_SIGNAL_D0 }; // Pins for encoder K0-K3 data inputs _gpioController.OpenPin(PIN_ENCODER_SIGNAL_D0, PinMode.Output); _gpioController.OpenPin(PIN_ENCODER_SIGNAL_D1, PinMode.Output); _gpioController.OpenPin(PIN_ENCODER_SIGNAL_D2, PinMode.Output); _gpioController.OpenPin(PIN_ENCODER_SIGNAL_D3, PinMode.Output); // Pin for mode (Amplitude Shift Keying/Frequency Shift Keying) _gpioController.OpenPin(PIN_MODE_SELECT, PinMode.Output); // Pin for modulator enable/disable _gpioController.OpenPin(PIN_MODULATOR_ON_OFF, PinMode.Output); }
private void Start() { GpioController gpio = null; try { gpio = GpioController.GetDefault(); } catch (Exception) { // the error will be handled below } // Show an error if there is no GPIO controller if (gpio == null) { pin = null; GpioStatus.Text = loader.GetString("NoGPIOController"); return; } pin = gpio.OpenPin(LED_PIN); // Show an error if the pin wasn't initialized properly if (pin == null) { GpioStatus.Text = loader.GetString("ProblemsInitializingGPIOPin"); return; } pin.Write(GpioPinValue.High); pin.SetDriveMode(GpioPinDriveMode.Output); GpioStatus.Text = loader.GetString("GPIOPinInitializedCorrectly"); blinkyTimer.Start(); BlinkyStartStop.Content = loader.GetString("BlinkyStop"); }
static void Main(string[] args) { int inputPinNum = 10; var gpio = new GpioController(); gpio.OpenPin(inputPinNum, PinMode.Input); gpio.Read(inputPinNum); // Warmup var stopWatch = Stopwatch.StartNew(); var cycleCounter = 0; while (stopWatch.Elapsed.TotalSeconds < 10) { gpio.Read(inputPinNum); ++cycleCounter; } Console.WriteLine("Read Frequency for input pin #" + inputPinNum.ToString() + " : " + (cycleCounter / stopWatch.Elapsed.TotalSeconds).ToString("N", CultureInfo.InvariantCulture) + " Hz"); Console.WriteLine("Runnning for : " + stopWatch.Elapsed.TotalSeconds + " seconds"); }
static void Main(string[] args) { var pin = 18; var lightTime = 1000; var dimTime = 200; Console.WriteLine($"Let's blink an LED!"); using GpioController controller = new GpioController(); controller.OpenPin(pin, PinMode.Output); Console.WriteLine($"GPIO pin enabled for use: {pin}"); // turn LED on and off while (true) { Console.WriteLine($"Light for {lightTime}ms"); controller.Write(pin, PinValue.High); Thread.Sleep(lightTime); Console.WriteLine($"Dim for {dimTime}ms"); controller.Write(pin, PinValue.Low); Thread.Sleep(dimTime); } }
/// <summary>Executes the command asynchronously.</summary> /// <returns>The command's exit code.</returns> /// <remarks> /// NOTE: This test app uses the base class's <see cref="CreateGpioController"/> method to create a device.<br/> /// Real-world usage would simply create an instance of <see cref="GpioController"/>: /// <code>using (var controller = new GpioController())</code> /// </remarks> public async Task <int> ExecuteAsync() { Console.WriteLine($"Driver={Driver}, Scheme={Scheme}, LedPin ={LedPin}, Count={Count}, TimeOn={TimeOn} ms, TimeOff={TimeOff} ms"); using (GpioController controller = CreateGpioController()) { controller.OpenPin(LedPin, PinMode.Output); controller.Write(LedPin, OffValue); for (int index = 0; index < Count; ++index) { Console.WriteLine($"[{index}] Turn the LED on and wait {TimeOn} ms."); controller.Write(LedPin, OnValue); await Task.Delay(TimeOn); Console.WriteLine($"[{index}] Turn the LED off and wait {TimeOff} ms."); controller.Write(LedPin, OffValue); await Task.Delay(TimeOff); } } return(0); }
public static void Main() { Debug.WriteLine("WifiKit32 NF Blinky"); int counter = 0; GpioController gpioc = new GpioController(); GpioPin led = gpioc.OpenPin(WifiKit32Common.OnBoardDevicePortNumber.Led, PinMode.Output); led.Write(PinValue.Low); while (true) { led.Toggle(); if (counter > 10000) { counter = 0; } Debug.WriteLine(counter.ToString()); Thread.Sleep(1000); counter++; } }
public static void Main() { s_GpioController = new GpioController(); // ESP32 DevKit: 4 is a valid GPIO pin in, some boards like Xiuxin ESP32 may require GPIO Pin 2 instead. GpioPin led = s_GpioController.OpenPin( 2, PinMode.Output); led.Write(PinValue.Low); while (true) { led.Toggle(); Thread.Sleep(125); led.Toggle(); Thread.Sleep(125); led.Toggle(); Thread.Sleep(125); led.Toggle(); Thread.Sleep(525); } }
public void Run(IBackgroundTaskInstance taskInstance) { Debug.WriteLine("Application startup"); try { GpioController gpioController = GpioController.GetDefault(); this.interruptGpioPin = gpioController.OpenPin(InterruptPinNumber); this.interruptGpioPin.SetDriveMode(GpioPinDriveMode.InputPullUp); this.interruptGpioPin.ValueChanged += this.InterruptGpioPin_ValueChanged; Debug.WriteLine("Digital Input Interrupt configuration success"); } catch (Exception ex) { Debug.WriteLine($"Digital Input Interrupt configuration failed " + ex.Message); return; } // enable task to continue running in background this.backgroundTaskDeferral = taskInstance.GetDeferral(); }
public SensorReader(int pinNumber) { GpioController controller = GpioController.GetDefault(); if (controller == null) { statusText = "GPIO is not available on this system"; } else { GpioPin pin; try { pin = controller.OpenPin(pinNumber); dht11.Init(pin); statusText = "Status: Initialized Successfully"; } catch (Exception ex) { statusText = "Failed to open GPIO pin: " + ex.Message; } } }
void Initialize() { #region Initialize Controller GpioController = GpioController.GetDefault(); if (GpioController == null) { throw new NotSupportedException("No GPIO controller found."); } #endregion #region Initialize Pins GpioPins = new GpioPin[16]; for (int pin = 0; pin < 16; pin++) { GpioPins[pin] = GpioController.OpenPin(PinNumbers[pin]); GpioPins[pin].SetDriveMode(GpioPinDriveMode.InputPullUp); } #endregion }
public PwmDevice(string n, int pinNumber, double freq = 50) : base(n) { GpioController gpio = GpioController.GetDefault(); if (gpio == null) { throw new Exception("GPIO Initialization Failed"); } _pin = gpio.OpenPin(pinNumber); _pin.Write(LOW); _pin.SetDriveMode(OUTPUT); _dutyCycle = 0; _frequency = freq; _timeOn = (ulong)((((1.0 / _frequency) / 100.0) * _dutyCycle) * 1000.0); _timePeriod = (ulong)((1.0 / _frequency) * 1000.0); _on = false; _task = new Task(() => PwmRun()); }
public void Run(IBackgroundTaskInstance taskInstance) { deferral = taskInstance.GetDeferral(); //Motor starts off currentPulseWidth = 0; //The stopwatch will be used to precisely time calls to pulse the motor. stopwatch = Stopwatch.StartNew(); GpioController controller = GpioController.GetDefault(); servoPin = controller.OpenPin(13); servoPin.SetDriveMode(GpioPinDriveMode.Output); timer = ThreadPoolTimer.CreatePeriodicTimer(this.Tick, TimeSpan.FromSeconds(2)); //You do not need to await this, as your goal is to have this run for the lifetime of the application Windows.System.Threading.ThreadPool.RunAsync(this.MotorThread, Windows.System.Threading.WorkItemPriority.High); }
public void Run() { int ledPin = 4; GpioController controller = new GpioController(); controller.OpenPin(ledPin, PinMode.Output); int lightTimeInMiliseconds = 5000; int dimTimeInMiliseconds = 5000; while (true) { _logger.Write($"LED1 on for {lightTimeInMiliseconds}ms"); controller.Write(ledPin, PinValue.Low); Thread.Sleep(lightTimeInMiliseconds); _logger.Write($"LED off for {dimTimeInMiliseconds}ms"); controller.Write(ledPin, PinValue.High); Thread.Sleep(dimTimeInMiliseconds); } }
/// <summary> /// Get and open a GpioPin using its logical (Gpio) number. /// </summary> /// <remarks>You can use Pin.Close() to remove a pin.</remarks> public static GpioPin Pin(int number) { if (number < 0) { number = 0; } if (number > pins.Length - 1) { number = pins.Length - 1; } var pin = pins[number]; if (pin == null) { pin = new GpioPin(controller, number); pins[number] = pin; if (pin.Valid) { controller.OpenPin(number); } } return(pin); }
/// <summary> /// Constructor for Tlc1543 /// </summary> /// <param name="spiDevice">Device used for SPI communication.</param> /// <param name="endOfConversion">End of Conversion pin, if GpioController is not provided logical numbering scheme is used (default for GpioController).</param> /// <param name="controller">The GPIO controller for defined external pins. If not specified, the default controller will be used.</param> /// <param name="shouldDispose">True to dispose the GPIO controller and SPI device.</param> public Tlc1543(SpiDevice spiDevice, int endOfConversion = -1, GpioController?controller = null, bool shouldDispose = true) { if (spiDevice == null) { throw new ArgumentNullException(nameof(spiDevice)); } if (spiDevice.ConnectionSettings.DataBitLength != SpiDataBitLength) { throw new ArgumentException($"SpiDevice is required to be have DataBitLength={SpiDataBitLength}.", nameof(spiDevice)); } _spiDevice = spiDevice; _shouldDispose = controller == null || shouldDispose; _controller = controller ?? new GpioController(); _endOfConversion = endOfConversion; if (_endOfConversion != -1) { _controller.OpenPin(_endOfConversion, PinMode.InputPullUp); } }
internal async Task InitHardware() { try { _ioController = GpioController.GetDefault(); _interruptPin = _ioController.OpenPin(17); _interruptPin.Write(GpioPinValue.Low); _interruptPin.SetDriveMode(GpioPinDriveMode.Input); _interruptPin.ValueChanged += _interruptPin_ValueChanged; _mpu9150 = new I2CDevice((byte)Mpu9150Setup.Address, I2cBusSpeed.FastMode); await _mpu9150.Open(); await Task.Delay(100); // power up _mpu9150.Write((byte)Mpu9150Setup.PowerManagement1, 0x80); // reset the device await Task.Delay(100); _mpu9150.Write((byte)Mpu9150Setup.PowerManagement1, 0x2); _mpu9150.Write((byte)Mpu9150Setup.UserCtrl, 0x04); //reset fifo _mpu9150.Write((byte)Mpu9150Setup.PowerManagement1, 1); // clock source = gyro x _mpu9150.Write((byte)Mpu9150Setup.GyroConfig, 0); // +/- 250 degrees sec, max sensitivity _mpu9150.Write((byte)Mpu9150Setup.AccelConfig, 0); // +/- 2g, max sensitivity _mpu9150.Write((byte)Mpu9150Setup.Config, 1); // 184 Hz, 2ms delay _mpu9150.Write((byte)Mpu9150Setup.SampleRateDiv, 19); // set rate 50Hz _mpu9150.Write((byte)Mpu9150Setup.FifoEnable, 0x78); // enable accel and gyro to read into fifo _mpu9150.Write((byte)Mpu9150Setup.UserCtrl, 0x40); // reset and enable fifo _mpu9150.Write((byte)Mpu9150Setup.InterruptEnable, 0x1); } catch (Exception ex) { Debug.WriteLine(ex); } }
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); }