You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// function to translate heart rate to decimal, copied straight up from this tut: https://www.raywenderlich.com/231-core-bluetooth-tutorial-for-ios-heart-rate-monitor#toc-anchor-014
// Heart Rate Value Format is in the 2nd and 3rd bytes
244
-
return(Int(byteArray[1]) << 8)+ Int(byteArray[2])
245
-
}
246
-
}
247
-
248
-
// this function pulls date from phone, shuffles it into the correct order, and then hex-encodes it to a format that InfiniTime can understand
249
-
privatefunc currentTime()->String{
250
-
letnow=Date() // current time
251
-
252
-
// formatting setup for the date, not including the year because we have to reformat the year hex to match what the PT expects
253
-
letdateFormatter=DateFormatter()
254
-
dateFormatter.dateFormat ="MM dd H m s e SSSS"
255
-
256
-
// prepare formatting for year
257
-
letyearFormatter=DateFormatter()
258
-
yearFormatter.dateFormat ="y"
259
-
letyearString= yearFormatter.string(from: now)
260
-
letintYear=Int(yearString)
261
-
262
-
// convert year string to hex-encoded string. conditionally prepend 0 in case by some miracle this application and your watch is still functional in the year 4096
263
-
varhexYear=String(format:"%02X", intYear!)
264
-
if hexYear.count ==3{
265
-
hexYear.insert("0", at: hexYear.startIndex)
266
-
}
267
-
268
-
// infinitime (and BLE in general? I dunno...) requires the MSB first, so we have to switch the year from XXYY to YYXX
0 commit comments