Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
[7 Masters] Wearables - WatchShaker
Search
Ezequiel Santos
October 26, 2017
Programming
1
280
[7 Masters] Wearables - WatchShaker
Ezequiel Santos
October 26, 2017
Tweet
Share
More Decks by Ezequiel Santos
See All by Ezequiel Santos
Dependency Management in iOS Development: A Developer Survey Perspective
ezefranca
0
8
Mestrado: Gestos e jogos: reflexões e desenvolvimento de um sistema de detecção de gestos baseado em wearables para controle de jogos
ezefranca
0
250
Server-Driven UI na prática
ezefranca
0
260
Modelo Clássico e Jogos (Jesper Jull) e exergames.
ezefranca
0
91
Server Driven UI Diferença e evolução em 2010 e 2020
ezefranca
0
1.3k
[#2 Community day Shawee] Prototipação eletrônica em Hackathons: idéias makers ganhando vida
ezefranca
0
910
[7 Masters - Intercon 2018] 7 dicas de performance Mobile
ezefranca
0
260
[TDC Florianopolis 2018] - 5 Soft Skills para desenvolvedores iOS
ezefranca
0
730
[Intercon 2017] Desenvolvimento para SmartWatchs
ezefranca
0
82
Other Decks in Programming
See All in Programming
一文字エイリアスのすすめ
fujimura
0
200
JavaScript Closure
asoluka
0
2k
mb_trim関数を作りました
youkidearitai
PRO
1
210
Documentation testsの恩恵 / Documentation testing benefits
ssssota
1
560
slow types ってなんだろう?
karad
0
210
TypeScriptの型とパフォーマンス (TSKaigi 2024)
ypresto
14
4.5k
仕様と実装で学ぶOpenTelemetry
drumato
2
1.1k
WebGLで始める コンピュータグラフィックス入門
heller77
0
370
TypeScriptから始める VR生活
tamagokakeg
2
120
Long journey of Ruby standard library RubyKaigi 2024
andpad
2
210
Ruby on Fails - effective error handling with Rails conventions
talyssonoc
0
300
TCAとKMPを用いた新規動画配信アプリ 「ABEMA Live」の設計
tomu28
2
140
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
41
4.5k
GraphQLとの向き合い方2022年版
quramy
33
13k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
104
6.7k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
15
1.6k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
323
20k
The MySQL Ecosystem @ GitHub 2015
samlambert
244
12k
Product Roadmaps are Hard
iamctodd
45
9.8k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
26
2.3k
Into the Great Unknown - MozCon
thekraken
15
1.1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
21
1.6k
10 Git Anti Patterns You Should be Aware of
lemiorhan
649
58k
Transcript
7Masters - Wearables Ezequiel França WatchShaker! ⌚
Mecatrônica @ SENAI Automação Industrial @ IFSP Analise de Sistemas
@ FIAP Desenvolvedor iOS, Maker e open-source hacker. Ezequiel França
None
None
Heurística?
None
None
Let’s Shake
None
None
http://indiatoday.intoday.in/technology/story/apple-watch- handshakes-nfc-gestures/1/448093.html
None
None
lembrando rapidinho de protocolos delegates
protocol SomeProtocol { func someTypeMethod() }
protocol SomeProtocol { func someTypeMethod() } class SomeClass: SomeProtocol{ }
protocol WatchShakerDelegate { func watchShakerDidShake(_ watchShaker: WatchShaker) func watchShaker(_ watchShaker:WatchShaker,
didFailWith error: Error) }
protocol WatchShakerDelegate { func didShake() func didFail(error: Error) }
protocol WatchShakerDelegate { func watchShakerDidShake(_ watchShaker: WatchShaker) func watchShaker(_ watchShaker:WatchShaker,
didFailWith error: Error) }
class WatchShaker { public var delegate: WatchShakerDelegate? fileprivate var motionManager:
CMMotionManager! fileprivate var lastShakeDate: Date? !// The threshold for how much acceleration needs to happen before an event will register. fileprivate var threshold:Double !// Time between shakes fileprivate var delay:Double = 0.1
init(shakeSensibility to:ShakeSensibility, delay time:Double) { self.threshold = to.rawValue self.delay =
time self.motionManager = CMMotionManager() }
ShakeSensibility
enum ShakeSensibility: Double { case shakeSensibilitySoftest = 0.1 case shakeSensibilitySoft
= 0.7 case shakeSensibilityNormal = 1.0 case shakeSensibilityHard = 1.2 case shakeSensibilityHardest = 2.0 }
public func start(delay accelerometerUpdateInterval:Double = 0.02) { guard motionManager.isAccelerometerAvailable else
{ return } motionManager.accelerometerUpdateInterval = accelerometerUpdateInterval let motionQueue = OperationQueue() motionManager.startAccelerometerUpdates(to: motionQueue) { (accelerometerData, err) -> Void in guard err == nil else { self.delegate?.watchShaker(self, didFailWith: err!) return }
guard let data = accelerometerData else { let e =
NSError(domain: "No accelerometer data", code: 666, userInfo: ["No accelerometer data":"info"]) self.delegate?.watchShaker(self, didFailWith: e) return }
let valueX = fabs(data.acceleration.x) let valueY = fabs(data.acceleration.y) let maxValue
= valueX > valueY ? valueX : valueY if maxValue > self.threshold { if let lastDate = self.lastShakeDate { if Date().compare(lastDate.addingTimeInterval(self.delay)) !== .orderedDescending { self.lastShakeDate = Date() self.delegate!?.watchShakerDidShake(self) } return } self.lastShakeDate = Date() self.delegate!?.watchShakerDidShake(self) }
:) @ezefranca http://ezefranca.com