static void Main(string[] args) { 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); Console.WriteLine("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); Console.WriteLine("Sensel Device: " + System.Text.Encoding.Default.GetString(list.devices[0].serial_num)); 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); } Thread.Sleep(4000); }
static void Main(string[] args) { IntPtr handle = new IntPtr(0); SenselFrame frame = new SenselFrame(); SenselDeviceList list = new SenselDeviceList(); SenselSensorInfo sensor_info = new SenselSensorInfo(); float total_force = 0; list.num_devices = 0; Sensel.senselGetDeviceList(ref list); Console.WriteLine("Num Devices: " + list.num_devices); if (list.num_devices != 0) { Sensel.senselOpenDeviceByID(ref handle, list.devices[0].idx); Sensel.senselSetFrameContent(handle, 1); Sensel.senselAllocateFrameData(handle, frame); Sensel.senselStartScanning(handle); } if (handle.ToInt64() != 0) { Sensel.senselGetSensorInfo(handle, ref sensor_info); for (int c = 0; c < 500; c++) { Int32 num_frames = 0; Sensel.senselReadSensor(handle); Sensel.senselGetNumAvailableFrames(handle, ref num_frames); for (int f = 0; f < num_frames; f++) { Sensel.senselGetFrame(handle, frame); 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.senselStopScanning(handle); Sensel.senselClose(handle); } }
static void Main(string[] args) { IntPtr handle = new IntPtr(0); SenselFrame frame = new SenselFrame(); SenselDeviceList list = new SenselDeviceList(); list.num_devices = 0; Sensel.senselGetDeviceList(ref list); Console.WriteLine("Num Devices: " + list.num_devices); if (list.num_devices != 0) { Sensel.senselOpenDeviceByID(ref handle, list.devices[0].idx); Sensel.senselSetFrameContent(handle, 4); Sensel.senselAllocateFrameData(handle, frame); Sensel.senselStartScanning(handle); } if (handle.ToInt64() != 0) { for (int c = 0; c < 500; c++) { Int32 num_frames = 0; Sensel.senselReadSensor(handle); Sensel.senselGetNumAvailableFrames(handle, ref num_frames); for (int f = 0; f < num_frames; f++) { Sensel.senselGetFrame(handle, frame); Console.WriteLine("\nNum Contacts: " + frame.n_contacts); for (int i = 0; i < frame.n_contacts; i++) { Console.WriteLine("Contact ID: " + frame.contacts[i].id); } } } Sensel.senselStopScanning(handle); Sensel.senselClose(handle); } }