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 dos Santos
October 26, 2017
Programming
1
440
[7 Masters] Wearables - WatchShaker
Ezequiel dos Santos
October 26, 2017
Tweet
Share
More Decks by Ezequiel dos Santos
See All by Ezequiel dos Santos
Gamified Interventions for Composting Behavior: A Case Study Using the Gamiflow Framework in a Workplace Setting
ezefranca
1
110
Comparative Analysis of AI Models in Managing Household Food Waste: OpenAI GPT-4, Google Gemini, Mistral, and Anthropic Claude
ezefranca
0
260
Decision-making algorithms and Planning Algorithms
ezefranca
1
190
Dependency Management in iOS Development: A Developer Survey Perspective
ezefranca
0
240
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
460
Server-Driven UI na prática
ezefranca
0
400
Modelo Clássico e Jogos (Jesper Jull) e exergames.
ezefranca
0
240
Server Driven UI Diferença e evolução em 2010 e 2020
ezefranca
0
1.6k
[#2 Community day Shawee] Prototipação eletrônica em Hackathons: idéias makers ganhando vida
ezefranca
0
1.2k
Other Decks in Programming
See All in Programming
VS Code Update for GitHub Copilot
74th
1
210
deno-redisの紹介とJSRパッケージの運用について (toranoana.deno #21)
uki00a
0
140
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
170
設計やレビューに悩んでいるPHPerに贈る、クリーンなオブジェクト設計の指針たち
panda_program
5
740
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
44
29k
つよそうにふるまい、つよい成果を出すのなら、つよいのかもしれない
irof
1
300
アンドパッドの Go 勉強会「 gopher 会」とその内容の紹介
andpad
0
250
AIコーディング道場勉強会#2 君(エンジニア)たちはどう生きるか
misakiotb
1
240
Result型で“失敗”を型にするPHPコードの書き方
kajitack
4
160
XP, Testing and ninja testing
m_seki
3
160
第9回 情シス転職ミートアップ 株式会社IVRy(アイブリー)の紹介
ivry_presentationmaterials
1
220
Claude Codeの使い方
ttnyt8701
1
130
Featured
See All Featured
For a Future-Friendly Web
brad_frost
179
9.8k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
The World Runs on Bad Software
bkeepers
PRO
69
11k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
What's in a price? How to price your products and services
michaelherold
246
12k
A designer walks into a library…
pauljervisheath
206
24k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
Into the Great Unknown - MozCon
thekraken
39
1.9k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Code Review Best Practice
trishagee
68
18k
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