Need advice

Good day to all.
Actually, need two advices. Both for watch face developing.

First one with getting GPS position for further calculations.
Before I used “currentLocation” from “Activity.getActivityInfo()”, but it makes some inconvenient, to get PSN data, need to activate GPS in short time before position data will be used. Same, when need to refresh changed GPS PSN – extra code requested.
Not so far, while making widget, I found that GPS PSN can be taken from “(Position.getInfo()).position” and it’s looks like that last received GPS PSN stored there constantly, and automatically updated, when received.
It’s properly working with beta fw 9.72, tested on Fenix 5x and 5s. But on fw 9.2 (same devices) got two different errors: 5x error – “Unexpected Type Error”, 5s – “Permission error”. After update devices to 9.72 all working smooth and without errors.
Question is: is it new possibility of last beta or bug of last official?

Second question regarding “settings” file from “resources” with watch face settings. One of my watch face has 8 cells to data selected by user. For each cell can be selected one from thirteen types of data. I’m using same list of option for each cell, it’s just duplicated eight times.
Question is: is there any possibility to avoid duplicating and call same option list for each cell?
  • onPartialUpdate will be called on watches that support it unless you've exceeded the prover budget, and then it stops. But it should just be a simple check of the property, and if you have it off, just return, so a cheap call.
  • Good day.
    Again need advice. Actually two.
    First one, simpler and answer looks like will be “no”. Anyhow, is it possible to dc.setClip for not rectangle shape?
    Second one, more important. One of the user asked me to add weather forecast to watch face. As I understood Communication does not work with watch face same as with widget (just gives “permission error”). To use Communication.makeWebRequest I have to use background process. But I did not found any explanations or, much better, example – how it should looks like.
    Should I use call in onTemporalEvent() function makeRequest() which on response will call function onReceive (as done in WebRequest sample from SDK).
    I’ve made couple Sys.println() inside of functions, to check if they called. But got prints on BG call, on makeRequest. But it seems like onReceive was not called. Code add below.
    When I tried makeRequest and onReceive in widget mode. All worked.

    Kindly asking advice and help for this question.


    using Toybox.Background;
    using Toybox.Communications as Comm;
    using Toybox.System;

    (:background)
    class requestWebData extends System.ServiceDelegate {

    function initialize() {
    ServiceDelegate.initialize();
    }

    function onTemporalEvent() {
    System.println("In BG");
    var getWeather = makeRequest();

    //return data
    Background.exit(getWeather);
    }

    //Call
    function makeRequest() {
    System.println("In CALL");
    Comm.makeWebRequest(
    "api.openweathermap.org/.../weather
    {
    },
    {
    "Content-Type" => Comm.REQUEST_CONTENT_TYPE_URL_ENCODED
    },
    method(:onReceive)
    );
    }
    //Receive
    function onReceive(responseCode, data) {
    System.println("In RESPONCE");
    var result;
    if (responseCode == 200) {
    result = data;
    } else {
    result = "Failed to load\nError: " + responseCode.toString();
    }
    return result;
    }

    }
  • 1) You are correct. Only a rectangle

    2) In just a simple case, the place you want to call Background.exit() is in onReceive(), and not in onTemporalEvent. The "return result"in onReceive, doesn't get passed back as a return from make WebRequest().
  • Good day again.

    Is there any possibility to get height above sea level data from device? As I know it use it to convert Mean Sea Level
    ressure and it’s can be seen while barometer calibration.

    But how to get this data (means – height above sea level for current location) for further calculations in widget?
  • Activity.Info.altitude on devices with a baro altimeter. But as the baro drifts, so will this.
  • Act.getActivityInfo().altitude

    Noted, thanks a lot.
  • And again need advice)

    Is there any easy way to round or just cut 1.2345 to 1.2?
  • for calculations or for display?