Пример #1
0
        public static void Main()
        {
            // HUMIDITY & TEMPERATURE
            // ----------------------
            var RHT03 = new Dht22Sensor(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1, PullUpResistor.Internal);

            Thread.Sleep(2000);

            WebServer w = new WebServer(80, 10000);

            w.Start();
            w.CommandReceived += delegate(object o, WebServer.WebServerEventArgs e)
            {
                //WebServer.OutPutStream(e.response, e.rawURL);
                if (RHT03.Read())
                {
                    var    temperatureCelsius = RHT03.Temperature;
                    var    humidity           = RHT03.Humidity;
                    string answer             = "DHT Sensor: RH = " + humidity.ToString("F1") + "%  Temp = " + temperatureCelsius.ToString("F1") + "°C ";
                    Debug.Print(answer);
                    WebServer.OutPutStream(e.response, answer);
                }
            };


            // INFRA RED
            // ---------
            //// Declare our remote control input pin
            RC_In.OnInterrupt += new NativeEventHandler(RC_In_OnInterrupt);

            //// Set the RC6 decoder's input pin to the one we just declared, and create an event handler for the code.
            //RC6_Decoder.RemoteInputPin = RC_In;
            //RC6_Decoder.CodeReceived += new CodeReceivedEventHandler(RC6_Decoder_CodeReceived);

            // NEC

            var necRemoteControlDecoder = new NecProtocolDecoder(Pins.GPIO_PIN_D7);

            NecProtocolDecoder.OnIRCommandReceived += necRemoteControlDecoder_OnIrCommandReceived;


            // LOOP INFINITO
            // -------------
            while (true)
            {
                //if (RHT03.Read())
                //{
                //    var temperatureCelsius = RHT03.Temperature;
                //    var humidity = RHT03.Humidity;
                //    Debug.Print("DHT sensor Read() ok, RH = " + humidity.ToString("F1") + "%, Temp = " + temperatureCelsius.ToString("F1") + "°C " + (temperatureCelsius * 1.8 + 32).ToString("F1") + "°F");
                //}

                //    Thread.Sleep(2000);
            }

            //var RHT03 = new TemperatureSensor(Cpu.AnalogChannel.ANALOG_0);
            //var temp = RHT03.Temperature;
        }
Пример #2
0
        // Event handler for the RC6 pin's code event. Just pass everything to the handler in the RC6 decoder class
        static void RC_In_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            //RC6_Decoder.Record_Pulse(data1, data2, time);

            NecProtocolDecoder.OnInterrupt(data1, data2, time);
        }