Shaking WF

I have a desire to make WF with a change in the display of information on shaking the watch. How to implement it, what API function to use?
  • Not quite shaking, but on a gesture. In a watch face, you can tell if you are in low power or not with onEnterSleep() and onExitSleep().

    After onEnterSleep(), onUpdate() is called once a minute, and after onExitSleep(), onUpdate() is called every second for about 10 seconds, and you'll see when this is over when onEnterSleep is called. This is how devices that can't do 1hz can display seconds after a gesture.

    In the sim, under settings is a checkbox for "Low Power Mode". When checked, onUpdate is called every minute, when unchecked, every second. There's no 10 second timeout in the sim. As you check/uncheck it, you'll get the onEnterSleep() and onExitSleep() calls.
  • Thanks for the answer. All about what you wrote - I already use in my WF.
    I'm interested in a certain external flag that the user generates (for example, a watch shake), which I can use at that moment when this flag occurs (regardless of whether the watch is in "Low Power Mode" or not).


  • The versions of Data Lover prior to it's public release also used the approach of misusing the high power activation to toggle functionality as Jim alludes to above, but I didn't think it worked well in practice as it was always activating when you didn't want it to activate. I spent a considerable amount coding the feature but the switching annoyed the hell out of me when I was using the watch face, so I threw all that code in the bin....

    Feel free to have an attempt too, but don't say I didn't warn you :)
  • It actually works well, and was the way a watch face could display seconds after a gesture before onPartialUpdate(). I use it today to handle devices without 1hx seconds, or if the avg power budget is exceeded on watches that do.

    Here's the code I use:
    //! The user has just looked at their watch. Timers and animations may be started here.
    function onExitSleep() {
    inLowPower=false;
    if(!do1hz) {Ui.requestUpdate();}
    }

    //! Terminate any active timers and prepare for slow updates.
    function onEnterSleep() {
    inLowPower=true;
    if(!do1hz) {Ui.requestUpdate();}
    }

    I set a boolean as far as the state, and if I'm NOT doing 1hz, do the Ui.requestUpdate(). I forget why, but seems the seconds could be a bit "jumpy" if it was doing 1hz (onPartialUpdate). So the flag gets set and onUpdate() gets called right away. onUpdate() then does things based on the inLowPower flag.

    Without the Ui.requestUpdate, it can be a minute before onUpdate is called after the onEnterSleep() is called.
  • I'm not saying that technically it didn't work :) but it didn't work well for me "emotionally" as it was always displaying the wrong screen that I wanted to see (eg graph screen when I wanted to see the time), maybe it works better if the content of your (several) screens isn't too different....
  • Part of that could be I think "shaking" may cause entering and leaving low power quickly, and just a simple writ turn could be better.