Skip to content

Commit

Permalink
Merge pull request #67 from MoveUpwards/feature/GraphView
Browse files Browse the repository at this point in the history
Feature/graph view
  • Loading branch information
MoveUpwardsDev authored May 16, 2019
2 parents 87188b8 + 8dc1f95 commit 681ffec
Show file tree
Hide file tree
Showing 236 changed files with 8,501 additions and 471 deletions.
Binary file modified Sample/Playground.playground/Contents.o
Binary file not shown.
26 changes: 22 additions & 4 deletions Sample/Sample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
6D4F2F9C222598E700A0799B /* WalkthroughVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D4F2F9B222598E700A0799B /* WalkthroughVC.swift */; };
6D4F2F9E222598EF00A0799B /* Walkthrough.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D4F2F9D222598EF00A0799B /* Walkthrough.storyboard */; };
6D5037F3228981AD0017AEC9 /* GraphView.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D5037F2228981AD0017AEC9 /* GraphView.storyboard */; };
6D5037F5228981C90017AEC9 /* GraphViewVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5037F4228981C90017AEC9 /* GraphViewVC.swift */; };
6D5660F5221EC6B200014498 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5660F4221EC6B200014498 /* AppDelegate.swift */; };
6D5660F7221EC6B200014498 /* MainVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5660F6221EC6B200014498 /* MainVC.swift */; };
6D5660FA221EC6B200014498 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D5660F8221EC6B200014498 /* Main.storyboard */; };
Expand Down Expand Up @@ -52,6 +54,8 @@
/* Begin PBXFileReference section */
6D4F2F9B222598E700A0799B /* WalkthroughVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalkthroughVC.swift; sourceTree = "<group>"; };
6D4F2F9D222598EF00A0799B /* Walkthrough.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Walkthrough.storyboard; sourceTree = "<group>"; };
6D5037F2228981AD0017AEC9 /* GraphView.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = GraphView.storyboard; sourceTree = "<group>"; };
6D5037F4228981C90017AEC9 /* GraphViewVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GraphViewVC.swift; sourceTree = "<group>"; };
6D5660F1221EC6B200014498 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; };
6D5660F4221EC6B200014498 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
6D5660F6221EC6B200014498 /* MainVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainVC.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -101,6 +105,15 @@
path = Walkthrough;
sourceTree = "<group>";
};
6D5037F1228981920017AEC9 /* GraphView */ = {
isa = PBXGroup;
children = (
6D5037F4228981C90017AEC9 /* GraphViewVC.swift */,
6D5037F2228981AD0017AEC9 /* GraphView.storyboard */,
);
path = GraphView;
sourceTree = "<group>";
};
6D5660E8221EC6B200014498 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -140,6 +153,7 @@
children = (
6DDD7E3A222ECA1A0033F5F9 /* Toasts */,
6D4F2F9A222598B700A0799B /* Walkthrough */,
6D5037F1228981920017AEC9 /* GraphView */,
);
path = Pages;
sourceTree = "<group>";
Expand Down Expand Up @@ -248,9 +262,11 @@
TargetAttributes = {
6D5660F0221EC6B200014498 = {
CreatedOnToolsVersion = 10.1;
LastSwiftMigration = 1020;
};
F30318D62225542F00171E00 = {
CreatedOnToolsVersion = 10.1;
LastSwiftMigration = 1020;
TestTargetID = 6D5660F0221EC6B200014498;
};
};
Expand Down Expand Up @@ -283,6 +299,7 @@
6D5660FF221EC6B400014498 /* LaunchScreen.storyboard in Resources */,
6DDD7E3E222ECA500033F5F9 /* Toasts.storyboard in Resources */,
6D5660FC221EC6B400014498 /* Assets.xcassets in Resources */,
6D5037F3228981AD0017AEC9 /* GraphView.storyboard in Resources */,
6D5660FA221EC6B200014498 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -304,6 +321,7 @@
6DDD7E3C222ECA3E0033F5F9 /* ToastsVC.swift in Sources */,
6D566142221EECAF00014498 /* MUColor.swift in Sources */,
F3E2FC962226EA5F008476BE /* WalkthroughContentVC.swift in Sources */,
6D5037F5228981C90017AEC9 /* GraphViewVC.swift in Sources */,
F3C1DDB82226E2BC006081AE /* MUView.swift in Sources */,
6D566144221EF98000014498 /* ThemeManager.swift in Sources */,
6D5660F7221EC6B200014498 /* MainVC.swift in Sources */,
Expand Down Expand Up @@ -480,7 +498,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.surfin.MUSample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -499,7 +517,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.surfin.MUSample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -517,7 +535,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.surfin.SampleUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = Sample;
};
Expand All @@ -536,7 +554,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.surfin.SampleUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = Sample;
};
Expand Down
115 changes: 115 additions & 0 deletions Sample/Source/Pages/GraphView/GraphView.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="QGf-ja-4rW">
<device id="retina6_1" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Graph ViewVC-->
<scene sceneID="zMI-9Q-KJ4">
<objects>
<viewController id="QGf-ja-4rW" customClass="GraphViewVC" customModule="Sample" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="VWx-ow-VJk">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Acc" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8FY-zk-aVO">
<rect key="frame" x="0.0" y="64" width="414" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="NJk-Ml-esc"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Gyro" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9qM-N8-Rsq">
<rect key="frame" x="0.0" y="253" width="414" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="hTT-QZ-ODO"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Magneto" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JRx-R2-YUV">
<rect key="frame" x="0.0" y="442" width="414" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="vka-jS-7hD"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Vl0-32-sAw" customClass="MUGraphView" customModule="Sejima">
<rect key="frame" x="0.0" y="95" width="414" height="128"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="128" id="2Yi-HB-CVo"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="d4J-m6-FLW" customClass="MUGraphView" customModule="Sejima">
<rect key="frame" x="0.0" y="284" width="414" height="128"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="128" id="buY-Bg-5Hs"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IQp-PQ-oI3" customClass="MUGraphView" customModule="Sejima">
<rect key="frame" x="0.0" y="714" width="414" height="128"/>
<color key="backgroundColor" red="1" green="0.034920876080000003" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="128" id="qUV-AN-7Jm"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="xColor">
<color key="value" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="yColor">
<color key="value" red="0.71535209759999996" green="0.94279751710000004" blue="0.62772902399999997" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="zColor">
<color key="value" red="0.71535209759999996" green="0.94279751710000004" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="IQp-PQ-oI3" firstAttribute="trailing" secondItem="4Tn-Km-wDT" secondAttribute="trailing" id="0jj-MM-lLA"/>
<constraint firstItem="9qM-N8-Rsq" firstAttribute="top" secondItem="Vl0-32-sAw" secondAttribute="bottom" constant="30" id="8hG-6d-oaq"/>
<constraint firstItem="JRx-R2-YUV" firstAttribute="top" secondItem="d4J-m6-FLW" secondAttribute="bottom" constant="30" id="Al8-h0-5tj"/>
<constraint firstItem="IQp-PQ-oI3" firstAttribute="leading" secondItem="4Tn-Km-wDT" secondAttribute="leading" id="Ara-CY-l1o"/>
<constraint firstItem="d4J-m6-FLW" firstAttribute="leading" secondItem="4Tn-Km-wDT" secondAttribute="leading" id="BoB-Qv-BH8"/>
<constraint firstItem="8FY-zk-aVO" firstAttribute="top" secondItem="4Tn-Km-wDT" secondAttribute="top" constant="20" id="G7h-7Y-lVy"/>
<constraint firstItem="9qM-N8-Rsq" firstAttribute="leading" secondItem="4Tn-Km-wDT" secondAttribute="leading" id="S4y-A7-QUJ"/>
<constraint firstItem="4Tn-Km-wDT" firstAttribute="trailing" secondItem="JRx-R2-YUV" secondAttribute="trailing" id="SpF-c3-5pK"/>
<constraint firstItem="JRx-R2-YUV" firstAttribute="leading" secondItem="4Tn-Km-wDT" secondAttribute="leading" id="Uv3-Ek-kEn"/>
<constraint firstItem="d4J-m6-FLW" firstAttribute="trailing" secondItem="4Tn-Km-wDT" secondAttribute="trailing" id="dDh-xs-mH8"/>
<constraint firstItem="Vl0-32-sAw" firstAttribute="top" secondItem="8FY-zk-aVO" secondAttribute="bottom" constant="10" id="fkB-qd-4Uj"/>
<constraint firstItem="4Tn-Km-wDT" firstAttribute="bottom" secondItem="IQp-PQ-oI3" secondAttribute="bottom" constant="20" id="jdF-7f-BiT"/>
<constraint firstItem="Vl0-32-sAw" firstAttribute="trailing" secondItem="4Tn-Km-wDT" secondAttribute="trailing" id="k9S-ln-qno"/>
<constraint firstItem="d4J-m6-FLW" firstAttribute="top" secondItem="9qM-N8-Rsq" secondAttribute="bottom" constant="10" id="nDX-Li-2pi"/>
<constraint firstItem="Vl0-32-sAw" firstAttribute="leading" secondItem="4Tn-Km-wDT" secondAttribute="leading" id="rB3-Aa-zng"/>
<constraint firstItem="4Tn-Km-wDT" firstAttribute="trailing" secondItem="8FY-zk-aVO" secondAttribute="trailing" id="rpn-gX-Ogr"/>
<constraint firstItem="4Tn-Km-wDT" firstAttribute="trailing" secondItem="9qM-N8-Rsq" secondAttribute="trailing" id="whN-1s-jfS"/>
<constraint firstItem="8FY-zk-aVO" firstAttribute="leading" secondItem="4Tn-Km-wDT" secondAttribute="leading" id="xC4-1A-SKK"/>
</constraints>
<viewLayoutGuide key="safeArea" id="4Tn-Km-wDT"/>
</view>
<connections>
<outlet property="accGraphView" destination="Vl0-32-sAw" id="v9j-nt-Evg"/>
<outlet property="gyroGraphView" destination="d4J-m6-FLW" id="mRB-Jd-pzf"/>
<outlet property="magnetoGraphView" destination="IQp-PQ-oI3" id="nqC-Fx-js4"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="xsr-Jo-anV" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="40.579710144927539" y="71.651785714285708"/>
</scene>
</scenes>
</document>
72 changes: 72 additions & 0 deletions Sample/Source/Pages/GraphView/GraphViewVC.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// GraphViewVC.swift
// Sample
//
// Created by Damien Noël Dubuisson on 13/05/2019.
// Copyright © 2019 Damien Noël Dubuisson. All rights reserved.
//

import UIKit
import CoreMotion
import Sejima

class GraphViewVC: UIViewController {
@IBOutlet weak var accGraphView: MUGraphView!
@IBOutlet weak var gyroGraphView: MUGraphView!
@IBOutlet weak var magnetoGraphView: MUGraphView!

private let motionManager = CMMotionManager()

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.
gyroGraphView.xColor = .yellow
gyroGraphView.yColor = .purple
gyroGraphView.zColor = .orange

//
magnetoGraphView.xRange = -2.0...2.0
magnetoGraphView.yRange = -2.0...2.0
magnetoGraphView.zRange = -2.0...2.0

magnetoGraphView.mainAxisColor = .green
magnetoGraphView.othersAxisColor = .white

//
startUpdates()
}

deinit {
stopUpdates()
}

func startUpdates() {
guard motionManager.isDeviceMotionAvailable else { return }

// showGraph(selectedDeviceMotion)
// updateIntervalLabel.text = formattedUpdateInterval

motionManager.deviceMotionUpdateInterval = 0.01 // 0.0 to 1.0
motionManager.showsDeviceMovementDisplay = true

motionManager.startDeviceMotionUpdates(using: .xArbitraryZVertical,
to: .main) { [weak self] deviceMotion, error in
guard let deviceMotion = deviceMotion else { return }

self?.accGraphView.add(x: deviceMotion.userAcceleration.x,
y: deviceMotion.userAcceleration.y,
z: deviceMotion.userAcceleration.z)
self?.gyroGraphView.add(x: deviceMotion.rotationRate.x,
y: deviceMotion.rotationRate.y,
z: deviceMotion.rotationRate.z)
self?.magnetoGraphView.add(x: deviceMotion.gravity.x, y: deviceMotion.gravity.y, z: deviceMotion.gravity.z)
}
}

func stopUpdates() {
guard motionManager.isDeviceMotionActive else { return }

motionManager.stopDeviceMotionUpdates()
}
}
Loading

0 comments on commit 681ffec

Please sign in to comment.