Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RFIDControllerMfrc522" /> class.
 /// </summary>
 /// <param name="spiPort">The spi port.</param>
 /// <param name="spiFrquency">The spi frquency.</param>
 /// <param name="outputPort">The output port.</param>
 public RFIDControllerMfrc522(SpiChannel spiPort, int spiFrquency, GpioPin outputPort)
 {
     Pi.Spi.Channel0Frequency = spiFrquency;
     _spiPort    = spiPort;
     _outputPort = outputPort;
     InitializeComponent();
 }
Exemplo n.º 2
0
        /// <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 = SpiChannel.DefaultFrequency, 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();

            // 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();
        }
Exemplo n.º 3
0
        public CardReader()
        {
            Pi.Spi.Channel0Frequency = SpiChannel.MinFrequency;
            _channel = Pi.Spi.Channel0;

            Pi.Gpio.Pin22.PinMode = GpioPinDriveMode.Output;
            Pi.Gpio.Pin22.Write(GpioPinValue.High);

            Reset();

            Write(TModeReg, 0x8D);
            Write(TPrescalerReg, 0x3E);
            Write(TReloadRegL, 30);
            Write(TReloadRegH, 0);
            Write(TxAutoReg, 0x40);
            Write(ModeReg, 0x3D);
            AntennaOn();
        }
Exemplo n.º 4
0
        public override Task InitAsync()
        {
            var gpioController = GpioController.Instance;

            rstPin          = gpioController.Pin17;
            rstPin.PinMode  = GpioPinDriveMode.Output;
            busyPin         = gpioController.Pin24;
            busyPin.PinMode = GpioPinDriveMode.Input;
            dataPin         = gpioController.Pin25;
            dataPin.PinMode = GpioPinDriveMode.Output;
            //tstPin = gpioController.OpenPin(18);
            spi = SpiBus.Instance.Channel0;
            SpiBus.Instance.Channel0Frequency = 2000000;
            //var spiSetting = new SpiConnectionSettings(0);
            //spiSetting.ClockFrequency = 2000000;
            //spiSetting.Mode = SpiMode.Mode0;
            //spiSetting.DataBitLength = 8;
            //spi = spiController.GetDevice(spiSetting);
            return(Task.CompletedTask);
        }