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); } }
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_CONTACTS_MASK); sensel_device.StartScanning(); Console.WriteLine("Press any key to exit"); while (!Console.KeyAvailable) { sensel_device.ReadSensor(); int num_frames = sensel_device.GetNumAvailableFrames(); for (int f = 0; f < num_frames; f++) { SenselFrame frame = sensel_device.GetFrame(); if (frame.n_contacts > 0) { Console.WriteLine("\nNum Contacts: " + frame.n_contacts); for (int i = 0; i < frame.n_contacts; i++) { Console.WriteLine("Contact ID: " + frame.contacts[i].id); if (frame.contacts[i].state == (int)SenselContactState.CONTACT_START) { sensel_device.SetLEDBrightness(frame.contacts[i].id, 100); } if (frame.contacts[i].state == (int)SenselContactState.CONTACT_END) { sensel_device.SetLEDBrightness(frame.contacts[i].id, 0); } } } } } byte num_leds = sensel_device.GetNumAvailableLEDs(); for (int i = 0; i < num_leds; i++) { sensel_device.SetLEDBrightness((byte)i, 0); } sensel_device.StopScanning(); sensel_device.Close(); }
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(); }
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) { } }
void Awake() { SenselDeviceList list = new SenselDeviceList(); 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 != IntPtr.Zero) { 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); // 185 Debug.Log("Rows: " + _sensor_info.num_rows); // 105 Sensel.senselSetFrameContent(_handle, 1); Sensel.senselAllocateFrameData(_handle, _frame); Sensel.senselStartScanning(_handle); _forces = new float[(int)_sensor_info.num_cols * (int)_sensor_info.num_rows]; for (int y = 0; y < _sensor_info.num_rows; ++y) { var vZ = ((float)y - (float)_sensor_info.num_rows * 0.5f) * -PosScale; for (int x = 0; x < _sensor_info.num_cols; ++x) { var vX = ((float)x - (float)_sensor_info.num_cols * 0.5f) * PosScale; _tempVertices.Add(new Vector3(vX, 0.0f, vZ)); _tempUVs.Add(new Vector2(0.0f, 1.0f)); } } Mesh tempMesh = _AddMesh(_tempVertices, _tempUVs); List <int> tempIndices = new List <int>(); int vertexIndex = 0; for (int y = 0; y < _sensor_info.num_rows - 1; ++y) { for (int x = 0; x < _sensor_info.num_cols - 1; ++x, ++vertexIndex) { tempIndices.Add(vertexIndex + 0); tempIndices.Add(vertexIndex + 1); tempIndices.Add(vertexIndex + _sensor_info.num_cols + 1); tempIndices.Add(vertexIndex + _sensor_info.num_cols + 0); } } if (tempMesh != null && tempIndices.Count > 0) { tempMesh.SetIndices(tempIndices.ToArray(), MeshTopology.Quads, 0); } foreach (var mesh in _tempMeshes) { mesh.RecalculateNormals(); mesh.RecalculateBounds(); } } }