Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Added JSON parser, added functioning screen for TeleOp and Auton
Browse files Browse the repository at this point in the history
  • Loading branch information
dropbear32 committed Feb 12, 2018
1 parent 836da8e commit de764f2
Show file tree
Hide file tree
Showing 29 changed files with 364 additions and 100 deletions.
16 changes: 12 additions & 4 deletions scouting1072.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,29 @@
objects = {

/* Begin PBXBuildFile section */
6C02CBBF202E55A700607242 /* AutonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C02CBBE202E55A600607242 /* AutonViewController.swift */; };
6C51CE80201BF944008E7A14 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 6C51CE7F201BF944008E7A14 /* GoogleService-Info.plist */; };
6C8F1F46202431DE00E523C8 /* IntermediateViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8F1F45202431DE00E523C8 /* IntermediateViewController.swift */; };
6C8F1F48202435F400E523C8 /* RequestHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8F1F47202435F400E523C8 /* RequestHandler.swift */; };
6CBCE5DC2032187A009E99F5 /* field.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CBCE5DB2032187A009E99F5 /* field.png */; };
6CD4E106201A8EE500E83826 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CD4E105201A8EE500E83826 /* AppDelegate.swift */; };
6CD4E108201A8EE500E83826 /* SignInViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CD4E107201A8EE500E83826 /* SignInViewController.swift */; };
6CD4E10B201A8EE500E83826 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6CD4E109201A8EE500E83826 /* Main.storyboard */; };
6CD4E10D201A8EE500E83826 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6CD4E10C201A8EE500E83826 /* Assets.xcassets */; };
6CD4E110201A8EE500E83826 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6CD4E10E201A8EE500E83826 /* LaunchScreen.storyboard */; };
6CD4E13B201A965700E83826 /* SafariServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CD4E13A201A965600E83826 /* SafariServices.framework */; };
6CD4E13D201A966000E83826 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CD4E13C201A966000E83826 /* SystemConfiguration.framework */; };
6CE7CECD203117210016E5AD /* Switch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CE7CECC203117210016E5AD /* Switch.swift */; };
AA302E368CE1438AF4CA4C5C /* Pods_scouting1072.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED7C4C92725EBA6019296D48 /* Pods_scouting1072.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
1C9BC29630A747B2CE80E7F0 /* Pods-scouting1072Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-scouting1072Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-scouting1072Tests/Pods-scouting1072Tests.debug.xcconfig"; sourceTree = "<group>"; };
58DBA468DFA68FC6785DC1FC /* Pods-scouting1072.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-scouting1072.release.xcconfig"; path = "Pods/Target Support Files/Pods-scouting1072/Pods-scouting1072.release.xcconfig"; sourceTree = "<group>"; };
6C02CBBE202E55A600607242 /* AutonViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutonViewController.swift; sourceTree = "<group>"; };
6C51CE7F201BF944008E7A14 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
6C7374B7201B94FF0054C5BF /* scouting1072-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "scouting1072-Bridging-Header.h"; sourceTree = "<group>"; };
6C8F1F45202431DE00E523C8 /* IntermediateViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntermediateViewController.swift; sourceTree = "<group>"; };
6C8F1F47202435F400E523C8 /* RequestHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestHandler.swift; sourceTree = "<group>"; };
6CBCE5DB2032187A009E99F5 /* field.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = field.png; sourceTree = "<group>"; };
6CD4E102201A8EE500E83826 /* scouting1072.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = scouting1072.app; sourceTree = BUILT_PRODUCTS_DIR; };
6CD4E105201A8EE500E83826 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
6CD4E107201A8EE500E83826 /* SignInViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInViewController.swift; sourceTree = "<group>"; };
Expand All @@ -36,6 +39,7 @@
6CD4E111201A8EE500E83826 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6CD4E13A201A965600E83826 /* SafariServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SafariServices.framework; path = System/Library/Frameworks/SafariServices.framework; sourceTree = SDKROOT; };
6CD4E13C201A966000E83826 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
6CE7CECC203117210016E5AD /* Switch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Switch.swift; sourceTree = "<group>"; };
82B57E53F842FFAB400F4442 /* Pods-scouting1072.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-scouting1072.debug.xcconfig"; path = "Pods/Target Support Files/Pods-scouting1072/Pods-scouting1072.debug.xcconfig"; sourceTree = "<group>"; };
A42D818BDD180895A8EF205E /* Pods_scouting1072UITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_scouting1072UITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BB0AB75575B7D4A78FEF2CA3 /* Pods-scouting1072UITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-scouting1072UITests.release.xcconfig"; path = "Pods/Target Support Files/Pods-scouting1072UITests/Pods-scouting1072UITests.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -84,10 +88,12 @@
children = (
6CD4E105201A8EE500E83826 /* AppDelegate.swift */,
6CD4E107201A8EE500E83826 /* SignInViewController.swift */,
6C8F1F47202435F400E523C8 /* RequestHandler.swift */,
6C8F1F45202431DE00E523C8 /* IntermediateViewController.swift */,
6C02CBBE202E55A600607242 /* AutonViewController.swift */,
6CD4E109201A8EE500E83826 /* Main.storyboard */,
6CE7CECC203117210016E5AD /* Switch.swift */,
6CD4E10C201A8EE500E83826 /* Assets.xcassets */,
6CBCE5DB2032187A009E99F5 /* field.png */,
6CD4E10E201A8EE500E83826 /* LaunchScreen.storyboard */,
6CD4E111201A8EE500E83826 /* Info.plist */,
);
Expand Down Expand Up @@ -183,6 +189,7 @@
buildActionMask = 2147483647;
files = (
6CD4E110201A8EE500E83826 /* LaunchScreen.storyboard in Resources */,
6CBCE5DC2032187A009E99F5 /* field.png in Resources */,
6C51CE80201BF944008E7A14 /* GoogleService-Info.plist in Resources */,
6CD4E10D201A8EE500E83826 /* Assets.xcassets in Resources */,
6CD4E10B201A8EE500E83826 /* Main.storyboard in Resources */,
Expand Down Expand Up @@ -258,9 +265,10 @@
buildActionMask = 2147483647;
files = (
6C8F1F46202431DE00E523C8 /* IntermediateViewController.swift in Sources */,
6C8F1F48202435F400E523C8 /* RequestHandler.swift in Sources */,
6CD4E108201A8EE500E83826 /* SignInViewController.swift in Sources */,
6C02CBBF202E55A700607242 /* AutonViewController.swift in Sources */,
6CD4E106201A8EE500E83826 /* AppDelegate.swift in Sources */,
6CE7CECD203117210016E5AD /* Switch.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
10 changes: 10 additions & 0 deletions scouting1072/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
return UIApplication.shared.delegate as! AppDelegate
}

var shouldRotate = true

//MARK: - Func to rotate only one view controller
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
if (shouldRotate == true){
return UIInterfaceOrientationMask.all
}
return UIInterfaceOrientationMask.landscape
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
Expand Down
54 changes: 36 additions & 18 deletions scouting1072/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,93 +1,111 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@3x.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@3x.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@3x.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@2x.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@3x-1.png",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@1x.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@2x-1.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@2x-1.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@1x.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@2x-1.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@1x.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@2x.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-App-83.5x83.5@2x.png",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "ItunesArtwork@2x.png",
"scale" : "1x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions scouting1072/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
98 changes: 98 additions & 0 deletions scouting1072/AutonViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//
// AutonViewController.swift
// scouting1072
//
// Created by Aydin Tiritoglu on 2/9/18.
// Copyright © 2018 Aydin Tiritoglu. All rights reserved.
//

var startingPosition = Float()
var autonStartTime = Double()
var teleOpStartTime = Double()
var autonStarted = false
var teleOpStarted = false
var autonPresses = [Double: String]()
var teleOpPresses = [Double: String]()
var timer = Timer()
var crossedLine = false

class AutonViewController: UIViewController {
var counter = 0
@IBOutlet weak var fieldImage: UIImageView!
@IBOutlet weak var timerLabel: UILabel!
@IBOutlet weak var actionButton: UIButton!
@IBOutlet weak var initialBotPosition: UISlider! {
didSet {
initialBotPosition.transform = CGAffineTransform(rotationAngle: CGFloat(Double.pi / 2))
}
}

@IBAction func actionButtonPressed(_ sender: Any) {
if actionButton.currentTitle == "Confirm Starting Position" {
startingPosition = initialBotPosition.value
actionButton.setTitle("Start Auton", for: .normal)
} else if actionButton.currentTitle == "Start Auton" {
counter = 15
autonStartTime = NSDate().timeIntervalSince1970
autonStarted = true
actionButton.setTitle("Auton Started", for: .normal)
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(timerUpdate), userInfo: nil, repeats: true)
timer.fire()
}
}

@objc func timerUpdate() {
counter -= 1
if counter <= -1 {
timer.invalidate()
if autonStarted {
autonEnd()
} else if teleOpStarted {
teleOpEnd()
}
} else {
timerLabel.text = "\(Int(counter / 60)):\(String(counter % 60).count == 2 ? "\(counter % 60)" : "0\(counter % 60)")"
}
}

func autonEnd() {
print(autonPresses)
counter = 135
autonStarted = false
teleOpStartTime = NSDate().timeIntervalSince1970
teleOpStarted = true
actionButton.setTitle("TeleOp Started", for: .normal)
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(timerUpdate), userInfo: nil, repeats: true)
timer.fire()
}

func teleOpEnd() {
print(teleOpPresses)
teleOpStarted = false
timer.invalidate()
// TODO: Transition to info-sending screen
}

override func viewDidLoad() {
super.viewDidLoad()
let appdelegate = UIApplication.shared.delegate as! AppDelegate
appdelegate.shouldRotate = false
let value = UIInterfaceOrientation.landscapeLeft.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
if scoutingUserInfo!.scouting.blue {
fieldImage.transform = fieldImage.transform.rotated(by: CGFloat.pi)
}
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}

private func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscapeLeft
}

private func shouldAutorotate() -> Bool {
return true
}
}
Loading

0 comments on commit de764f2

Please sign in to comment.