Bixby: want to implement stop watch in my capsule

137 Views Asked by At

I want to display a stopwatch(timer) for my capsule.

So, is there any way from which I can show timer in my view page which will get refreshed every second. I am not understanding where to start. How will time get refreshed?

Any help on this.

2

There are 2 best solutions below

2
On BEST ANSWER

You can use the built-in refresh command to repaint the screen. For example,

result-view {
  match {
    Activity (this) {
      min (Required)
      max (One)
      from-output: CheckRideShareStatus (check)
    }
  }
  message {
    if (this.countdown != 0) {
      template ("Your ride will arrive in #{value(this.countdown)} seconds.") 
    } else {
      template ("I hope you are enjoying your ride")
    }
  }
  refresh {
  if (this.countdown != 0) {
    spec {
      delay-seconds (5)
      with-request {
        intent {
          goal: CheckRideShareStatus
          value {
            $expr (this)
          }
        }
      }
    }
  }
}
  render {
    layout-macro (activity-map-macro) {
      param (activity) {
        expression (this)
      }
    }
  }
}

The Bixby team has provided a working example on Github

Detail on refresh here

1
On

Although it's possible to do a 1 second refresh this is definitely going to suffer from inaccuracy due to latency.

Depending upon your use case, simply creating an animated gif and displaying it may be simpler and definitely more accurate. Perhaps this combined with a refresh may be a better solution.

An example (from https://timertopia.files.wordpress.com/2018/06/30seccut.gif) would be something like this

enter image description here