Skip to content

Commit

Permalink
Updated comments
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermo-ag-95 committed Feb 22, 2018
1 parent 93642ea commit 61b59d5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Speed Gauge/Speed Gauge/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,39 +86,46 @@ class MainViewController: UIViewController {
}

func initializeStoredData(){
// Clean accelerometer data.
accelerometerXData.removeAll()
accelerometerXData.append(0)
accelerometerYData.removeAll()
accelerometerYData.append(0)
accelerometerZData.removeAll()
accelerometerZData.append(0)

// Clean velocity data.
velocityXData.removeAll()
velocityXData.append(0)
velocityYData.removeAll()
velocityYData.append(0)
velocityZData.removeAll()
velocityZData.append(0)

// Clean gravity data
gravityXData.removeAll()
gravityXData.append(0)
gravityYData.removeAll()
gravityYData.append(0)
gravityZData.removeAll()
gravityZData.append(0)

// Clean acceleration LineChartDataSet
accelerometerXDataset.values.removeAll()
accelerometerYDataset.values.removeAll()
accelerometerZDataset.values.removeAll()

// Clean velocity LineChartDataSet
velocityXDataset.values.removeAll()
velocityYDataset.values.removeAll()
velocityZDataset.values.removeAll()

// Clean gravity LineChartDataSet
gravityXDataset.values.removeAll()
gravityYDataset.values.removeAll()
gravityZDataset.values.removeAll()

// Clean charts (LineChartView)
accelerationLineChartGraph.clear()
velocityLineChartGraph.clear()
gravityLineChartGraph.clear()
Expand All @@ -137,8 +144,7 @@ class MainViewController: UIViewController {
let newYGravity = data.gravity.y
let newZGravity = data.gravity.z


// Instant velocity calculation by Integration
// Instant velocity calculation by integration
let newXVelocity = (accelerometerXData.last! * updatesIntervalOn) + (newXAcceleration - accelerometerXData.last!) * (updatesIntervalOn / 2)
let newYVelocity = (accelerometerYData.last! * updatesIntervalOn) + (newYAcceleration - accelerometerYData.last!) * (updatesIntervalOn / 2)
let newZVelocity = (accelerometerZData.last! * updatesIntervalOn) + (newZAcceleration - accelerometerZData.last!) * (updatesIntervalOn / 2)
Expand Down

0 comments on commit 61b59d5

Please sign in to comment.