Esempio n. 1
0
        public MainPage()
        {
            InitializeComponent();
            Unloaded += MainPage_Unloaded;

            //Window.Current.CoreWindow.PointerCursor = null;

            connection = new RemoteConnection();
            connection.OnLedEvent(LedEvent);

            led = new MulticolorLed(redPinNumber: 18, greenPinNumber: 23, bluePinNumber: 24);
            humitureSensor = new Dht11HumitureSensor(pinNumber: 4);
            relay = new Relay(pinNumber: 16);

            motionDetector = new Sr501PirMotionDetector(pinNumber: 12);
            motionDetector.RaiseEventsOnUIThread = true;
            motionDetector.MotionDetected += MotionDetector_MotionDetected;
            motionDetector.MotionStopped += MotionDetector_MotionStopped;

            flameSensor = new FlameSensor(pinNumber: 27);
            flameSensor.RaiseEventsOnUIThread = true;
            flameSensor.FlameDetected += FlameSensor_FlameDetected;
            flameSensor.FlameExtinguished += FlameSensor_FlameExtinguished;

            timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(5) };
            timer.Tick += Timer_Tick;
        }
Esempio n. 2
0
        public MainPage()
        {
            InitializeComponent();
            Unloaded += MainPage_Unloaded;

            connection = new RemoteConnection();
            connection.OnLedEvent(LedEvent);

            led = new MulticolorLed(redPinNumber: 27, greenPinNumber: 22, bluePinNumber: 23);
        }
Esempio n. 3
0
        public MainPage()
        {
            this.InitializeComponent();
            Unloaded += MainPage_Unloaded;

            ultrasonic = new Sr04UltrasonicDistanceSensor(triggerPinNumber: 5, echoPinNumber: 6);
            ultrasonic.RaiseEventsOnUIThread = true;
            ultrasonic.DistanceChanged += ultrasonic_DistanceChanged;

            led = new MulticolorLed(redPinNumber: 18, greenPinNumber: 23, bluePinNumber: 24);
        }
Esempio n. 4
0
        public MainPage()
        {
            this.InitializeComponent();
            Unloaded += MainPage_Unloaded;

            led = new MulticolorLed(redPinNumber: 27, greenPinNumber: 22, bluePinNumber: 23);

            button = new PushButton(5, type: ButtonType.PullDown);
            button.Pressed += ButtonPressed;
            button.Click += ChangeColor;
            button.Released += ButtonReleased;
        }
Esempio n. 5
0
        public MainPage()
        {
            this.InitializeComponent();
            Unloaded += MainPage_Unloaded;

            led = new MulticolorLed(redPinNumber: 18, greenPinNumber: 23, bluePinNumber: 24);

            button = new PushButton(5);
            button.Pressed += ButtonPressed;
            button.Click += ChangeColor;
            button.Released += ButtonReleased;
        }
Esempio n. 6
0
        public MainPage()
        {
            InitializeComponent();
            Unloaded += MainPage_Unloaded;

            led = new MulticolorLed(redPinNumber: 27, greenPinNumber: 22, bluePinNumber: 23);

            pir = new Sr501PirMotionDetector(5);
            pir.RaiseEventsOnUIThread = true;
            pir.MotionDetected += pir_MotionDetected;
            pir.MotionStopped += pir_MotionStopped;
        }
Esempio n. 7
0
        public MainPage()
        {
            this.InitializeComponent();
            this.Unloaded += MainPage_Unloaded;

            led = new MulticolorLed(redPinNumber: 18, greenPinNumber: 23, bluePinNumber: 24);

            button = new PushButton(pinNumber: 26);
            button.RaiseEventsOnUIThread = true;
            button.Click += Button_Click;

            distanceSensor = new Sr04UltrasonicDistanceSensor(triggerPinNumber: 12, echoPinNumber: 16, mode: ReadingMode.Manual);

            var motorDriver = new L298nMotorDriver(motor1Pin1: 27, motor1Pin2: 22, motor2Pin1: 5, motor2Pin2: 6);
            motors = motorDriver.AsLeftRightMotors();

            rnd = new Random(unchecked((int)(DateTime.Now.Ticks)));

            moveTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(MOVE_INTERVAL_SEC) };
            moveTimer.Tick += MoveTimer_Tick;
        }
Esempio n. 8
0
        public MainPage()
        {
            this.InitializeComponent();
            Unloaded += MainPage_Unloaded;

            connection = new RemoteConnection();
            connection.OnRoverMovementEvent(RoverMovementEvent);

            var motorDriver = new L298nMotorDriver(motor1Pin1: 27, motor1Pin2: 22, motor2Pin1: 5, motor2Pin2: 6);
            motors = motorDriver.AsLeftRightMotors();

            led = new MulticolorLed(redPinNumber: 18, greenPinNumber: 23, bluePinNumber: 24);

            movements = new Dictionary<RoverMovementType, Action>
            {
                [RoverMovementType.Forward] = () => motors.MoveForward(),
                [RoverMovementType.Backward] = () => motors.MoveBackward(),
                [RoverMovementType.TurnLeft] = () => motors.TurnLeft(),
                [RoverMovementType.TurnRight] = () => motors.TurnRight(),
                [RoverMovementType.RotateLeft] = () => motors.RotateLeft(),
                [RoverMovementType.RotateRight] = () => motors.RotateRight(),
                [RoverMovementType.Stop] = () => motors.Stop()
            };
        }