void echo_Interrupt(GT.SocketInterfaces.InterruptInput sender, bool value)
        {
            Debug.Print("interrupt occurred");
            if (first == true)
            {
                start_interval = timer2.Milliseconds;
                Debug.Print("time1: " + start_interval);

                first = false;
            }
            else
            {
                end_interval = timer2.Milliseconds;
                Debug.Print("time2: " + end_interval);
                interval = end_interval - start_interval; // in ms
                distance = 0.034 * (interval / 2);        // in cm       (or also 0,01715*interval)
                if (interval > 38000)                     //out of range
                {
                    interval = -1;                        //remove this if with the average mode
                }

                Debug.Print("Distance: " + distance + " cm");
            }

            // UPGRADE CODE WITH AVERAGE
            //interval[i] = end_interval - start_interval;
            //i++;
            //if(if==10)
            //{
            //  for(int j=0; J<10; j++)
            //      {
            //          mean_interval=mean_interval+interval[i];
            //}
        }
Beispiel #2
0
        public PIR_Module(Extender extender, DomoteerWebServer server)
        {
            this.server          = server;
            this.extender        = extender;
            interrupt            = extender.CreateInterruptInput(GT.Socket.Pin.Three, GT.SocketInterfaces.GlitchFilterMode.Off, GT.SocketInterfaces.ResistorMode.PullUp, GT.SocketInterfaces.InterruptMode.FallingEdge);
            interrupt.Interrupt += new GT.SocketInterfaces.InterruptEventHandler(mov_det);

            timer_cross       = new GT.Timer(20000);
            timer_cross.Tick += new GT.Timer.TickEventHandler(Timer_Cross_Tick);
        }
        void ProgramStarted()
        {
            trigger = breakout.CreateDigitalOutput(GT.Socket.Pin.Four, false);                                                                                                                                        //trigger down
            echo    = breakout.CreateInterruptInput(GT.Socket.Pin.Five, GT.SocketInterfaces.GlitchFilterMode.Off, GT.SocketInterfaces.ResistorMode.Disabled, GT.SocketInterfaces.InterruptMode.RisingAndFallingEdge); //echo

            trigger.Write(false);
            first = false;

            GT.Timer timer = new GT.Timer(10000);
            timer.Tick += timer_Tick;
            timer.Start();

            Debug.Print("Program Started");
        }
Beispiel #4
0
 public void mov_det(GT.SocketInterfaces.InterruptInput input, bool value)
 {
     if (!value)
     {
         if (count == 0)
         {
             timer_cross.Start();
             count++;
         }
         else
         {
             timer_cross.Restart();
         }
     }
 }