Skip to content

Instantly share code, notes, and snippets.

View MickaelCruzDB's full-sized avatar

Mickaël Cruz MickaelCruzDB

View GitHub Profile
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
//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
@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
}
@objc func goToMenu() {
if self.timerStarted == true {
self.idleTimer.invalidate()
self.timerStarted = false
}
self.ck3dCube.camera.stop()
self.scene.rootNode.enumerateChildNodes { (node, stop) in
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
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 {
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
import App
import Fluent
import FluentSQLiteDriver
import Vapor
import APNS
import Leaf
import CoreLocation
struct GlobalVariables {
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()
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)