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?
  • For display.

    I did not find better solution than:

    var x = 1.2345;
    (x.toString()).substring(0,3);


    But it looks ridicules…
  • Former Member
    Former Member over 7 years ago
    var x = 1.2345;
    string = x.format("%0.1f");
  • Exactly what I need!
    Thanks a lot!))
  • Good day and again need advice))

    Making widget.
    It has like main view with some amount of two different type of data. And I’m tying to make menu (onSelect) where, user can choose one from two data types to open extended view for them.
    Some how:
    ........................................mainView
    ..............................................|
    ..........................................Menu
    ..................................Item 1....... Item 2
    ......................................|..................|
    Extended view for Item 1 ............ Extended view for Item 2

    Main view – done; menu to select Item 1 or Item 2 – done;

    Question is: how to draw data for Item 1 and Item 2?
    I’ve tried to pass “dc” there – no working, tried to make separate “view” class for both items, but when on call – shows nothing…
  • With Watch Faces and Data Fields, onUpdate() is called for you on a regular interval. For Widgets and Device Apps, it's not.

    So what you need to do is call Ui.requestUpdate() when you want the screen to update. This can be done based on a timer (call Ui.requestUpdate() every X seconds) or based on an event (Data received from the internet, you selected a different screen, etc)
  • No, no, Jim, question is different.

    Question exactly how make different (extra view) screen.

    I’ve made some widget, let’s say with basic screen No1. When I’m clicking “Start” button it’s get me to menu with “item1” and “item2” to choose. (Up this place all working).

    But next step I need to make:
    when I select “item1” from menu, widget will show screen No2, if will select “item2” from menu, widget will show screen No3

    Basic screen show’s basic information for two conditions, screens No2 and No3 will show extended information for them (results of some calculations, formatted text and nubers).

    The question is – how to make those screens? I tried to make function in classical way, which we call to show some data from “onUpdate”, for example “function showsSomeData(dc)” and tried to call this function from “delegate” class if corresponding “item” selected but I did not find how to pass ”dc” to this function to show text and draw figures on screen.
  • One way to do it is with a single view, but has something like a "Screen number", and in update, do display the data/screen for that page. You can do it with direct dc calls.
    function onUpdate() {
    dc.setColor(Gfx.COLOR_BLACK,Gfx.COLOR_BLACK);
    dc.clear();
    dc.setColor(Gfx.COLOR_WHITE,Gfx.COLOR_TRANSPARENT);
    switch scrno {
    case 0:
    dc.drawText(25,10,Gfx.FONT_SMALL,"zero",Gfx.TEXT_JUSTIFY_LEFT);
    break;
    case 1:
    dc.drawText(50,30,Gfx.FONT_MEDIUM,"one",Gfx.TEXT_JUSTIFY_CENTER);
    break;
    }
    }

    and then in the delegate, set scrno as needed;
  • Great! Just what I need!
    Jim, thanks a lot for your help and support!)
  • And again…))

    I’m making widget. And some part of the code need to adjust for different type of display size.
    To make it, I decided to use jungles (excludeAnnotations), code below.

    Question is: for each kind of display size I have to make two excludeAnnotation. I’ve made two
    rows, is it correct way, or I can put two exclusions in same raw using, for example comma?

    monkey.jungle

    round-218x218.excludeAnnotations = bigScreen
    round-218x218.excludeAnnotations = semiround
    round-240x240.excludeAnnotations = smallScreen
    round-240x240.excludeAnnotations = semiround
    semiround-215x180.excludeAnnotations = bigScreen
    semiround-215x180.excludeAnnotations = smallScreen
  • You want to do something along the lines of
    round-218x218.excludeAnnotaions=bigScreen;semiround

    as with what you have, the second line replaces the first

    Also, not all 218x218 devices are the same. The f5s and f3 for example.

    Not sure how much you need to make different, but if it's only a small amount, maybe consider doing it at runtime in onLayout()

    if(width==height) { //round
    if(width==218) //small

    } else { //big

    }
    } else { //semi-round

    }