Exemplo n.º 1
0
        public Component()
        {
            client = new HttpClient();
            // Create connection object
            _ipConnection = new IPConnection();

            // Create device objects
            _dualButtonBricklet  = new BrickletDualButton(DualButtonUID, _ipConnection);
            _lcdBricklet         = new BrickletLCD20x4(DisplayUID, _ipConnection);
            _temperatureBricklet = new BrickletTemperature(TemperatureUID, _ipConnection);
            _humidityBricklet    = new BrickletHumidity(HumidityUID, _ipConnection);
            _linearPoti          = new BrickletLinearPoti(LinearPotiUID, _ipConnection);
            _rgbButton           = new BrickletRGBLEDButton(RGBButtonUID, _ipConnection);
            _rotaryPoti          = new BrickletRotaryPoti(RotaryPotiUID, _ipConnection);
            _segmentDisplay      = new BrickletSegmentDisplay4x7(SegmentUID, _ipConnection);
            _motionDetector      = new BrickletMotionDetectorV2(motionDetectorUID, _ipConnection);
            _multiTouch          = new BrickletMultiTouch(multiTouchUID, _ipConnection);

            //register listeners
            _dualButtonBricklet.StateChangedCallback += DualButtonStateChanged;

            //register callback
            _linearPoti.PositionCallback                += PositionCb;
            _rotaryPoti.PositionCallback                += PositionRCB;
            _motionDetector.MotionDetectedCallback      += MotionDetectedCB;
            _motionDetector.DetectionCycleEndedCallback += DetectionCycleEndedCB;
            _multiTouch.TouchStateCallback              += TouchStateCB;
        }
    private static string UID  = "XYZ";    // Change XYZ to the UID of your Motion Detector Bricklet 2.0

    static void Main()
    {
        IPConnection             ipcon = new IPConnection(); // Create IP connection
        BrickletMotionDetectorV2 md    =
            new BrickletMotionDetectorV2(UID, ipcon);        // Create device object

        ipcon.Connect(HOST, PORT);                           // Connect to brickd
        // Don't use device before ipcon is connected

        // Turn blue backlight LEDs on (maximum brightness)
        md.SetIndicator(255, 255, 255);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
Exemplo n.º 3
0
        //motion detector
        public void MotionDetectedCB(BrickletMotionDetectorV2 sender)
        {
            counter++;
            Console.WriteLine($"Motion Detected => count: {counter} \n(next detection possible in ~2 seconds)");

            if (ButtonActive == true)
            {
                MoveCount++;
                _lcdBricklet.ClearDisplay();
                _lcdBricklet.WriteLine(0, 0,
                                       "Temperature: " + Convert.ToString(ReadTemperature() / 100.0) + UTF16ToKS0066U("°C"));
                _lcdBricklet.WriteLine(1, 0,
                                       "Humidity: " + Convert.ToString(ReadHumidity() / 100.0) + UTF16ToKS0066U("%"));

                _lcdBricklet.WriteLine(3, 0, "Move count: " + MoveCount);
            }
        }
    static void Main()
    {
        IPConnection             ipcon = new IPConnection(); // Create IP connection
        BrickletMotionDetectorV2 md    =
            new BrickletMotionDetectorV2(UID, ipcon);        // Create device object

        ipcon.Connect(HOST, PORT);                           // Connect to brickd
        // Don't use device before ipcon is connected

        // Register motion detected callback to function MotionDetectedCB
        md.MotionDetectedCallback += MotionDetectedCB;

        // Register detection cycle ended callback to function DetectionCycleEndedCB
        md.DetectionCycleEndedCallback += DetectionCycleEndedCB;

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
 // Callback function for detection cycle ended callback
 static void DetectionCycleEndedCB(BrickletMotionDetectorV2 sender)
 {
     Console.WriteLine("Detection Cycle Ended (next detection possible in ~2 seconds)");
 }
    private static string UID  = "XYZ";    // Change XYZ to the UID of your Motion Detector Bricklet 2.0

    // Callback function for motion detected callback
    static void MotionDetectedCB(BrickletMotionDetectorV2 sender)
    {
        Console.WriteLine("Motion Detected");
    }
Exemplo n.º 7
0
 public void DetectionCycleEndedCB(BrickletMotionDetectorV2 sender)
 {
     Console.WriteLine("Detection Cycle Ended");
 }
Exemplo n.º 8
0
 private void MotionEmit(BrickletMotionDetectorV2 sender)
 {
     _counter++;
 }