Ambient pressure and pressure history don't match

Hey all, does anyone know what pressure the pressure history is storing? I have tested with putting both on screen and my ambient pressure is always higher than my max pressure history (over last 30 mins) so what is this doing?

If I look at my watch now it shows PH getMax to be 101833 and my AP now to be 102996. The PH never been above 101... if I put it in water (20cm) the AP goes up to 104888 which shows AP sensor is moving but PH never changes or goes near it.

Any insights would be great as I am trying to see historical pressure history to make a "guess" on no fly time for diving.

Many thanks,

Ben

  • Awesome, thanks Jim! Slight smile

  • Hey Jim, got the blog post code working and put it on my own watch as I want to use AP which isn't supported in the simulator and no matter how long I leave it in the background, when I go back to the WF, it only returns 1 result. I read in the documentation it will collect and store if multiple temporals run in the background but when ever I print out the "bgData" or data, it is just 1 value. Any ideas how I can collect multiple and read them out?

    Also I assume the background process works by storing only when in background and you need to add those values to an array in the WF and once you read the background data, it empties and when in WF mode, you collect as normal, only when you go out of it you top up the main array with the background data when you return to it? That right?

    Thanks again for your help :)

  • In the background, you use 

    Background.getBackgroundData();
    This is what has yet to be seen by the main app. You take this, check that it's under the max size, add the newest reading, and use Background.exit() to return the combined data.  In the widget I mentioned, I return at most the newest 96 readings.
  • So you mean in this method (from your example I downloaded):

    function onTemporalEvent() {

        var pres = Activity.getActivityInfo().ambientPressure;

            Background.exit(pres);

        }

    I should be using Background.getBackgroundData();, append the pres reading and then return the whole thing? So something like:

    function onTemporalEvent() {

        var pres = Activity.getActivityInfo().ambientPressure;

    var bgstuff = Background.getBackgroundData()

            Background.exit(bgstuff + "," +pres);

        }

    That what you mean? In the WF example I downloaded you don't use Background.getBackgroundData() so not sure if that is used before sending the data or if I should use it in the main App or WF to get everything?

    Thanks again Slight smile

  • Yes.  And in onPackgroundData you need to handle the complex data it may see,

    in onTemporalEvent, you may also want to limit the size of what you return - strip off old data if it gets too large.

  • Thanks Jim, makes sense. And finally, what puts the data into the backgrounddata method? I don't see that part... cannot figure it out from the docs Disappointed I understand the .exit method but feels like I should be pushing the data into the background method for it to queue when it .exits? Maybe this is beyond my coding skills but feels like I am very close... 

    Thanks again!

  • The background can run without the main app running.  If that happens, what's returned by Background.exit() is in getBackgroundData().  Let's say that you are recording a run activity.  Your WF doesn't run during that time, but the bacckground will.  So it may queue up a number of samples during that time.

  • After hours of playing with this and trying things, I finally have it working! Thanks Jim Slight smile

    BTW is there a split type method for a comma delimited string or do I need to write my own method for this? Cannot find any string splitters or array conversion methods. Just Find which would require iterating through the string I guess... 

    Thanks again! Huge help :) 

  • Instead of a comma separated sting, try an array, where you use add() to append something new, and slice() if you need to reduce the size.  That way you can just walk the array .