private void IMU_Display_Click(object sender, EventArgs e) { this.Hide(); FormProvider.getIMU_Display_Monitor().Show(); }
// Non-static method public void sensorEventThread() { try { while (true) { ZenEvent zenEvent = new ZenEvent(); //Console.WriteLine(mZenHandle); if (OpenZen.ZenWaitForNextEvent(mZenHandle, zenEvent)) { if (zenEvent.component.handle == 0) { // if the handle is on, its not a sensor event but a system wide // event switch (zenEvent.eventType) { case (int)ZenSensorEvent.ZenSensorEvent_SensorFound: Console.WriteLine("found sensor event event " + zenEvent.data.sensorFound.name); mFoundSensors.Add(zenEvent.data.sensorFound); break; case (int)ZenSensorEvent.ZenSensorEvent_SensorListingProgress: if (zenEvent.data.sensorListingProgress.progress == 1.0) { mSearchDone = true; } break; } } else { switch (zenEvent.eventType) { case (int)ZenImuEvent.ZenImuEvent_Sample: mImuEventCount++; if (mImuEventCount % 100 == 0) { continue; } // read acceleration OpenZenFloatArray fa = OpenZenFloatArray.frompointer(zenEvent.data.imuData.a); // read euler angles OpenZenFloatArray fg = OpenZenFloatArray.frompointer(zenEvent.data.imuData.g); // read quaternion OpenZenFloatArray fb = OpenZenFloatArray.frompointer(zenEvent.data.imuData.b); // Output Data IMU_Display_Monitor imu = FormProvider.getIMU_Display_Monitor(); // Accelerometer imu.acx = fa.getitem(0); imu.acy = fa.getitem(1); imu.acz = fa.getitem(2); // Gyroscope imu.gyx = fg.getitem(0); imu.gyy = fg.getitem(1); imu.gyz = fg.getitem(2); // Magnetometer imu.mgx = fb.getitem(0); imu.mgy = fb.getitem(1); imu.mgz = fb.getitem(2); break; } } } } } catch (ThreadAbortException) { } }