Add a live status panel between the run screen's halves
Replaces the small target-HR pill on the iPhone run screen with a glanceable big-digit strip between the timer flow and the figure — heart rate (band-tinted with the cue arrow when the run carries a target), HR zone, active calories, and the workout stopwatch. A horizontal band in portrait, a vertical column in landscape (the inverse of the half-and-half split, so it always sits between them). The watch now rides the running calorie total and the HR zone (1-5, computed watch-side where max HR is known) along with each live HR sample; absent keys keep older builds wire-compatible both ways. LiveRunState holds all three under the shared staleness expiry. The screenshot rig seeds believable values so the run capture shows the panel populated.
This commit is contained in:
@@ -221,22 +221,28 @@ final class WatchConnectivityBridge: NSObject {
|
||||
|
||||
/// Rounded bpm last sent and when, to throttle the forward: HR samples land every few
|
||||
/// seconds, but an unchanged reading only needs an occasional keep-alive so the phone's
|
||||
/// staleness window doesn't blank the readout mid-run.
|
||||
/// staleness window doesn't blank the readout mid-run. A zone flip breaks the throttle
|
||||
/// so the panel's zone can't lag a boundary crossing by the keep-alive interval.
|
||||
private var lastHRSentBpm: Int?
|
||||
private var lastHRSentZone: Int?
|
||||
private var lastHRSentAt = Date.distantPast
|
||||
|
||||
/// Forward a live heart-rate sample to a mirroring phone. Unlike the run frames this is
|
||||
/// pure best-effort — reachable-only, no staging, no retry: a gauge, not a record. The
|
||||
/// durable HR summary still lands in `WorkoutMetrics` when the session finishes.
|
||||
func sendLiveHeartRate(_ bpm: Double) {
|
||||
/// Forward a live sample (heart rate + running calories + zone) to a mirroring phone.
|
||||
/// Unlike the run frames this is pure best-effort — reachable-only, no staging, no
|
||||
/// retry: a gauge, not a record. The durable summary still lands in `WorkoutMetrics`
|
||||
/// when the session finishes.
|
||||
func sendLiveSample(_ sample: WorkoutSessionManager.LiveSample) {
|
||||
guard let session, session.activationState == .activated, session.isReachable else { return }
|
||||
let rounded = Int(bpm.rounded())
|
||||
let rounded = Int(sample.bpm.rounded())
|
||||
let now = Date()
|
||||
if rounded == lastHRSentBpm, now.timeIntervalSince(lastHRSentAt) < 10 { return }
|
||||
if rounded == lastHRSentBpm, sample.zone == lastHRSentZone,
|
||||
now.timeIntervalSince(lastHRSentAt) < 10 { return }
|
||||
lastHRSentBpm = rounded
|
||||
lastHRSentZone = sample.zone
|
||||
lastHRSentAt = now
|
||||
session.sendMessage(WCPayload.encodeLiveHeartRate(bpm: bpm, at: now),
|
||||
replyHandler: nil, errorHandler: nil)
|
||||
session.sendMessage(
|
||||
WCPayload.encodeLiveHeartRate(bpm: sample.bpm, at: now, kcal: sample.kcal, zone: sample.zone),
|
||||
replyHandler: nil, errorHandler: nil)
|
||||
}
|
||||
|
||||
/// Apply a live-run frame the phone sent. Catches our send counter up first (shared per-run
|
||||
|
||||
Reference in New Issue
Block a user