This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class KalmanFilter: NSObject { | |
public var estimatedRSSI = 0.0 // Calculated rssi | |
private var processNoise = 0.125 // Process noise | |
private var measurementNoise = 0.8 // Measurement noise | |
private var errorCovarianceRSSI = 0.0 // Calculated covariance | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TxPower given by Jérôme | |
let power = 62.0 | |
// Truncate incoming RSSI | |
let incomingRSSI = Double(truncating: RSSI) | |
// Check if filter is already present for current peripheral | |
guard let filter = items[peripheral.identifier.uuidString] else { | |
// Init the KalmanFilter | |
items[peripheral.identifier.uuidString] = KalmanFilter(first: incomingRSSI) | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func close360Pressed(_ sender: Any) { | |
self.vviewmgr.stop() | |
self.view.bringSubviewToFront(self.activityIndicator) | |
self.activityIndicator.alpha = 1 | |
self.activityIndicator.startAnimating() | |
UIView.animate(withDuration: 0.5) { | |
self.seekSlider.alpha = 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@objc func goToMenu() { | |
if self.timerStarted == true { | |
self.idleTimer.invalidate() | |
self.timerStarted = false | |
} | |
self.ck3dCube.camera.stop() | |
self.scene.rootNode.enumerateChildNodes { (node, stop) in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { | |
// Working with functions categories collection view | |
if collectionView == self.functionsCategoriesCollectionView { | |
let cell = collectionView.cellForItem(at: indexPath) as! DevicePageFunctionsCategoriesCVCell | |
cell.isHidden = false | |
cell.cellView.isHidden = false | |
cell.isSelected = true | |
cell.cellView.clipsToBounds = true | |
cell.cellView.layer.cornerRadius = 25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | |
// Working with functions categories collection view | |
if collectionView == self.functionsCategoriesCollectionView { | |
let cellFunctionsCategories = collectionView.dequeueReusableCell(withReuseIdentifier: "cellCat", for: indexPath) as! DevicePageFunctionsCategoriesCVCell | |
cellFunctionsCategories.cellTitleContent.text = ICDatabase.objects(FunctionCategory.self)[indexPath.row].name.uppercased() | |
cellFunctionsCategories.setGradientBorder(width: 10, colors: [UIColor(red: 127.0/255.0, green: 127.0/255.0, blue: 127.0/255.0, alpha: 1.0), UIColor(red: 47.0/255.0, green: 47.0/255.0, blue: 47.0/255.0, alpha: 1.0)]) | |
if indexPath == cellSelectionIndexPath { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | |
// Working with functions categories collection view | |
if collectionView == self.functionsCategoriesCollectionView { | |
let cellFunctionsCategories = collectionView.dequeueReusableCell(withReuseIdentifier: "cellCat", for: indexPath) as! DevicePageFunctionsCategoriesCVCell | |
cellFunctionsCategories.cellTitleContent.text = ICDatabase.objects(FunctionCategory.self)[indexPath.row].name.uppercased() | |
cellFunctionsCategories.setGradientBorder(width: 10, colors: [UIColor(red: 127.0/255.0, green: 127.0/255.0, blue: 127.0/255.0, alpha: 1.0), UIColor(red: 47.0/255.0, green: 47.0/255.0, blue: 47.0/255.0, alpha: 1.0)]) | |
return cellFunctionsCategories |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import App | |
import Fluent | |
import FluentSQLiteDriver | |
import Vapor | |
import APNS | |
import Leaf | |
import CoreLocation | |
struct GlobalVariables { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import App | |
import Vapor | |
var env = try Environment.detect() | |
try LoggingSystem.bootstrap(from: &env) | |
let app = Application(env) | |
defer { app.shutdown() } | |
try configure(app) | |
try app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
// Override point for customization after application launch. | |
let appDelegate = UIApplication.shared.delegate as! AppDelegate | |
let context = appDelegate.persistentContainer.viewContext | |
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "AppVersion") | |
request.returnsObjectsAsFaults = false | |
do { | |
let result = try context.fetch(request) |