Example #1
0
    private static string UID  = "XYZ";    // Change to your UID

    // Callback function for touch state
    static void TouchStateCB(BrickletMultiTouch sender, int touchState)
    {
        string str = "";

        if ((touchState & (1 << 12)) == (1 << 12))
        {
            str += "In proximity, ";
        }

        if ((touchState & 0xfff) == 0)
        {
            str += "No electrodes touched" + System.Environment.NewLine;
        }
        else
        {
            str += "Electrodes ";
            for (int i = 0; i < 12; i++)
            {
                if ((touchState & (1 << i)) == (1 << i))
                {
                    str += i + " ";
                }
            }
            str += "touched" + System.Environment.NewLine;
        }

        System.Console.WriteLine(str);
    }
Example #2
0
    public MultiTouchInput(IPConnection ipcon, BlockingQueue <char> keyQueue)
    {
        this.keyQueue = keyQueue;

        if (Config.UID_MULTI_TOUCH_BRICKLET == null)
        {
            System.Console.WriteLine("Not Configured: Multi Touch");
            return;
        }

        multiTouch = new BrickletMultiTouch(Config.UID_MULTI_TOUCH_BRICKLET, ipcon);

        try
        {
            multiTouch.GetElectrodeSensitivity();
            System.Console.WriteLine("Found: Multi Touch ({0})",
                                     Config.UID_MULTI_TOUCH_BRICKLET);
        }
        catch (TinkerforgeException)
        {
            System.Console.WriteLine("Not Found: Multi Touch ({0})",
                                     Config.UID_MULTI_TOUCH_BRICKLET);
            return;
        }

        multiTouch.SetElectrodeSensitivity(100);
        multiTouch.TouchState += TouchStateCB;

        touchTimer = new Timer(delegate(object state) { TouchTick(); }, null, 100, 100);
    }
Example #3
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 Multi Touch Bricklet

    #endregion Fields

    #region Methods

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

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

        // Get current touch state
        int state = mt.GetTouchState();
        string str = "";

        if((state & (1 << 12)) == (1 << 12)) {
            str += "In proximity, ";
        }

        if((state & 0xfff) == 0) {
            str += "No electrodes touched";
        } else {
            str += "Electrodes ";
            for(int i = 0; i < 12; i++) {
                if((state & (1 << i)) == (1 << i)) {
                    str += i + " ";
                }
            }
            str += "touched";
        }

        Console.WriteLine(str);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
Example #5
0
    private void TouchStateCB(BrickletMultiTouch sender, int touchState)
    {
        int changedState = currentState ^ touchState;

        currentState = touchState;

        StateToQueue(changedState & currentState);
    }
    private static string UID = "XYZ"; // Change XYZ to the UID of your Multi Touch Bricklet

    #endregion Fields

    #region Methods

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

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

        // Register touch state callback to function TouchStateCB
        mt.TouchState += TouchStateCB;

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
Example #7
0
    static void Main()
    {
        IPConnection       ipcon = new IPConnection();                 // Create IP connection
        BrickletMultiTouch mt    = new BrickletMultiTouch(UID, ipcon); // Create device object

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

        // Register touchState callback to function TouchStateCB
        mt.TouchState += TouchStateCB;

        System.Console.WriteLine("Press enter to exit");
        System.Console.ReadLine();
        ipcon.Disconnect();
    }
    private static string UID  = "XYZ";    // Change to your UID

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

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

        // Get current touch state
        int touchState = mt.GetTouchState();

        string str = "";

        if ((touchState & (1 << 12)) == (1 << 12))
        {
            str += "In proximity, ";
        }

        if ((touchState & 0xfff) == 0)
        {
            str += "No electrodes touched" + System.Environment.NewLine;
        }
        else
        {
            str += "Electrodes ";
            for (int i = 0; i < 12; i++)
            {
                if ((touchState & (1 << i)) == (1 << i))
                {
                    str += i + " ";
                }
            }
            str += "touched" + System.Environment.NewLine;
        }

        System.Console.WriteLine(str);

        System.Console.WriteLine("Press enter to exit");
        System.Console.ReadLine();
        ipcon.Disconnect();
    }
    // Callback function for touch state callback
    static void TouchStateCB(BrickletMultiTouch sender, int state)
    {
        string str = "";

        if((state & (1 << 12)) == (1 << 12)) {
            str += "In proximity, ";
        }

        if((state & 0xfff) == 0) {
            str += "No electrodes touched";
        } else {
            str += "Electrodes ";
            for(int i = 0; i < 12; i++) {
                if((state & (1 << i)) == (1 << i)) {
                    str += i + " ";
                }
            }
            str += "touched";
        }

        Console.WriteLine(str);
    }
Example #10
0
    private void TouchStateCB(BrickletMultiTouch sender, int touchState)
    {
        int changedState = currentState ^ touchState;

        currentState = touchState;

        StateToQueue(changedState & currentState);
    }
Example #11
0
    public MultiTouchInput(IPConnection ipcon, BlockingQueue<char> keyQueue)
    {
        this.keyQueue = keyQueue;

        if (Config.UID_MULTI_TOUCH_BRICKLET == null)
        {
            System.Console.WriteLine("Not Configured: Multi Touch");
            return;
        }

        multiTouch = new BrickletMultiTouch(Config.UID_MULTI_TOUCH_BRICKLET, ipcon);

        try
        {
            multiTouch.GetElectrodeSensitivity();
            System.Console.WriteLine("Found: Multi Touch ({0})",
                                     Config.UID_MULTI_TOUCH_BRICKLET);
        }
        catch (TinkerforgeException)
        {
            System.Console.WriteLine("Not Found: Multi Touch ({0})",
                                     Config.UID_MULTI_TOUCH_BRICKLET);
            return;
        }

        multiTouch.SetElectrodeSensitivity(100);
        multiTouch.TouchState += TouchStateCB;

        touchTimer = new Timer(delegate(object state) { TouchTick(); }, null, 100, 100);
    }
Example #12
0
        //multi touch
        public void TouchStateCB(BrickletMultiTouch sender, int state)
        {
            Console.WriteLine(_multiTouch.GetTouchState());
            int    key = 0;
            string str = "";

            if ((state & (1 << 12)) == (1 << 12))
            {
                str += "In proximity, ";
            }

            if ((state & 0xfff) == 0)
            {
                str += "No electrodes touched";
            }
            else
            {
                str += "Electrodes ";
                for (int i = 0; i < 12; i++)
                {
                    if ((state & (1 << i)) == (1 << i))
                    {
                        str += i + " ";
                        key  = i;
                    }
                }

                switch (key)
                {
                case 0:
                    while (_multiTouch.GetTouchState() == 4097)
                    {
                        SendKeys.SendWait("{DOWN}");
                    }

                    break;

                case 1:
                    while (_multiTouch.GetTouchState() == 4098)
                    {
                        SendKeys.SendWait("{LEFT}");
                    }

                    break;

                case 2:
                    while (_multiTouch.GetTouchState() == 4100)
                    {
                        SendKeys.SendWait("{RIGHT}");
                    }

                    break;

                case 3:
                    while (_multiTouch.GetTouchState() == 4104)
                    {
                        SendKeys.SendWait("{UP}");
                    }

                    break;

                case 6:
                    while (_multiTouch.GetTouchState() == 4160)
                    {
                        SendKeys.SendWait("{X}");
                    }

                    break;

                case 7:
                    while (_multiTouch.GetTouchState() == 4224)
                    {
                        SendKeys.SendWait("{Z}");
                    }

                    break;

                default:
                    break;
                }


                str += "touched";
            }

            Console.WriteLine(str);
        }