Example #1
1
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            _bluetooth = new Bluetooth(4);
            _bluetooth.DebugPrintEnabled = true;
            _client = _bluetooth.ClientMode;
            _bluetooth.SetDeviceName("Gadgeteer");
            _bluetooth.SetPinCode("1234");
            _bluetooth.DataReceived += bluetooth_DataReceived;

            button.ButtonPressed += (sender, state) => _client.EnterPairingMode();

            var monitor = new GT.Timer(500);
            monitor.Tick += timer =>
                {
                    if (_bluetooth.IsConnected)
                    {
                        //_client.Send("xxx");
                    }
                };
            monitor.Start();
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            var sensePuss = new GT.Timer(1000);
            sensePuss.Tick += timer =>
                {
                    relays.Relay3 = moistureSensor.GetMoistureReading() > 500;
                    Debug.Print(moistureSensor.GetMoistureReading().ToString());
                };
            sensePuss.Start();
        }
Example #2
0
        void start(GT.Timer timer)
        {
            t.Stop();

            if (!wifi_RS21.Interface.IsOpen)
            {
                wifi_RS21.Interface.Open();
            }
            if (!wifi_RS21.Interface.NetworkInterface.IsDhcpEnabled)
            {
                wifi_RS21.Interface.NetworkInterface.EnableDhcp();
            }

            // to use hold the network to connect to
            //GHI.Premium.Net.WiFiNetworkInfo[] info = null;
            wifi_RS21.NetworkDown += new GT.Modules.Module.NetworkModule.NetworkEventHandler(wifi_NetworkDown);
            wifi_RS21.NetworkUp   += new GT.Modules.Module.NetworkModule.NetworkEventHandler(wifi_NetworkUp);
            wifi_RS21.Interface.NetworkAddressChanged += Interface_NetworkAddressChanged;

            wifi_RS21.UseDHCP();
            GHI.Premium.Net.WiFiNetworkInfo[] info = null;
            info = wifi_RS21.Interface.Scan("AndroidNexus");

            wifi_RS21.Interface.Join(info[0], "17533355k");
        }
Example #3
0
 public Wifi(Gadgeteer.Modules.GHIElectronics.WiFi_RS21 wifi_RS21)
 {
     this.wifi_RS21 = wifi_RS21;
     t       = new GT.Timer(3000);
     t.Tick += new GT.Timer.TickEventHandler(start);
     t.Start();
 }
Example #4
0
 public Wifi(Gadgeteer.Modules.GHIElectronics.WiFi_RS21 wifi_RS21)
 {
     this.wifi_RS21 = wifi_RS21;
     t = new GT.Timer(3000);
     t.Tick += new GT.Timer.TickEventHandler(start);
     t.Start();
 }
        void jt_Tick(GT.Timer timer)
        {
            Joystick.Position position = joystick.GetPosition();

            if (didJoystickMove(position))
            {
                if (position.Y > .9)
                {
                    upEventFired();
                }
                else if (position.Y < -.9)
                {
                    downEventFired();
                }
                else if (position.X > .9)
                {
                    rightEventFired();
                }
                else if (position.X < -.9)
                {
                    leftEventFired();
                }

                lastJoystickPosition = position;
            }
        }
Example #6
0
        void ProgramStarted()
        {
            Debug.Print("Initialization Started: " + DateTime.Now);
            Microsoft.SPOT.Hardware.PowerState.ChangePowerLevel(Microsoft.SPOT.Hardware.PowerLevel.High);
            led1.TurnRed();
            led2.TurnOff();

            sdCard.SDCardMounted += sdCard_SDCardMounted;
            sdCard.SDCardUnmounted += sdCard_SDCardUnmounted;

            rfid.CardIDReceived += rfid_CardIDReceived;
            rfid.CardIDBadChecksum += rfid_CardIDBadChecksum;

            try
            {
                rs232.Initialize(38400, GTI.Serial.SerialParity.None, GTI.Serial.SerialStopBits.None, 8, GTI.Serial.HardwareFlowControl.NotRequired);
                rs232.serialPort.DataReceived += serialPort_DataReceived;
                rs232.serialPort.LineReceived += serialPort_LineReceived;
            }
            catch (Exception exc)
            {
                Debug.Print("failed to init rs232: " + exc.Message);
            }

            GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
            timer.Tick += timer_Tick;
            timer.Start();

            Debug.Print("Program Started: " + DateTime.Now);
        }
Example #7
0
        void ProgramStarted()
        {

            this.last = new Point(0, 0);
            this.touched = false;

            this.displayCP7.ScreenPressed += this.OnScreenPressed;
            this.displayCP7.ScreenReleased += this.OnScreenReleased;
            this.displayCP7.GestureDetected += this.OnGesureDetected;

            Glide.FitToScreen = true;

            Debug.Print("Program Started");

            mainWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.mainWindow));
            Image image = (Image)mainWindow.GetChildByName("earthImage");

            image.Bitmap = new Bitmap(Resources.GetBytes(Resources.BinaryResources.main),Bitmap.BitmapImageType.Jpeg);
            mainWindow.BackColor = Microsoft.SPOT.Presentation.Media.Color.White;
            Glide.MainWindow = mainWindow;

            DateTime dateTime = new DateTime(2015, 12, 18, 20, 53, 0);
            Utility.SetLocalTime(dateTime);
            RealTimeClock.SetDateTime(dateTime);

            GHI.Glide.UI.Button myText = (GHI.Glide.UI.Button)mainWindow.GetChildByName("keyboard");
            myText.PressEvent += new OnPress(Glide.OpenKeyboard);

            Gadgeteer.Timer timer = new Gadgeteer.Timer(500);

            timer.Tick += TimerTick;
            timer.Start();
        }
Example #8
0
        void setTimerInterval(int newIntervalPosition)
        {
            intervalPosition = newIntervalPosition;
            TimeSpan interval = new TimeSpan(0, 0, 0, 0, intervals[intervalPosition] * 1000);

            if (timer != null)
            {
                timer.Stop();
            }
            else
            {
                timer       = new GT.Timer(interval);
                timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
            }

            if (intervalPosition == 0)
            {
                DisplayMessage("Camera Off");
            }
            else
            {
                timer.Interval = interval;
                timer.Start();

                DisplayMessage("Interval Set to: " + intervals[intervalPosition] + " seconds");
            }
        }
Example #9
0
 // Remove second window
 private void OnTick(GT.Timer timerAccessWindow)
 {
     if (running)
     {
         Dismiss();
     }
 }
        void snowFlakeTimer_Tick(GT.Timer timer)
        {
            snowflakeTopPosition += 5;
            //it means that it hit the ground
            if (snowflakeTopPosition >= 240)
            {
                missedSnowflakes++;
                Debug.Print("Missed: " + missedSnowflakes.ToString());
                ResetSnowflake();
            }

            if (missedSnowflakes == 3)
            {
                endLabel.TextContent = "GAME OVER!";
            }

            Random rnd = new Random();

            snowflakeLeftPosition += (rnd.Next(15) - 7);
            if (snowflakeLeftPosition < 10)
            {
                snowflakeLeftPosition = 0;
            }
            if (snowflakeLeftPosition > 300)
            {
                snowflakeLeftPosition = 300;
            }
            Canvas.SetLeft(snowflake, snowflakeLeftPosition);
            Canvas.SetTop(snowflake, snowflakeTopPosition);
        }
Example #11
0
 // This method is run when the mainboard is powered up or reset.
 void ProgramStarted()
 {
     Debug.Print("Program Started");
     GT.Timer timer = new GT.Timer(3000);
     timer.Tick += Timer_Tick;
     timer.Start();
 }
Example #12
0
 void tmrIdleTimer_Tick(GT.Timer timer)
 {
     tmrIdleTimer.Stop();
     window.Background = new SolidColorBrush(GT.Color.Black);
     currentTime       = timeMgr.UpdatedTime;
     window.Child      = ViewManager.IdleTimeView;
 }
Example #13
0
 private void  RetryServer(GT.Timer t)
 {
     server_available       = true;
     timerRetryServer.Tick -= RetryServer;
     timerRetryServer.Stop();
     return;
 }
Example #14
0
        void hideMessage_Tick(GT.Timer timer)
        {
            timer.Stop();

            label.Visibility        = Visibility.Collapsed;
            imageDisplay.Visibility = Visibility.Visible;
        }
        public SensorsHandler(USBHost usbHostObject, Button buttonObject)
        {
            // Set objects
            usbHost = usbHostObject;
            button  = buttonObject;

            // Initialize variables
            oldX             = oldY = "";
            oldTempC         = oldPressureMb = oldPressureMb = 0;
            lastWrittenX     = lastWrittenY = 0;
            wasMouseFailed   = wasSensorFailed = true;
            bme280Working    = false;
            isMouseConnected = false;

            // Setup USBHost patched module and get mouse if already connected
            InitMouse();

            // Setup bosch bme280 sensor
            Thread setupSensor = new Thread(InitSensor);

            setupSensor.Start();

            // Mouse timers
            GT.Timer mouseTimer = new GT.Timer(500);
            mouseTimer.Tick += mouseTimer_Tick;
            mouseTimer.Start();

            // Mouse persistence timer
            GT.Timer persistenceTimer = new GT.Timer(6000);
            persistenceTimer.Tick += persistenceTimer_Tick;
            persistenceTimer.Start();
        }
        /*
         * BOSCH SECTION
         */
        private void InitSensor()
        {
            bool isNotActivated = true;

            while (isNotActivated)
            {
                try
                {
                    bme280 = new BME280Device(0x76)
                    {
                        AltitudeInMeters = 239
                    };

                    isNotActivated = false;
                }
                catch (BME280Exception)
                {
                    Debug.Print("Error during BME280 initiliazation");
                }

                Thread.Sleep(5000);
            }

            // Sensor Timer
            GT.Timer sensorTimer = new GT.Timer(20000);
            sensorTimer.Tick += sensorTimer_Tick;
            sensorTimer.Start();

            // Show first bme280 reading
            sensorTimer_Tick(null);
        }
Example #17
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            display_HD44780 = new GTM.GHIElectronics.Display_HD44780(1);
            CheckForServiceUpdate();

            Display("Loading assembly", "");

            JayDayService.Service.Init(display_HD44780);
            JayDayService.Service.Run();
            //var bytes = Resources.GetBytes(Resources.BinaryResources.JayDayService);
            //var asm = Assembly.Load(bytes);
            //var t = asm.GetType("JayDayService.Service");
            //if (t != null)
            //{
            //    Display("Assembly Loaded", "Starting Service");
            //    serviceRun = t.GetMethod("Run");
            //    serviceInit = t.GetMethod("Init");
            //    serviceStop = t.GetMethod("Stop");
            //    // display is shared.
            //    serviceInit.Invoke(null, new object[] { display_HD44780 });
            //    serviceRun.Invoke(null, null);
            //    // PowerState.Reboot(true) .. to free up memory..
            //}

            timer = new GT.Timer(10000);
            timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
            timer.Start();
        }
Example #18
0
        //Breakout breakout = new Breakout(9);
        void timer_Tick(GT.Timer timer)
        {
            Debug.Print("--------");
            AnalogInput analogInput = breakout.CreateAnalogInput(GT.Socket.Pin.Three);

            Debug.Print("Voltage: " + analogInput.ReadVoltage().ToString());
        }
Example #19
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            _bluetooth = new Bluetooth(4);
            _bluetooth.DebugPrintEnabled = true;
            _client = _bluetooth.ClientMode;
            _bluetooth.SetDeviceName("Gadgeteer");
            _bluetooth.SetPinCode("1234");
            _bluetooth.DataReceived += bluetooth_DataReceived;

            button.ButtonPressed += (sender, state) => _client.EnterPairingMode();

            var monitor = new GT.Timer(500);

            monitor.Tick += timer =>
            {
                if (_bluetooth.IsConnected)
                {
                    //_client.Send("xxx");
                }
            };
            monitor.Start();
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            var sensePuss = new GT.Timer(1000);

            sensePuss.Tick += timer =>
            {
                relays.Relay3 = moistureSensor.GetMoistureReading() > 500;
                Debug.Print(moistureSensor.GetMoistureReading().ToString());
            };
            sensePuss.Start();
        }
Example #20
0
        void timer_Tick(GT.Timer timer)
        {
            var data = new SensorData()
            {
                Ph     = 1 + rnd.Next(10),
                Relay1 = rnd.Next(2) > 0 ? true : false,
                Relay2 = rnd.Next(2) > 0 ? true : false,
                Tds1   = 1 + rnd.Next(100),
                Tds2   = 1 + rnd.Next(100),
                Temp1  = 25 + rnd.Next(7), //.ConvertAndReadTemperature(),
                Temp2  = 25 + rnd.Next(8), //.ConvertAndReadTemperature(),
                //Temp3 = Temp3.ConvertAndReadTemperature(),
                WaterDist = 1 + rnd.Next(10)
            };
            //insert to db
            var item = new DataGridItem(new object[] { DateTime.Now.ToString("HH:mm:ss"), data.Temp1.ToString("n2") + "C", data.Temp2.ToString("n2") + "C", data.WaterDist.ToString("n2") + "CM", data.Tds1.ToString("n2"), data.Tds2.ToString("n2") });

            //add data to grid
            GvData.AddItem(item);
            GvData.Invalidate();
            if (counter++ > 9)
            {
                counter = 0;
                GvData.Clear();
            }

            var jsonStr = Json.NETMF.JsonSerializer.SerializeObject(data);

            Debug.Print("kirim :" + jsonStr);
            xBeeAdapter.Port.WriteLine(jsonStr);
        }
Example #21
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            /*******************************************************************************************
            Modules added in the Program.gadgeteer designer view are used by typing
            their name followed by a period, e.g.  button.  or  camera.

            Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
                button.ButtonPressed +=<tab><tab>

            If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
                GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
                timer.Tick +=<tab><tab>
                timer.Start();
            *******************************************************************************************/

            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            bluetooth.SetDeviceName("Gadgeteer");

            bluetooth.BluetoothStateChanged += new Bluetooth.BluetoothStateChangedHandler(bluetooth_BluetoothStateChanged);
            bluetooth.DataReceived += new Bluetooth.DataReceivedHandler(bluetooth_DataReceived);

            //The timer gives the device enough time to initialize.
            Gadgeteer.Timer timer = new Gadgeteer.Timer(1000, Gadgeteer.Timer.BehaviorType.RunOnce);
            timer.Tick += new Gadgeteer.Timer.TickEventHandler(timer_Tick);
            timer.Start();
        }
Example #22
0
        public WifiWidget(WiFi_RS21 wifi_RS21) : base()
        {
            this.font = Resources.GetFont(Resources.FontResources.small);
            this.x    = x;
            this.y    = y;
            background.set_position(0, 28);
            background.set_size(UserInterface.Instance.screen_width, UserInterface.Instance.screen_height - 28);
            background.set_colours(BackgroundColor, BorderColor);
            elements.Clear();
            elements.Add(background);


            // NetworkInterfaceExtension.AssignNetworkingStackTo((NetworkInterfaceExtension)wifi_RS21);
            this.wifi_RS21 = wifi_RS21;
            this.wifi_RS21.UseThisNetworkInterface();
            this.wifi_RS21.Interface.NetworkInterface.EnableDhcp();
            this.wifi_RS21.UseDHCP();
            this.wifi_RS21.NetworkDown += new GT.Modules.Module.NetworkModule.NetworkEventHandler(wifi_NetworkDown);
            this.wifi_RS21.NetworkUp   += new GT.Modules.Module.NetworkModule.NetworkEventHandler(wifi_NetworkUp);

            // connect to known wifi
            GT.Timer t = new GT.Timer(1000);
            t.Tick += new GT.Timer.TickEventHandler(t_Tick);
            t.Start();
        }
Example #23
0
 /// <summary>
 /// Send Database data
 /// </summary>
 /// <param name="timer">Timer</param>
 private void send_data(GT.Timer timer)
 {
     if (firstTime == true)
     {
         client.sendToBroker(configuration, -1, true);
         firstTime = false;
     }
     if (DateTime.Now.Year != 2011)
     {
         if (wifiRS21.IsNetworkConnected && broker != null)
         {
             Hashtable packet = new Hashtable();
             if ((packet = init.retriveData(sqldb)) != null)
             {
                 foreach (DictionaryEntry de in packet)
                 {
                     int    num  = (int)de.Key;
                     string json = (string)de.Value;
                     Debug.Print("sending....!");
                     client.sendToBroker(json, num, false);
                     Debug.Print("DATA SENDED!");
                 }
             }
         }
         else
         {
             Debug.Print("RECONNECTION");
             // wifiC = new WiFiConnection();
             // wifiC.WifiConnected += wifiC_WifiConnected;
             wifiC.connectToWiFI(wifiRS21, SSID, PASSWORD);
         }
     }
 }
Example #24
0
 // This method is run when the mainboard is powered up or reset.
 void ProgramStarted()
 {
     Debug.Print("Program Started");
     GT.Timer timer = new GT.Timer(3000);
     timer.Tick += Timer_Tick;
     timer.Start();
 }
Example #25
0
        /// <summary>
        /// Resumes the USB host controller from a suspended state.
        /// </summary>
        public void Wakeup()
        {
            lock (_lock)
            {
                if (!isAsleep)
                {
                    return;
                }

                if (_wakedt == null)
                {
                    _wakedt       = new Gadgeteer.Timer(_holdRI);
                    _wakedt.Tick += new Gadgeteer.Timer.TickEventHandler(wakedt_Tick);
                }

                if (!_wakedt.IsRunning && !_glitchdt.IsRunning)
                {
                    if (_glitchdt == null)
                    {
                        _glitchdt       = new Gadgeteer.Timer(_glitchTime);
                        _glitchdt.Tick += new Gadgeteer.Timer.TickEventHandler(_glitchdt_Tick);
                    }

                    //_RIBar.Write(false);
                    _wakedt.Start();
                    _glitchdt.Start();
                }
            }
        }
Example #26
0
 //led lampeggianti, per ora lo sono sempre all'avvio
 private void timer_led_lampeggianti(GT.Timer timer)
 {
     state = !state;
     ledStrip.SetLed(2, state);
     ledStrip.SetLed(3, state);
     ledStrip.SetLed(4, state);
 }
Example #27
0
        private void _SleepBar_Interrupt(Interfaces.InterruptInput input, bool value)
        {
            lock (_lock)
            {
                if (_glitchdt == null)
                {
                    _glitchdt       = new Gadgeteer.Timer(_glitchTime);
                    _glitchdt.Tick += new Gadgeteer.Timer.TickEventHandler(_glitchdt_Tick);
                }

                bool sleeping = isAsleep;
                if (!_glitchdt.IsRunning || _isAsleepLastSent == true && !sleeping)
                {
                    _isAsleepLastSent = sleeping;
                    OnPowerStateChangedEvent(this, _isAsleepLastSent);
                }
                else
                {
                    // filter out all but first "awake" event while glitch filter is running
                }
                if (_glitchdt.IsRunning)
                {
                    // reset the timer interval
                    _glitchdt.Start();
                }
            }
        }
Example #28
0
        GT.Timer timerPictureCaptured;                                      // every second (1000ms)

        void ProgramStarted()
        {
            /*******************************************************************************************
            *  Modules added in the Program.gadgeteer designer view are used by typing
            *  their name followed by a period, e.g.  button.  or  camera.
            *
            *  Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
            *   button.ButtonPressed +=<tab><tab>
            *
            *  If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
            *   GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
            *   timer.Tick +=<tab><tab>
            *   timer.Start();
            *******************************************************************************************/


            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            //Timer
            timer.Tick += timer_Tick;
            timer.Start();
            timerPictureCaptured       = new GT.Timer(9000);
            timerPictureCaptured.Tick += timerPictureCaptured_Tick;
            timerPictureCaptured.Start();

            //Load windows
            mainWindow        = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.MainWindow));
            resultWindow      = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.ResultWindow));
            cameraWindow      = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.CameraWindow));
            BtnLeer           = (GHI.Glide.UI.Button)resultWindow.GetChildByName("BtnLeer");
            BtnLeer.TapEvent += BtnLeer_TapEvent;
            GlideTouch.Initialize();
            Glide.MainWindow = mainWindow;



            button.ButtonPressed += button_ButtonPressed;

            //Conexion a Internet
            this.ethernetJ11D.NetworkInterface.Open();
            //this.ethernetJ11D.NetworkInterface.EnableStaticIP("200.9.176.102", "255.255.255.128", "200.9.176.2");

            this.ethernetJ11D.NetworkInterface.EnableDhcp();
            //this.ethernetJ11D.UseStaticIP("200.9.176.102", "255.255.255.128","200.9.176.2");
            this.ethernetJ11D.UseThisNetworkInterface();
            this.ethernetJ11D.NetworkDown += ethernetJ11D_NetworkDown;
            this.ethernetJ11D.NetworkUp   += ethernetJ11D_NetworkUp;



            //Funciones de Camara
            camera.BitmapStreamed  += camera_BitmapStreamed;
            camera.CameraConnected += camera_CameraConnected;
            camera.PictureCaptured += camera_PictureCaptured;
            systemState             = State.Camera;

            //imagen del qr
            currentBitmap = new Bitmap(camera.CurrentPictureResolution.Width, camera.CurrentPictureResolution.Height);
        }
Example #29
0
 void timer_Tick(GT.Timer timer)
 {
     if (captureOn)
     {
         doMeasurement();
     }
 }
        void ProgramStarted()
        {
            var timer = new GT.Timer(50);

            timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
            timer.Start();
        }
Example #31
0
 void timer_Tick(GT.Timer timer)
 {
     if (camera.CameraReady)
     {
         camera.TakePicture();
     }
 }
Example #32
0
 /**
  * This method send periodic keep alive to server
  */
 private void keepAlive(GT.Timer timer)
 {
     Debug.Print("Keep Alive !");
     servertime += 35000;
     try
     {
         var data = proxy.keepAlive(new keepAlive()
         {
             myMacAddress  = myMac,
             mycurrentTime = servertime,
             port          = int.Parse(connectionInfo[1]),
         });
     }
     catch (SocketException e)
     {
         if (timer_keepAlive.IsRunning)
         {
             timer_keepAlive.Stop();
         }
         if (setupComplete)
         {
             if (!throw_allarm)
             {
                 ThrowAllarm();
             }
         }
     }
 }
Example #33
0
 private void pubOldTimer(int time = 20000)
 {
     GT.Timer timer = new GT.Timer(time);
     timer.Tick     += (s) => { s.Stop(); mqtt.PublishOld(MeasureOrchestrator.id); s.Start(); };
     MeasureDB.Timer = timer;
     timer.Start();
 }
 void wateringTimer_Tick(Timer timer)
 {
     // Stop watering
     _relayX1.TurnOff();
     _wateringTimer.Stop();
     _internetOfThingsService.PostStatus("Stopped watering.");
 }
Example #35
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            /*******************************************************************************************
            Modules added in the Program.gadgeteer designer view are used by typing
            their name followed by a period, e.g.  button.  or  camera.

            Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
                button.ButtonPressed +=<tab><tab>

            If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
                GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
                timer.Tick +=<tab><tab>
                timer.Start();
            *******************************************************************************************/

            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            var timer = new GT.Timer(250);
            timer.Tick += timer1 =>
            {
                if (!tripWire.TripWire1.Read()) Debug.Print("TripWire1");
                if (!tripWire.TripWire2.Read()) Debug.Print("TripWire2");
                if (!tripWire.TripWire3.Read()) Debug.Print("TripWire3");
                if (!tripWire.TripWire4.Read()) Debug.Print("TripWire4");
                if (!tripWire.TripWire5.Read()) Debug.Print("TripWire5");
                if (!tripWire.TripWire6.Read()) Debug.Print("TripWire6");
                if (!tripWire.TripWire7.Read()) Debug.Print("TripWire7");
            };
            timer.Start();
        }
        public WifiWidget(WiFi_RS21 wifi_RS21)
            : base()
        {
            this.font = Resources.GetFont(Resources.FontResources.small);
            this.x = x;
            this.y = y;
            background.set_position(0, 28);
            background.set_size(UserInterface.Instance.screen_width, UserInterface.Instance.screen_height - 28);
            background.set_colours(BackgroundColor, BorderColor);
            elements.Clear();
            elements.Add(background);

               // NetworkInterfaceExtension.AssignNetworkingStackTo((NetworkInterfaceExtension)wifi_RS21);
            this.wifi_RS21 = wifi_RS21;
            this.wifi_RS21.UseThisNetworkInterface();
            this.wifi_RS21.Interface.NetworkInterface.EnableDhcp();
            this.wifi_RS21.UseDHCP();
            this.wifi_RS21.NetworkDown += new GT.Modules.Module.NetworkModule.NetworkEventHandler(wifi_NetworkDown);
            this.wifi_RS21.NetworkUp += new GT.Modules.Module.NetworkModule.NetworkEventHandler(wifi_NetworkUp);

            // connect to known wifi
            GT.Timer t = new GT.Timer(1000);
            t.Tick += new GT.Timer.TickEventHandler(t_Tick);
            t.Start();
        }
Example #37
0
 private void setupJoystick()
 {
     joystick.Calibrate();
     timer_joystick       = new GT.Timer(200);
     timer_joystick.Tick += joystick_function;
     timer_joystick.Start();
 }
Example #38
0
        /// <summary>
        /// This timer event serves as the main sequencer of the program
        /// </summary>
        /// <param name="pbTimer">The GT.Timer who's calling (GT = Gadgeteer)</param>
        private void timer_Tick(GT.Timer pbTimer)
        {
            // Main menu
            if (_menuState == MENU_STATE.initial)
            {
                InitialState();
            }

            // Add card event
            if (_menuState == MENU_STATE.addCard)
            {
                AddCard();
            }

            // Delete card event
            if (_menuState == MENU_STATE.deleteCard)
            {
                DeleteCard();
            }

            // Display cards event
            if (_menuState == MENU_STATE.displayCards)
            {
                DisplayCards();
            }

            // Unlock with the secret code event
            if (_menuState == MENU_STATE.secretCode)
            {
                UnlockSecretCode();
            }
        }
Example #39
0
 private void pubTimer(int time = 20000)
 {
     GT.Timer timer = new GT.Timer(time);
     timer.Tick     += (s) => MeasureOrchestrator.publish();
     MeasureDB.Timer = timer;
     timer.Start();
 }
Example #40
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Gyro(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('I', this);

            this.readBuffer1  = new byte[1];
            this.writeBuffer1 = new byte[1];
            this.writeBuffer2 = new byte[2];
            this.readBuffer8  = new byte[8];

            this.offsetX = 0;
            this.offsetY = 0;
            this.offsetZ = 0;

            this.ready       = false;
            this.timer       = new GT.Timer(200);
            this.timer.Tick += (a) => this.TakeMeasurement();

            this.i2c = GTI.I2CBusFactory.Create(socket, 0x68, 100, this);

            this.interruptInput            = GTI.InterruptInputFactory.Create(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingEdge, this);
            this.interruptInput.Interrupt += this.OnInterrupt;

            this.SetFullScaleRange();
        }
Example #41
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Gyro(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);
            socket.EnsureTypeIsSupported('I', this);
            
            this.readBuffer1 = new byte[1];
            this.writeBuffer1 = new byte[1];
            this.writeBuffer2 = new byte[2];
            this.readBuffer8 = new byte[8];

            this.offsetX = 0;
            this.offsetY = 0;
            this.offsetZ = 0;

            this.ready = false;
            this.timer = new GT.Timer(200);
            this.timer.Tick += (a) => this.TakeMeasurement();

            this.i2c = GTI.I2CBusFactory.Create(socket, 0x68, 100, this);
            
            this.interruptInput = GTI.InterruptInputFactory.Create(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingEdge, this);
            this.interruptInput.Interrupt += this.OnInterrupt;

            this.SetFullScaleRange();
        }
Example #42
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            GT.Timer t = new GT.Timer(1000);
            t.Tick += new GT.Timer.TickEventHandler(connect);
            t.Start();

            Debug.Print("Program Started");
        }
 // This method is run when the mainboard is powered up or reset.
 void ProgramStarted()
 {
     Debug.Print("Program Started");
     FlashAllLedsOnce();
     var timer = new GT.Timer(100);
     timer.Tick += timer_Tick;
     timer.Start();
 }
 // This method is run when the mainboard is powered up or reset.
 void ProgramStarted()
 {
     joystick.JoystickPressed += new GTM.GHIElectronics.Joystick.JoystickEventHandler(joystick_JoystickPressed);
     button.ButtonPressed += new GTM.GHIElectronics.Button.ButtonEventHandler(button_ButtonPressed);
     GT.Timer timer = new GT.Timer(100);
     timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
     timer.Start();
 }
        public LedStripAnnunciator()
        {
            _ledStrip = new GTM.GHIElectronics.LEDStrip(11);

            GT.Timer timer = new GT.Timer(125); // Create a timer
            timer.Tick += Timer_Tick;
            timer.Start(); // Start the timer
        }
 public SensorProximidad(GTM.GHIElectronics.Extender extender)
 {
     //TODO: Inicializar el sensor
     input = extender.CreateAnalogInput(GT.Socket.Pin.Three);
     output = extender.CreateDigitalOutput(GT.Socket.Pin.Five, false);
     timer = new GT.Timer(1000);
     timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
     //timer.Start();
 }
Example #47
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            var timer = new GT.Timer(250);
            timer.Tick += timer1 => Debug.Print(moistureSensor.GetMoistureReading().ToString());
            timer.Start();
        }
Example #48
0
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            GT.Timer timer = new GT.Timer(200); // every second (1000ms)
            timer.Tick += timer_Tick;
            timer.Start();

            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");
        }
Example #49
0
 public Devices(Button button, Wifi wifi)
 {
     this.wifi = wifi;
     blueT = new Gadgeteer.Bluetooth(8);
     this.button = button;
     t = new GT.Timer(100);
     t.Tick += new GT.Timer.TickEventHandler(start);
     t.Start();
     Debug.Print("devices");
 }
Example #50
0
        private GT.Timer timer; // every second (1000ms)

        #endregion Fields

        #region Constructors

        public SensorProximidad(GTM.GHIElectronics.Extender extender)
        {
            //TODO: Inicializar el sensor

            entrada = extender.CreateAnalogInput(GT.Socket.Pin.Three);
            salida = extender.CreateDigitalOutput(GT.Socket.Pin.Five, false);
            timer = new GT.Timer(1000);
            timer.Tick += timer_Tick;
            estado = Estado.Ninguno;
        }
Example #51
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            Debug.Print("Program Started");

            _timer = new GT.Timer(1000);
            _timer.Tick += new GT.Timer.TickEventHandler(_timer_Tick);
            _timer.Start();

            //button.ButtonPressed += new GTM.GHIElectronics.Button.ButtonEventHandler(button_ButtonPressed);
        }
Example #52
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            Debug.Print("Program Started");

               GT.Socket thermoSocket = GT.Socket.GetSocket(thermoExtender.ExtenderSocketNumber, true, thermoExtender, null);
               thermometer = new DS18B20(thermoSocket.CpuPins[4]);

               var thermoTimer = new GT.Timer(1000);
               thermoTimer.Tick += timer => Debug.Print(thermometer.ConvertAndReadTemperature().ToString());
               thermoTimer.Start();
        }
        void timer_Tick(Timer timer)
        {
            Debug.Print("Checking if plants need watering...");
            bool waterPlants = ShouldWater();

            if (waterPlants)
            {
                Debug.Print("Watering plants.");
                _wateringService.Water();
            }
        }
Example #54
0
        public Monitor(TemperatureReader temperatureReader, ILoggerDisplay loggerDisplay)
        {
            _temperatureReader = temperatureReader;
            _temperatureReader.MeasurementComplete += TemperatureReaderMeasurementComplete;
            _temperatureReader.LightLevelMeasurementComplete += _temperatureReader_LightLevelMeasurementComplete;
            _loggerDisplay = loggerDisplay;
            _timer = new Timer(new TimeSpan(0, 0, 1, 0));
            _timer.Tick += _timer_Tick;

            Pressure = "2";
            _hasPressure = true;
        }
Example #55
0
        void ProgramStarted()
        {
            Debug.Print("Program Started");

            _roboticArmController = new RoboticArmController(PwmExtender, GT.Socket.Pin.Seven, GT.Socket.Pin.Eight, 20000000);

            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
            button.ButtonReleased +=new Button.ButtonEventHandler(button_ButtonReleased);

            _timer = new GT.Timer(500);
            _timer.Tick += new GT.Timer.TickEventHandler(_timer_Tick);
        }
        public WateringRulesEngine(
            IMeasurementService measurementService, 
            IWateringService wateringService, 
            IInternetOfThingsService internetOfThingsService)
        {
            _measurementService = measurementService;
            _wateringService = wateringService;
            _internetOfThingsService = internetOfThingsService;

            _timer = new Timer(new TimeSpan(0, 0, 0, 20));
            _timer.Tick += timer_Tick;
        }
        public CameraClass(Gadgeteer.Modules.GHIElectronics.Camera camera, Motion_Sensor motion_Sensor, Wifi wf)
        {
            this.wifi = wf;
            this.camera = camera;
            this.camera.CurrentPictureResolution = Camera.PictureResolution.Resolution160x120;
            this.motion_Sensor = motion_Sensor;
            this.motion_Sensor.Motion_Sensed += new GTM.Motion_Sensor.Motion_SensorEventHandler(motion_Sensor_Motion_Sensed);
            this.camera.PictureCaptured += new Camera.PictureCapturedEventHandler(camera_PictureCaptured);
            this.camera.DebugPrintEnabled = false;

            timer = new GT.Timer(sleepTime);
            timer.Tick += timer_Tick;
        }
Example #58
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            Debug.Print("Program Started");

            _relay = extender.SetupDigitalOutput(Socket.Pin.Three, _relayState);

            var timer = new GT.Timer(1000);
            timer.Tick += timer1 =>
                              {
                                  _relayState = !_relayState;
                                  _relay.Write(_relayState);
                              };
            timer.Start();
        }
        public MeasurementService(
            Moisture moistureSensor, 
            LightSense lightSensor, 
            IInternetOfThingsService internetOfThingsService)
        {
            _moistureSensor = moistureSensor;
            _lightSensor = lightSensor;
            _internetOfThingsService = internetOfThingsService;

            // Measure every second.
            _measurementsTimer = new Timer(new TimeSpan(0, 0, 0, 1));
            _measurementsTimer.Tick += measurementsTimer_Tick;
            _measurementsTimer.Start();
        }
        void measurementsTimer_Tick(Timer timer)
        {
            //Debug.Print("Measuring moisture and light levels");

            _currentMeasurement = new Measurement
            {
                MoistureLevel = _moistureSensor.ReadMoisture(),
                LightLevel = _lightSensor.ReadVoltage()
            };

            Debug.Print(_currentMeasurement.ToString());

            PostMeasurement();
        }