/// <summary> /// Initializes a new instance of the <see cref="RFIDControllerMfrc522" /> class. /// </summary> /// <param name="spiPort">The spi port.</param> /// <param name="spiFrequency">The spi frequency.</param> /// <param name="outputPort">The output port.</param> public RFIDControllerMfrc522(ISpiChannel spiPort, int spiFrequency, IGpioPin outputPort) { Pi.Spi.Channel0Frequency = spiFrequency; _spiPort = spiPort; _outputPort = outputPort; InitializeComponent(); }
public DefaultEPaperConnection(IDevice device) { RstPin = Pi.Gpio[device.RstPin]; RstPin.PinMode = GpioPinDriveMode.Output; DcPin = Pi.Gpio[device.DcPin]; DcPin.PinMode = GpioPinDriveMode.Output; CsPin = Pi.Gpio[device.CsPin]; CsPin.PinMode = GpioPinDriveMode.Output; BusyPin = Pi.Gpio[device.BusyPin]; BusyPin.PinMode = GpioPinDriveMode.Input; Pi.Spi.Channel0Frequency = device.SpiFrequency; Channel = Pi.Spi.Channel0; }
/// <summary> /// Initializes the SPI connection to the strip /// </summary> /// <returns>Task representing the async action</returns> public void Begin(int spiFrequency) { //ClockFrequency = 10 000 000, //Pi.Spi.DefaultFrequency 8 000 000 int Pi.Init <BootstrapWiringPi>(); if (spiFrequency == 0) { spiFrequency = Pi.Spi.DefaultFrequency; } Pi.Spi.Channel0Frequency = spiFrequency; Channel = Pi.Spi.Channel0; //SpiController controller = await SpiController.GetDefaultAsync(); //spiDevice = controller.GetDevice(settings); }
protected override async Task InitGpio() { Unosquare.RaspberryIO.Pi.Init <BootstrapWiringPi>(); // NOTE: This is by BCM pin. VERY IMPORTANT! ResetPin = Unosquare.RaspberryIO.Pi.Gpio[17]; BusyPin = Unosquare.RaspberryIO.Pi.Gpio[24]; DataPin = Unosquare.RaspberryIO.Pi.Gpio[25]; ResetPin.PinMode = GpioPinDriveMode.Output; BusyPin.PinMode = GpioPinDriveMode.Input; DataPin.PinMode = GpioPinDriveMode.Output; Spi = Unosquare.RaspberryIO.Pi.Spi.Channel0; Unosquare.RaspberryIO.Pi.Spi.Channel0Frequency = 2000000; await Task.Yield(); }
public void Initialize() { lock (_syncLock) { ResetPin = Pi.Gpio[_specification.RST_PIN]; ResetPin.PinMode = GpioPinDriveMode.Output; DcPin = Pi.Gpio[_specification.DC_PIN]; DcPin.PinMode = GpioPinDriveMode.Output; CsPin = Pi.Gpio[_specification.CS_PIN]; CsPin.PinMode = GpioPinDriveMode.Output; BusyPin = Pi.Gpio[_specification.BUSY_PIN]; BusyPin.PinMode = GpioPinDriveMode.Input; Pi.Spi.Channel0Frequency = _specification.Channel0Frequency; Channel = Pi.Spi.Channel0; } }
/// <summary> /// Set up the SPI device and the controller for the transfer ready pin /// </summary> public static void Initialize() { // Initialize TX header. This only needs to happen once Serialization.Writer.InitTransferHeader(ref _txHeader); // Initialize WiringPi Pi.Init <BootstrapWiringPi>(); Pi.Gpio[Settings.TransferReadyPin].PinMode = GpioPinDriveMode.Input; Pi.Gpio[Settings.TransferReadyPin].InputPullMode = GpioPinResistorPullMode.PullDown; if (Settings.SpiBusID == 0) { Pi.Spi.Channel0Frequency = Settings.SpiFrequency; _spiChannel = Pi.Spi.Channel0; } else { Pi.Spi.Channel1Frequency = Settings.SpiFrequency; _spiChannel = Pi.Spi.Channel1; } Pi.Gpio[Settings.TransferReadyPin].RegisterInterruptCallback(EdgeDetection.FallingAndRisingEdge, () => _transferReadyEvent.Set()); }
/// <summary> /// Initializes a new instance of the <see cref="LedStripAPA102C"/> class. /// </summary> /// <param name="ledCount">The length of the stip.</param> /// <param name="spiChannel">The SPI channel.</param> /// <param name="spiFrequency">The SPI frequency.</param> /// <param name="reverseRgb">if set to <c>true</c> colors will be sent to the strip as BGR, otherwise as RGB.</param> public LedStripAPA102C(int ledCount = 60, int spiChannel = 1, int spiFrequency = 0, bool reverseRgb = true) { // Basic properties LedCount = ledCount; ReverseRgb = reverseRgb; // Create the frame buffer _frameBuffer = new byte[(_pixelHolder.Length * LedCount) + (StartFrame.Length + EndFrame.Length)]; Buffer.BlockCopy(StartFrame, 0, _frameBuffer, 0, StartFrame.Length); Buffer.BlockCopy(EndFrame, 0, _frameBuffer, _frameBuffer.Length - EndFrame.Length, EndFrame.Length); // Create ther Clear buffer _clearBuffer = new byte[_pixelHolder.Length * LedCount]; for (var baseAddress = 0; baseAddress < LedCount * _pixelHolder.Length; baseAddress += _pixelHolder.Length) { Buffer.SetByte(_clearBuffer, baseAddress, BrightnessSetMask); } // Set all the pixels to no value ClearPixels(); if (spiFrequency == 0) { spiFrequency = Pi.Spi.DefaultFrequency; } // Select the SPI channel if (spiChannel == 0) { Pi.Spi.Channel0Frequency = spiFrequency; _channel = Pi.Spi.Channel0; } else { Pi.Spi.Channel1Frequency = spiFrequency; _channel = Pi.Spi.Channel1; } Render(); }
public void Initialize() { lock (_syncLock) { ResetPin = Pi.Gpio[_specification.RST_PIN]; ResetPin.PinMode = GpioPinDriveMode.Output; DcPin = Pi.Gpio[_specification.DC_PIN]; DcPin.PinMode = GpioPinDriveMode.Output; CsPin = Pi.Gpio[_specification.CS_PIN]; CsPin.PinMode = GpioPinDriveMode.Output; BusyPin = Pi.Gpio[_specification.BUSY_PIN]; BusyPin.PinMode = GpioPinDriveMode.Input; Pi.Spi.Channel0Frequency = _specification.Channel0Frequency; Channel = Pi.Spi.Channel0; /******* System.Device.Gpio Alternative *********/ //ResetPin = _specification.RST_PIN; //Gpio.OpenPin(ResetPin, PinMode.Output); //DcPin = _specification.DC_PIN; //Gpio.OpenPin(DcPin, PinMode.Output); //CsPin = _specification.CS_PIN; //Gpio.OpenPin(CsPin, PinMode.Output); //BusyPin = _specification.BUSY_PIN; //Gpio.OpenPin(BusyPin, PinMode.Input); //Gpio.Write(CsPin, PinValue.High); //SpiDevice = SpiDevice.Create(_spiSettings); } }
public Max7219MatrixDisplay(ISpiChannel channel, IMax7219MatrixModule[][] modules) { Channel = channel; Modules = modules; InitOrderedModules(); }
public Max7219MatrixDisplay(ISpiChannel channel, int numberOfModules) { Channel = channel; InitModules(numberOfModules); InitOrderedModules(); }
public Pcd8544(ISpiChannel spiChannel, IGpioPin resetPin, IGpioPin dcPin) { _spi = spiChannel; _res = resetPin; _dc = dcPin; }