Esempio n. 1
0
 /// <summary>
 /// UltrasonicSensor constructor
 /// </summary>
 /// <param name="grovePi">The GrovePi class</param>
 /// <param name="port">The grove Port, need to be in the list of SupportedPorts</param>
 public UltrasonicSensor(GrovePi grovePi, GrovePort port)
 {
     if (!SupportedPorts.Contains(port))
     {
         throw new ArgumentException($"Grove port {port} not supported.", nameof(port));
     }
     _grovePi = grovePi;
     _port    = port;
 }
Esempio n. 2
0
 /// <summary>
 /// AnalogSensor constructor
 /// </summary>
 /// <param name="grovePi">The GrovePi class</param>
 /// <param name="port">The grove Port, need to be in the list of SupportedPorts</param>
 public AnalogSensor(GrovePi grovePi, GrovePort port)
 {
     if (!SupportedPorts.Contains(port))
     {
         throw new ArgumentException($"Grove port {port} not supported.", nameof(port));
     }
     _grovePi = grovePi;
     _port    = port;
     _grovePi.PinMode(_port, PinMode.Input);
 }
Esempio n. 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="goPiGo">The GoPiGo3 class</param>
 /// <param name="port">The Grove Port, need to be in the list of SupportedPorts</param>
 public UltraSonicSensor(GoPiGo goPiGo, GrovePort port)
 {
     if (!SupportedPorts.Contains(port))
     {
         throw new ArgumentException($"Error: Grove Port not supported");
     }
     _goPiGo = goPiGo;
     Port    = port;
     _goPiGo.SetGroveType(port, GroveSensorType.Ultrasonic);
 }
Esempio n. 4
0
 /// <summary>
 /// PwmOutput constructor
 /// </summary>
 /// <param name="grovePi">The GrovePi class</param>
 /// <param name="port">The grove Port, need to be in the list of SupportedPorts</param>
 public PwmOutput(GrovePi grovePi, GrovePort port)
 {
     if (!SupportedPorts.Contains(port))
     {
         throw new ArgumentException($"Grove port {port} not supported.", nameof(port));
     }
     _grovePi = grovePi;
     _port    = port;
     _grovePi.PinMode(_port, PinMode.Output);
     Value = 0;
 }
Esempio n. 5
0
        /// <summary>
        /// DigitalInput constructor
        /// </summary>
        /// <param name="grovePi">The GrovePi class</param>
        /// <param name="port">The grove Port, need to be in the list of SupportedPorts</param>
        public DigitalInput(GrovePi grovePi, GrovePort port)
        {
            if (!SupportedPorts.Contains(port))
            {
                throw new ArgumentException(nameof(port), "Grove port not supported");
            }

            _grovePi = grovePi;
            Port     = port;
            _grovePi.PinMode(Port, PinMode.Input);
        }
Esempio n. 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="goPiGo">The GoPiGo3 class</param>
 /// <param name="port">The Grove Port, need to be in the list of SupportedPorts</param>
 public DigitalInput(GoPiGo goPiGo, GrovePort port)
 {
     if (!SupportedPorts.Contains(port))
     {
         throw new ArgumentException($"Error: Grove Port not supported");
     }
     _goPiGo = goPiGo;
     Port    = port;
     _goPiGo.SetGroveType(port, GroveSensorType.Custom);
     _mode = (port == GrovePort.Grove1) ? GrovePort.Grove1Pin1 : GrovePort.Grove2Pin1;
     _goPiGo.SetGroveMode(_mode, GroveInputOutput.InputDigital);
 }
Esempio n. 7
0
 /// <summary>
 /// LedBar constructor
 /// </summary>
 /// <param name="grovePi">The GrovePi class</param>
 /// <param name="port">The grove Port, need to be in the list of SupportedPorts</param>
 /// <param name="orientation">Orientation, Green to red is default</param>
 public LedBar(GrovePi grovePi, GrovePort port, LedBarOrientation orientation)
 {
     if (!SupportedPorts.Contains(port))
     {
         throw new ArgumentException($"Grove port {port} not supported.", nameof(port));
     }
     _grovePi     = grovePi;
     _port        = port;
     _orientation = orientation;
     _grovePi.WriteCommand(GrovePiCommand.LedBarInitialization, port, (byte)_orientation, 0);
     _level = 0;
 }
Esempio n. 8
0
 /// <summary>
 /// Initialize the DHT Sensor class
 /// </summary>
 /// <param name="grovePi">The GrovePi class</param>
 /// <param name="port">The grove Port, need to be in the list of SupportedPorts</param>
 /// <param name="dhtType">The DHT type</param>
 public DhtSensor(GrovePi grovePi, GrovePort port, DhtType dhtType)
 {
     if (!SupportedPorts.Contains(port))
     {
         throw new ArgumentException($"Grove port {port} not supported.", nameof(port));
     }
     _grovePi = grovePi;
     DhtType  = dhtType;
     _port    = port;
     // Ask for the temperature so we will have one in cache
     _grovePi.WriteCommand(GrovePiCommand.DhtTemp, _port, (byte)DhtType, 0);
 }
Esempio n. 9
0
        /// <summary>
        /// Constructor for the generic Analog Sensor
        /// </summary>
        /// <param name="goPiGo">The GoPiGo3 class</param>
        /// <param name="port">The Grove Port, need to be in the list of SupportedPorts</param>
        public AnalogSensor(GoPiGo goPiGo, GrovePort port)
        {
            if (!SupportedPorts.Contains(port))
            {
                throw new ArgumentException(nameof(port), "Grove port not supported");
            }

            _goPiGo = goPiGo;
            Port    = port;
            _goPiGo.SetGroveType(port, GroveSensorType.Custom);
            _goPiGo.SetGroveMode(port, GroveInputOutput.InputAnalog);
            _mode = Port == GrovePort.Grove1 ? GrovePort.Grove1Pin1 : GrovePort.Grove2Pin1;
        }
Esempio n. 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="goPiGo">The GoPiGo3 class</param>
 /// <param name="port">The Grove Port, need to be in the list of SupportedPorts</param>
 /// <param name="duty">The PWM duty to use to generate the sound from 0 to 100</param>
 public Buzzer(GoPiGo goPiGo, GrovePort port, byte duty)
 {
     if (!SupportedPorts.Contains(port))
     {
         throw new ArgumentException($"Error: Grove Port not supported");
     }
     _goPiGo = goPiGo;
     Port    = port;
     _goPiGo.SetGroveType(port, GroveSensorType.Custom);
     _mode = (port == GrovePort.Grove1) ? GrovePort.Grove1Pin1 : GrovePort.Grove2Pin1;
     _goPiGo.SetGroveMode(_mode, GroveInputOutput.OutputPwm);
     Duty  = duty;
     Value = 24_000; //The default value
     Stop();
 }