digitalCrownRotation

Im trying to create a program that starts and stops a stopwatch by tracking the rotations of the digital crown, but i'm not sure how to use the crown method in the implementation.

Im kind of a noob to swift so I don't understand how I can track the rotations and use that as a condition for starting and stopping the watch.

My goal is to start the watch any time the rotation is less than 0 or greater than 0 depending on which way the user has spun the crown, and then reset the number to 0.

Then I want to make it so that if the state of the clock is true (so it is running) and the crown rotations become greater than or less than 0, then to stop the timer.

this is the code i saw relating to tracking the rotations of the crown.

Code Block
struct DigitalCrown: View {
@State private var crownValue = 0.0
var body: some View {
Text("Received Value:\(crownValue, specifier: "%.1f")")
.focusable()
.digitalCrownRotation($crownValue)
}
}


sorry if this was confusing, but any help would be greatly appreciated!

This is my code
Code Block //
// InterfaceController.swift
// Watch App WatchKit Extension
//
// Created by Maxwell Myers on 1/29/21.
//
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
   
  @IBOutlet weak var time: WKInterfaceTimer!
  @IBOutlet weak var sbutton: WKInterfaceButton!
   
  var timeIsStarted = false
  var startTime = Date()
  var elapsedTime : TimeInterval = 0.0
  private var crownValue = 0.0
   
  override func awake(withContext context: Any?) {
    // Configure interface objects here.
    super.awake(withContext: context)
  }
   
  override func willActivate() {
    // This method is called when watch view controller is about to be visible to user
    super.willActivate()
  }
   
   
  override func didDeactivate() {
    // This method is called when watch view controller is no longer visible
    super.didDeactivate()
  }
//  struct DigitalCrown: View {
//    @State private var crownValue = 0.0
//
//    var body: some View {
//      Text("Received Value:\(crownValue, specifier: "%.1f")")
//        .focusable()
//        .digitalCrownRotation($crownValue)
//    }
//  }
  @IBAction func stButton() {
    timeIsStarted = !timeIsStarted
    if timeIsStarted {
      startTime = Date()
      sbutton.setTitle("STOP")
      time .setDate(Date(timeIntervalSinceNow: elapsedTime))
      time.start()
    }else{
      let stoppedTime = Date()
      elapsedTime -= stoppedTime.timeIntervalSince(startTime)
      sbutton.setTitle("START")
      time.stop()
    }
     
    
  }
  //    if(crownValue != 0.0) {
  //      timeIsStarted = !timeIsStarted //change timeisstarted to true
  //      crownValue = 0.0
  //    }
   
}


digitalCrownRotation
 
 
Q