2
$\begingroup$

Currently trying to utilise the ClockGauge function to display two clocks side-by-side that have different UpdateInterval. The end goal is to create some sort of relativistic time dilation tool like this one except include preset options to choose different satellites like GPS, GLONASS etc. and hence, calculate both special and general effects of relativity. However, I can't get the clocks to display different update intervals? Any suggestions?

Code below:

Dynamic[
  Row[
    {Refresh[
       ClockGauge[AbsoluteTime[], PlotLabel -> Style["Local", Bold, Large]], 
       (UpdateInterval -> 1)], 
     Refresh[
       ClockGauge[AbsoluteTime[], PlotLabel -> Style["LocalDelayed", Bold, Large]], 
       (UpdateInterval -> 10)]}]]
$\endgroup$
  • 2
    $\begingroup$ Replace refresh with dynamic $\endgroup$ – Kuba Oct 23 '17 at 21:37
  • 2
    $\begingroup$ And drop the Dynamic at the front. i.e. take your code and do this: code // First[#]/.Refresh->Dynamic& $\endgroup$ – b3m2a1 Oct 23 '17 at 22:13
4
$\begingroup$

I think you need something else but first let's discuss the problem you have with your code.

OP's approach

By using:

Dynamic[ 
  ... 
  Refresh[... UpdateInterval -> x]
  Refresh[... UpdateInterval -> y]
  ...
]

you make the parent Dynamic updated each Min[x,y]. Refresh are not handled separately, it is Dynamic that governs updating at the end. See What is the point of Refresh if Dynamic has an UpdateInterval option? and read related sections in tutorial/AdvancedDynamicFunctionality.

So you need to do:

  (*parent dynamic dropped, nothing outside gauges needs updating*)
Row[{ 
  ... 
  Dynamic[ClockGauge... UpdateInterval -> 1]
  Dynamic[ClockGauge... UpdateInterval -> 10]
  ...
}]

The best would be to keep only the time dynamic, not the whole gauge but ClockGauge does not support Dynamic arguments e.g. Gauge[Dynamic[time]...]

My approach

Finally, I don't think this is what you want. It will result with two clocks showing current time but one will tick each second while the other each 10 seconds.

You would probably prefer to show clocks where time passes with different speeds:

With[{start = AbsoluteTime[]}, 
 Dynamic[
  Row[{
   ClockGauge[start + Clock[{0, 10^6, .1}, 1/2 10^6], 
     PlotLabel -> Style["Local\n x 2", Bold, Large]],
   ClockGauge[start + Clock[{0, 10^6, .1}, 1/0.5 10^6], 
     PlotLabel -> Style["Local Delayed\n x 0.5", Bold, Large]]
  }],
  UpdateInterval -> .1]
]

enter image description here

Notice that I use one Dynamic now because we control 'speed' with Clock.

Sorry if I missed your point.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.