Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GroveBarDevice"/> class.
 /// </summary>
 /// <param name="dataPin">The data pin.</param>
 /// <param name="clockPin">The clock pin.</param>
 /// <param name="threadFactory">The thread factory.</param>
 public GroveBarDevice(IOutputBinaryPin dataPin, IInputOutputBinaryPin clockPin, IThreadFactory threadFactory = null)
 {
     this.dataPin  = dataPin;
     this.clockPin = clockPin;
     this.thread   = ThreadFactory.EnsureThreadFactory(threadFactory).Create();
     this.Initialize();
 }
 public GroveRgbConnection(IOutputBinaryPin dataPin, IOutputBinaryPin clockPin, int ledCount)
 {
     ledColors = new List<RgbColor>();
     for (int i = 0; i < ledCount; i++)
     {
         // Initialize all leds with white color
         ledColors.Add(new RgbColor());
     }
     this.dataPin = dataPin;
     this.clockPin = clockPin;
 }
Esempio n. 3
0
 public GroveRgbConnection(IOutputBinaryPin dataPin, IOutputBinaryPin clockPin, int ledCount)
 {
     ledColors = new List <RgbColor>();
     for (int i = 0; i < ledCount; i++)
     {
         // Initialize all leds with white color
         ledColors.Add(new RgbColor());
     }
     this.dataPin  = dataPin;
     this.clockPin = clockPin;
 }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HcSr04Connection"/> class.
        /// </summary>
        /// <param name="triggerPin">The trigger pin.</param>
        /// <param name="echoPin">The echo pin.</param>
        public HcSr04Connection(IOutputBinaryPin triggerPin, IInputBinaryPin echoPin)
        {
            this.triggerPin = triggerPin;
            this.echoPin    = echoPin;

            Timeout = DefaultTimeout;

            try
            {
                GetDistance();
            } catch {}
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HcSr04Connection"/> class.
        /// </summary>
        /// <param name="triggerPin">The trigger pin.</param>
        /// <param name="echoPin">The echo pin.</param>
        public HcSr04Connection(IOutputBinaryPin triggerPin, IInputBinaryPin echoPin)
        {
            this.triggerPin = triggerPin;
            this.echoPin = echoPin;

            Timeout = DefaultTimeout;

            try
            {
                GetDistance();
            } catch {}
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GroveRgbDevice"/> class.
        /// </summary>
        /// <param name="dataPin">The data pin.</param>
        /// <param name="clockPin">The clock pin.</param>
        /// <param name="ledCount">The led count.</param>
        /// <param name="threadFactory">The thread factory.</param>
        public GroveRgbDevice(IOutputBinaryPin dataPin, IOutputBinaryPin clockPin, int ledCount, IThreadFactory threadFactory = null)
        {
            this.thread    = ThreadFactory.EnsureThreadFactory(threadFactory).Create();
            this.ledColors = new List <RgbColor>();
            for (int i = 0; i < ledCount; i++)
            {
                // Initialize all leds with white color
                this.ledColors.Add(new RgbColor());
            }

            this.dataPin  = dataPin;
            this.clockPin = clockPin;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SpiConnection"/> class.
        /// </summary>
        /// <param name="clockPin">The clock pin.</param>
        /// <param name="selectSlavePin">The select slave pin.</param>
        /// <param name="misoPin">The miso pin.</param>
        /// <param name="mosiPin">The mosi pin.</param>
        /// <param name="endianness">The endianness.</param>
        public SpiConnection(IOutputBinaryPin clockPin, IOutputBinaryPin selectSlavePin, IInputBinaryPin misoPin, IOutputBinaryPin mosiPin, Endianness endianness)
        {
            this.clockPin = clockPin;
            this.selectSlavePin = selectSlavePin;
            this.misoPin = misoPin;
            this.mosiPin = mosiPin;
            this.endianness = endianness;

            clockPin.Write(false);
            selectSlavePin.Write(true);

            if (mosiPin != null)
                mosiPin.Write(false);
            }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HcSr04Device" /> class.
        /// </summary>
        /// <param name="triggerPin">The trigger pin.</param>
        /// <param name="echoPin">The echo pin.</param>
        /// <param name="threadFactory">The thread factory.</param>
        public HcSr04Device(IOutputBinaryPin triggerPin, IInputBinaryPin echoPin, IThreadFactory threadFactory = null)
        {
            this.triggerPin = triggerPin;
            this.echoPin    = echoPin;
            this.thread     = ThreadFactory.EnsureThreadFactory(threadFactory).Create();

            this.SetTimeout(DefaultTimeout);

            try
            {
                this.GetDistance();
            }
            catch
            {
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpiConnection"/> class.
        /// </summary>
        /// <param name="clockPin">The clock pin.</param>
        /// <param name="selectSlavePin">The select slave pin.</param>
        /// <param name="misoPin">The miso pin.</param>
        /// <param name="mosiPin">The mosi pin.</param>
        /// <param name="endianness">The endianness.</param>
        public SpiConnection(IOutputBinaryPin clockPin, IOutputBinaryPin selectSlavePin, IInputBinaryPin misoPin, IOutputBinaryPin mosiPin, Endianness endianness)
        {
            this.clockPin       = clockPin;
            this.selectSlavePin = selectSlavePin;
            this.misoPin        = misoPin;
            this.mosiPin        = mosiPin;
            this.endianness     = endianness;

            clockPin.Write(false);
            selectSlavePin.Write(true);

            if (mosiPin != null)
            {
                mosiPin.Write(false);
            }
        }
        public Ti430BoostAds1118Connection(INativeSpiConnection spi0, INativeSpiConnection spi1, IOutputBinaryPin lcdRegisterSelectGpio, IOutputBinaryPin lcdResetGpio)
        {
            this.singleShot = Ads1118SingleShot.SingleShot;
            this.pga = Ads1118ProgrammableGainAmplifier.TwoFiveSix;
            this.deviceOperatingMode = Ads1118DeviceOperatingMode.PowerDownSingleShotMode;
            this.dataRate = Ads1118DataRate.OneTwoEight;
            this.pullupEnabled = Ads1118PullupEnable.PullupEnabled;

            this.spi0 = spi0;
            this.spi1 = spi1;
            this.lcdRegisterSelectGpio = lcdRegisterSelectGpio;
            this.lcdResetGpio = lcdResetGpio;

            this.lcdRegisterSelectGpio.Write(true);
            this.lcdResetGpio.Write(true);
        }
        public Ti430BoostAds1118Connection(INativeSpiConnection spi0, INativeSpiConnection spi1, IOutputBinaryPin lcdRegisterSelectGpio, IOutputBinaryPin lcdResetGpio)
        {
            this.singleShot          = Ads1118SingleShot.SingleShot;
            this.pga                 = Ads1118ProgrammableGainAmplifier.TwoFiveSix;
            this.deviceOperatingMode = Ads1118DeviceOperatingMode.PowerDownSingleShotMode;
            this.dataRate            = Ads1118DataRate.OneTwoEight;
            this.pullupEnabled       = Ads1118PullupEnable.PullupEnabled;

            this.spi0 = spi0;
            this.spi1 = spi1;
            this.lcdRegisterSelectGpio = lcdRegisterSelectGpio;
            this.lcdResetGpio          = lcdResetGpio;

            this.lcdRegisterSelectGpio.Write(true);
            this.lcdResetGpio.Write(true);
        }
Esempio n. 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpiConnection" /> class.
        /// </summary>
        /// <param name="clockPin">The clock pin.</param>
        /// <param name="selectSlavePin">The select slave pin.</param>
        /// <param name="misoPin">The miso pin.</param>
        /// <param name="mosiPin">The mosi pin.</param>
        /// <param name="endianness">The endianness.</param>
        /// <param name="threadFactory">The thread factory.</param>
        public SpiConnection(
            IOutputBinaryPin clockPin,
            IOutputBinaryPin selectSlavePin,
            IInputBinaryPin misoPin,
            IOutputBinaryPin mosiPin,
            Endianness endianness        = Endianness.LittleEndian,
            IThreadFactory threadFactory = null)
        {
            this.clockPin       = clockPin;
            this.selectSlavePin = selectSlavePin;
            this.misoPin        = misoPin;
            this.mosiPin        = mosiPin;
            this.endianness     = endianness;
            this.thread         = ThreadFactory.EnsureThreadFactory(threadFactory).Create();

            clockPin.Write(false);
            selectSlavePin.Write(true);

            mosiPin?.Write(false);
        }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Mcp4822SpiConnection" /> class.
 /// </summary>
 /// <param name="clockPin">The clock pin.</param>
 /// <param name="slaveSelectPin">The slave select pin.</param>
 /// <param name="mosiPin">The mosi pin.</param>
 public Mcp4822SpiConnection(IOutputBinaryPin clockPin, IOutputBinaryPin slaveSelectPin, IOutputBinaryPin mosiPin)
 {
     spiConnection = new SpiConnection(clockPin, slaveSelectPin, null, mosiPin, Endianness.LittleEndian);
 }
 public GroveBarConnection(IOutputBinaryPin dataPin, IInputOutputBinaryPin clockPin)
 {
     this.dataPin = dataPin;
     this.clockPin = clockPin;
     Initialize();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Hd44780LcdConnection" /> class.
 /// </summary>
 /// <param name="registerSelectPin">The register select pin.</param>
 /// <param name="clockPin">The clock pin.</param>
 /// <param name="dataPins">The data pins.</param>
 public Hd44780LcdConnection(IOutputBinaryPin registerSelectPin, IOutputBinaryPin clockPin, IEnumerable<IOutputBinaryPin> dataPins)
     : this(null, new Hd44780Pins(registerSelectPin, clockPin, dataPins))
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Hd44780LcdConnection" /> class.
 /// </summary>
 /// <param name="registerSelectPin">The register select pin.</param>
 /// <param name="clockPin">The clock pin.</param>
 /// <param name="dataPins">The data pins.</param>
 public Hd44780LcdConnection(IOutputBinaryPin registerSelectPin, IOutputBinaryPin clockPin, params IOutputBinaryPin[] dataPins)
     : this(null, new Hd44780Pins(registerSelectPin, clockPin, dataPins))
 {
 }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Hd44780Pins"/> class.
 /// </summary>
 /// <param name="registerSelect">The register select.</param>
 /// <param name="clock">The clock.</param>
 /// <param name="data">The data.</param>
 public Hd44780Pins(IOutputBinaryPin registerSelect, IOutputBinaryPin clock, params IOutputBinaryPin[] data)
 {
     RegisterSelect = registerSelect;
     Clock = clock;
     Data = data;
 }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Hd44780Pins"/> class.
 /// </summary>
 /// <param name="registerSelect">The register select.</param>
 /// <param name="clock">The clock.</param>
 /// <param name="data">The data.</param>
 public Hd44780Pins(IOutputBinaryPin registerSelect, IOutputBinaryPin clock, IEnumerable<IOutputBinaryPin> data)
     : this(registerSelect, clock, data.ToArray())
 {
 }
Esempio n. 19
0
 public TransceiverSpiConnection(INativeSpiConnection spiConnection, IOutputBinaryPin ssPin, IOutputBinaryPin resetPin)
 {
     this.spiConnection = spiConnection;
     this.ssPin         = ssPin;
     this.resetPin      = resetPin;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Hd44780Pins"/> class.
 /// </summary>
 /// <param name="registerSelect">The register select.</param>
 /// <param name="clock">The clock.</param>
 /// <param name="data">The data.</param>
 public Hd44780Pins(IOutputBinaryPin registerSelect, IOutputBinaryPin clock, IEnumerable <IOutputBinaryPin> data)
     : this(registerSelect, clock, data.ToArray())
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Hd44780LcdConnection" /> class.
 /// </summary>
 /// <param name="registerSelectPin">The register select pin.</param>
 /// <param name="clockPin">The clock pin.</param>
 /// <param name="dataPins">The data pins.</param>
 public Hd44780LcdConnection(IOutputBinaryPin registerSelectPin, IOutputBinaryPin clockPin, IEnumerable <IOutputBinaryPin> dataPins) : this(null, new Hd44780Pins(registerSelectPin, clockPin, dataPins))
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Mcp4822SpiConnection" /> class.
 /// </summary>
 /// <param name="clockPin">The clock pin.</param>
 /// <param name="slaveSelectPin">The slave select pin.</param>
 /// <param name="mosiPin">The mosi pin.</param>
 public Mcp4822SpiConnection(IOutputBinaryPin clockPin, IOutputBinaryPin slaveSelectPin, IOutputBinaryPin mosiPin)
 {
     spiConnection = new SpiConnection(clockPin, slaveSelectPin, null, mosiPin, Endianness.LittleEndian);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Mcp3202SpiConnection"/> class.
 /// </summary>
 /// <param name="clockPin">The clock pin.</param>
 /// <param name="slaveSelectPin">The slave select pin.</param>
 /// <param name="misoPin">The miso pin.</param>
 /// <param name="mosiPin">The mosi pin.</param>
 public Mcp3202SpiConnection(IOutputBinaryPin clockPin, IOutputBinaryPin slaveSelectPin, IInputBinaryPin misoPin, IOutputBinaryPin mosiPin, decimal maxValue = 1m)
 {
     _spiConnection = new SpiConnection(clockPin, slaveSelectPin, misoPin, mosiPin, Endianness.LittleEndian);
     _maxValue = maxValue;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Hd44780LcdConnection" /> class.
 /// </summary>
 /// <param name="registerSelectPin">The register select pin.</param>
 /// <param name="clockPin">The clock pin.</param>
 /// <param name="dataPins">The data pins.</param>
 public Hd44780LcdConnection(IOutputBinaryPin registerSelectPin, IOutputBinaryPin clockPin, params IOutputBinaryPin[] dataPins) : this(null, new Hd44780Pins(registerSelectPin, clockPin, dataPins))
 {
 }
Esempio n. 25
0
 public GroveBarConnection(IOutputBinaryPin dataPin, IInputOutputBinaryPin clockPin)
 {
     this.dataPin  = dataPin;
     this.clockPin = clockPin;
     Initialize();
 }
Esempio n. 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Mcp3208Device"/> class.
 /// </summary>
 /// <param name="clockPin">The clock pin.</param>
 /// <param name="slaveSelectPin">The slave select pin.</param>
 /// <param name="misoPin">The miso pin.</param>
 /// <param name="mosiPin">The mosi pin.</param>
 public Mcp3208Device(IOutputBinaryPin clockPin, IOutputBinaryPin slaveSelectPin, IInputBinaryPin misoPin, IOutputBinaryPin mosiPin)
 {
     this.spiConnection = new SpiConnection(clockPin, slaveSelectPin, misoPin, mosiPin, Endianness.LittleEndian);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Mcp3208SpiConnection"/> class.
 /// </summary>
 /// <param name="clockPin">The clock pin.</param>
 /// <param name="slaveSelectPin">The slave select pin.</param>
 /// <param name="misoPin">The miso pin.</param>
 /// <param name="mosiPin">The mosi pin.</param>
 public Mcp3208SpiConnection(IOutputBinaryPin clockPin, IOutputBinaryPin slaveSelectPin, IInputBinaryPin misoPin, IOutputBinaryPin mosiPin)
 {
     spiConnection = new SpiConnection(clockPin, slaveSelectPin, misoPin, mosiPin, Endianness.LittleEndian);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Hd44780Pins"/> class.
 /// </summary>
 /// <param name="registerSelect">The register select.</param>
 /// <param name="clock">The clock.</param>
 /// <param name="data">The data.</param>
 public Hd44780Pins(IOutputBinaryPin registerSelect, IOutputBinaryPin clock, params IOutputBinaryPin[] data)
 {
     RegisterSelect = registerSelect;
     Clock          = clock;
     Data           = data;
 }
Esempio n. 29
0
 public UltrasonicDistanceSensor(int[] pin)
 {
     triggerPin = driver.Out(Utilities.getPin(pin[0]));
     echoPin    = driver.In(Utilities.getPin(pin[1]));
 }