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
270
[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
4
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
240
Server-Driven UI na prática
ezefranca
0
260
Modelo Clássico e Jogos (Jesper Jull) e exergames.
ezefranca
0
88
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
900
[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
80
Other Decks in Programming
See All in Programming
0→1と1→10の狭間で Javaという技術選定を振り返る/Reflecting on the Decision to Choose Java Between Scaling from 0 to 1 and 1 to 10
jaguar_imo
2
380
Ruby GitHub Packages
bkuhlmann
0
630
入門 AWS Amplify Gen2 / Introduction to AWS Amplify Gen2
genkiogasawara
1
320
CQRS/ES avec Symfony, c’est (trop) bien !
jeremyfreeagent
1
640
デフォルトにして至高、RubyMineの大好きな所
ruzia
0
230
Elm Form Validation
bkuhlmann
0
510
What We Can Learn From OSS
inouehi
0
420
ADRを一年運用してみた/adr_after_a_year
hanhan1978
7
2.3k
Snowflakeで眠ったデータを起こそう!
estie
0
110
Rethinking UI building strategies @ SFI 2024
letelete
0
270
StoreKit2によるiOSのアプリ内課金のリニューアル
kangnux
0
110
Behind VS Code Extensions for JavaScript / TypeScript Linnting and Formatting
unvalley
5
880
Featured
See All Featured
Clear Off the Table
cherdarchuk
83
310k
Documentation Writing (for coders)
carmenintech
59
3.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
1
1.3k
Rebuilding a faster, lazier Slack
samanthasiow
72
8.2k
KATA
mclloyd
14
12k
Building Flexible Design Systems
yeseniaperezcruz
318
37k
Code Review Best Practice
trishagee
54
15k
We Have a Design System, Now What?
morganepeng
42
6.7k
Producing Creativity
orderedlist
PRO
336
39k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
16k
In The Pink: A Labor of Love
frogandcode
138
21k
Principles of Awesome APIs and How to Build Them.
keavy
120
16k
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