uikolas

Untitled

Oct 6th, 2014
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.11 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Threading;
  4. using Microsoft.SPOT;
  5. using Microsoft.SPOT.Presentation;
  6. using Microsoft.SPOT.Presentation.Controls;
  7. using Microsoft.SPOT.Presentation.Media;
  8. using Microsoft.SPOT.Touch;
  9.  
  10. using Gadgeteer.Networking;
  11. using GT = Gadgeteer;
  12. using GTM = Gadgeteer.Modules;
  13. using Gadgeteer.Modules.GHIElectronics;
  14.  
  15. namespace GadgetProject02
  16. {
  17.     public partial class Program
  18.     {
  19.         private DateTime startTime;
  20.         private bool sensorState;
  21.  
  22.         void ProgramStarted()
  23.         {
  24.             Debug.Print("Program Started");
  25.             //camera.TakePicture();
  26.            
  27.             startTime = DateTime.Now;
  28.             //sensorState = motion_Sensor.SensorStillActive;
  29.             motion_Sensor.Motion_Sensed += new GTM.GHIElectronics.Motion_Sensor.Motion_SensorEventHandler(motion_Sensor_Motion_Sensed);
  30.             /*GT.Timer tmr = new GT.Timer(50, GT.Timer.BehaviorType.RunContinuously);
  31.             tmr.Tick += new GT.Timer.TickEventHandler(tmr_Tick);
  32.             tmr.Start();*/
  33.             camera.PictureCaptured += new Camera.PictureCapturedEventHandler(camera_PictureCaptured);
  34.         }
  35.  
  36.  
  37.         void tmr_Tick(GT.Timer timer)
  38.         {
  39.             if (motion_Sensor.SensorStillActive != sensorState)
  40.             {
  41.                 Debug.Print("State changed to: " + motion_Sensor.SensorStillActive + " @ " + (DateTime.UtcNow - startTime).ToString());
  42.                 sensorState = motion_Sensor.SensorStillActive;
  43.             }
  44.         }
  45.  
  46.         void motion_Sensor_Motion_Sensed(GTM.GHIElectronics.Motion_Sensor sender, GTM.GHIElectronics.Motion_Sensor.Motion_SensorState state)
  47.         {
  48.             Debug.Print("Time span = " + (DateTime.UtcNow - startTime).ToString());
  49.             startTime = DateTime.UtcNow;
  50.             Debug.Print("TRIGGER");
  51.             camera.TakePicture();
  52.         }
  53.  
  54.         void camera_PictureCaptured(Camera sender, GT.Picture picture)
  55.         {
  56.             //throw new NotImplementedException();
  57.             display_T35.SimpleGraphics.DisplayImage(picture, 0, 0); // rodo vaizda
  58.         }
  59.  
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment