private void InitGrovePi()
        {
            System.Diagnostics.Debug.WriteLine(DeviceFactory.Build.GrovePi().GetFirmwareVersion());

            GroveRotary = DeviceFactory.Build.RotaryAngleSensor(Pin.AnalogPin0);
            GroveSound  = DeviceFactory.Build.SoundSensor(Pin.AnalogPin1);
            GroveLight  = DeviceFactory.Build.LightSensor(Pin.AnalogPin2);

            GroveRelay    = DeviceFactory.Build.Relay(Pin.DigitalPin2);
            GroveTempHumi = DeviceFactory.Build.DHTTemperatureAndHumiditySensor(Pin.DigitalPin3, DHTModel.Dht11);
            GroveRanger   = DeviceFactory.Build.UltraSonicSensor(Pin.DigitalPin4);
            GroveLedBar   = DeviceFactory.Build.BuildLedBar(Pin.DigitalPin5);
            GroveBuzzer   = DeviceFactory.Build.Buzzer(Pin.DigitalPin6);
            GroveButton   = DeviceFactory.Build.ButtonSensor(Pin.DigitalPin7);
            GroveLCD      = DeviceFactory.Build.RgbLcdDisplay();

            GroveLedBar.Initialize(GrovePi.Sensors.Orientation.GreenToRed);
            GroveLCD.SetBacklightRgb(255, 50, 255);

            DeviceFactory.Build.GrovePi().PinMode(Pin.DigitalPin2, PinMode.Output);
            Delay.Milliseconds(10);
            DeviceFactory.Build.GrovePi().Flush();

            DeviceFactory.Build.GrovePi().PinMode(Pin.DigitalPin6, PinMode.Output);
            Delay.Milliseconds(10);
            DeviceFactory.Build.GrovePi().Flush();
        }
Exemplo n.º 2
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            //
            // TODO: Insert code to perform background work
            //
            // If you start any asynchronous methods here, prevent the task
            // from closing prematurely by using BackgroundTaskDeferral as
            // described in http://aka.ms/backgroundtaskdeferral
            //

            _deferral = taskInstance.GetDeferral();

            // set the security for fms, and hook into fms
            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            fmserver = GetFMSInstance();

            // get the sensors
            lightSensor = DeviceFactory.Build.LightSensor(Pin.AnalogPin0);
            soundSensor = DeviceFactory.Build.SoundSensor(Pin.AnalogPin2);
            leds        = DeviceFactory.Build.BuildLedBar(Pin.DigitalPin8);
            leds.Initialize(GrovePi.Sensors.Orientation.GreenToRed);

            // start the timer
            ThreadPoolTimer timer = ThreadPoolTimer.CreatePeriodicTimer(Timer_Tick, TimeSpan.FromSeconds(1));
        }
        private void InitGrovePi()
        {
            System.Diagnostics.Debug.WriteLine(DeviceFactory.Build.GrovePi().GetFirmwareVersion());

            GroveRotary = DeviceFactory.Build.RotaryAngleSensor(Pin.AnalogPin0);
            GroveSound = DeviceFactory.Build.SoundSensor(Pin.AnalogPin1);
            GroveLight = DeviceFactory.Build.LightSensor(Pin.AnalogPin2);

            GroveRelay = DeviceFactory.Build.Relay(Pin.DigitalPin2);
            GroveTempHumi = DeviceFactory.Build.DHTTemperatureAndHumiditySensor(Pin.DigitalPin3, DHTModel.Dht11);
            GroveRanger = DeviceFactory.Build.UltraSonicSensor(Pin.DigitalPin4);
            GroveLedBar = DeviceFactory.Build.BuildLedBar(Pin.DigitalPin5);
            GroveBuzzer = DeviceFactory.Build.Buzzer(Pin.DigitalPin6);
            GroveButton = DeviceFactory.Build.ButtonSensor(Pin.DigitalPin7);
            GroveLCD = DeviceFactory.Build.RgbLcdDisplay();

            GroveLedBar.Initialize(GrovePi.Sensors.Orientation.GreenToRed);
            GroveLCD.SetBacklightRgb(255, 50, 255);

            DeviceFactory.Build.GrovePi().PinMode(Pin.DigitalPin2, PinMode.Output);
            Delay.Milliseconds(10);
            DeviceFactory.Build.GrovePi().Flush();

            DeviceFactory.Build.GrovePi().PinMode(Pin.DigitalPin6, PinMode.Output);
            Delay.Milliseconds(10);
            DeviceFactory.Build.GrovePi().Flush();
        }