Example #1
0
        private void Accelerometer_ReadingChanged(object sender, AccelerometerChangedEventArgs e)
        {
            var data = e.Reading;

            if (Math.Abs(data.Acceleration.Y) > 0.02)
            {
                if (Math.Abs(data.Acceleration.Y) > 150)
                {
                    CallEmergency();
                }
                Console.WriteLine($"IN REGULAR PROJ: Reading: X: {data.Acceleration.X}, Y: " +
                                  $"{data.Acceleration.Y}, Z: {data.Acceleration.Z}");
                accelY = data.Acceleration.Y;

                accelY = data.Acceleration.Y; //actual acceleration in Y axis, measured in Gs
                //TrackingPage.AccelDisplay.Text = f.ToString("00.000");
                AccelerationDataPoint point = new AccelerationDataPoint();
                point.time   = new DateTime();
                point.accelY = accelY;
                App.Database.SaveItemAsync(point);
                Console.WriteLine($"Wrote {accelY} to database");
                //return accelY;
            }

            //return 0.0;
        }
Example #2
0
 // accel is y axis acceleration
 public Task <int> SaveItemAsync(AccelerationDataPoint accelY)
 {
     if (accelY.ID != 0)
     {
         return(db.UpdateAsync(accelY));
     }
     else
     {
         return(db.InsertAsync(accelY));
     }
 }
Example #3
0
        void Accelerometer_ReadingChanged(object sender, AccelerometerChangedEventArgs e)
        {
            var   data   = e.Reading;
            float accelY = data.Acceleration.Y;

            AccelDisplay.Text = accelY.ToString("00.000");
            if (Math.Abs(data.Acceleration.Y) > 0.02)
            {
                if (Math.Abs(data.Acceleration.Y) > 12)
                {
                    OnEmergency();
                }
                accelY = data.Acceleration.Y; //actual acceleration in Y axis, measured in Gs
                //TrackingPage.AccelDisplay.Text = f.ToString("00.000");
                AccelerationDataPoint point = new AccelerationDataPoint();
                point.time   = new DateTime();
                point.accelY = accelY;
                App.Database.SaveItemAsync(point);
                //return accelY;
            }
        }