コード例 #1
0
ファイル: HelloSensel.cs プロジェクト: kyapp69/sensel-unity
            void Start()
            {
                IntPtr handle = new IntPtr(0);
                //SenselFrame frame = new SenselFrame();
                SenselDeviceList list        = new SenselDeviceList();
                SenselSensorInfo sensor_info = new SenselSensorInfo();

                list.num_devices = 0;
                Sensel.senselGetDeviceList(ref list);
                Debug.Log("Num Devices: " + list.num_devices);
                if (list.num_devices != 0)
                {
                    Sensel.senselOpenDeviceByID(ref handle, list.devices[0].idx);
                }
                if (handle.ToInt64() != 0)
                {
                    Sensel.senselGetSensorInfo(handle, ref sensor_info);
                    Debug.Log("Sensel Device: " + System.Text.Encoding.Default.GetString(list.devices[0].serial_num));
                    Debug.Log("Width: " + sensor_info.width + "mm");
                    Debug.Log("Height: " + sensor_info.height + "mm");
                    Debug.Log("Cols: " + sensor_info.num_cols);
                    Debug.Log("Rows: " + sensor_info.num_rows);

                    Sensel.senselClose(handle);
                }
            }
コード例 #2
0
        static ContactHandler()
        {
            _sensorInfo = SenselMaster.SensorInfo;

            _contactArray = new NativeArray <Contact>(
                _sensorInfo.max_contacts, Allocator.Persistent
                );

        #if UNITY_EDITOR
            // To release the internal objects on script recompilation.
            UnityEditor.AssemblyReloadEvents.beforeAssemblyReload += ReleaseResources;
        #endif
        }
コード例 #3
0
        static void Main(string[] args)
        {
            SenselDeviceList list = SenselDevice.GetDeviceList();

            Console.WriteLine("Num Devices: " + list.num_devices);
            if (list.num_devices == 0)
            {
                Console.WriteLine("No devices found.");
                Console.WriteLine("Press any key to exit.");
                while (!Console.KeyAvailable)
                {
                }
                return;
            }

            SenselDevice sensel_device = new SenselDevice();

            sensel_device.OpenDeviceByID(list.devices[0].idx);
            sensel_device.SetFrameContent(SenselDevice.FRAME_CONTENT_PRESSURE_MASK);
            sensel_device.StartScanning();
            SenselSensorInfo sensor_info = sensel_device.GetSensorInfo();

            Console.WriteLine("Press any key to exit");
            while (!Console.KeyAvailable)
            {
                sensel_device.ReadSensor();
                int numFrames = sensel_device.GetNumAvailableFrames();
                for (int f = 0; f < numFrames; f++)
                {
                    SenselFrame frame       = sensel_device.GetFrame();
                    float       total_force = 0;
                    for (int i = 0; i < sensor_info.num_cols * sensor_info.num_rows; i++)
                    {
                        total_force = total_force + frame.force_array[i];
                    }
                    Console.WriteLine("Total Force: " + total_force);
                }
            }
            sensel_device.StopScanning();
            sensel_device.Close();
        }
コード例 #4
0
        public SenselThread()
        {
            // Check if a device is available.
            var deviceList = SenselDevice.GetDeviceList();

            if (deviceList.num_devices == 0)
            {
                throw new System.IO.IOException("Sensel device not found.");
            }

            // Open the found device.
            _device = new SenselDevice();
            _device.OpenDeviceByID(deviceList.devices[0].idx);
            _device.SetFrameContent(
                SenselDevice.FRAME_CONTENT_CONTACTS_MASK |
                SenselDevice.FRAME_CONTENT_PRESSURE_MASK |
                SenselDevice.FRAME_CONTENT_ACCEL_MASK
                );

            _sensorInfo = _device.GetSensorInfo();

            // Allocate the force array.
            _forceArray = new NativeArray <float>(
                _sensorInfo.num_cols * _sensorInfo.num_rows,
                Allocator.Persistent
                );

            // Allocate the contact array.
            _contacts = new NativeArray <SenselContact>(
                _sensorInfo.max_contacts, Allocator.Persistent
                );

            // Start the receiver thread.
            _thread = new Thread(ReceiverThread);
            _sync   = new AutoResetEvent(false);
            _thread.Start();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            SenselDeviceList list = SenselDevice.GetDeviceList();

            Console.WriteLine("Num Devices: " + list.num_devices);
            if (list.num_devices != 0)
            {
                SenselDevice sensel_device = new SenselDevice();
                sensel_device.OpenDeviceByID(list.devices[0].idx);
                SenselSensorInfo   sensor_info = sensel_device.GetSensorInfo();
                SenselFirmwareInfo fw_info     = sensel_device.GetFirmwareInfo();
                Console.WriteLine("Sensel Device: " + System.Text.Encoding.Default.GetString(list.devices[0].serial_num));
                Console.WriteLine("Firmware Version: " + fw_info.fw_version_major + "." + fw_info.fw_version_minor + "." + fw_info.fw_version_build);
                Console.WriteLine("Width: " + sensor_info.width + "mm");
                Console.WriteLine("Height: " + sensor_info.height + "mm");
                Console.WriteLine("Cols: " + sensor_info.num_cols);
                Console.WriteLine("Rows: " + sensor_info.num_rows);
                sensel_device.Close();
            }
            Console.WriteLine("Press any key to exit.");
            while (!Console.KeyAvailable)
            {
            }
        }