Problems for my watch face for vivoactive 3, fenix 6 pro and FR245 only

Hi, I have a watch face in the Garmin connect IQ shop : https://apps.garmin.com/en-US/apps/5e1ebcab-39e4-4686-966c-a8ed6a8ca42c and I get some report from  vivoactive 3, fenix 6 pro and FR245 users for problems. The Vivoactive 3 users say things like "Settings in the app is a blank white page, and it jams up the watch (the buttons and touch screen becomes non-responsive, and the backlight will not turn itself off, draining the battery). Only way to regain function is to do a forced restart and change to another watch face". The Fenix 6 users write that there's an error message appeared in Garmin Connect Android app stating "cannot communicate with watch" and for the FR245 they can't use the settings. All of those problems are not seen in the ERA page and they don't have any CIQ_LOG files in their devices after using it so I can't even get a hint for what causing the problem.

Everything works fine in the Eclipse simulator so it is super weird for me. I couldn't find any errors in my code that will cause problems. Also I can't understand exactly why there are problems with the Vivoactive 3 and fenix 6 pro. There is a floor indicator that I might messed up and caused the problem with the FR245 (that doesn't have floors indicator in it).

I add the full code for the watch face since I believe it might help https://drive.google.com/drive/folders/1kDoljrg9i3dGrfCX_tPcCf-jXLZCL9HV?usp=sharing

I am posting it here since I am clueless. Last time you helped me with the ERA errors but now the errors aren't in ERA at all and I don't have any of these devices to test.

Please help me understand what caused/may cause the problem.

Thank you in advance everyone.

  • Oh I see. Thank you Jim. Yeh I agree I should do and I will do so when I will finish this. The only error I have now is:

    BUILD: ERROR: C:\temp\eclipse-workspace\Digital Elegant4\source\DigitalElegantApp.mc:28:  Undefined symbol "MySettings" detected.

    I saw that the onSettingsChanged function was existed already so here's the AppBase now:

    import Toybox.Application;
    import Toybox.Lang;
    import Toybox.WatchUi;
    
    class DigitalElegantApp extends Application.AppBase {
    	var view;
    	
        function initialize() {
            AppBase.initialize();
        }
    	
        // onStart() is called on application start up
        function onStart(state as Dictionary?) as Void {
        }
    
        // onStop() is called when your application is exiting
        function onStop(state as Dictionary?) as Void {
        }
    
        // Return the initial view of your application here
        function getInitialView() {
            view=new DigitalElegantView();
            return [view];
        }
    
        // New app settings have been received so trigger a UI update
    function onSettingsChanged() {
                view.MySettings.load();
                WatchUi.requestUpdate();
            }
    
    }
    
    function getApp() as DigitalElegantApp {
        return Application.getApp() as DigitalElegantApp;
    }

    Here's the full view.mc again: https://pastebin.com/CTRNAWmF . I can't understand why it wouldn't work now because everything in the view.mc file should be ok now.

  • study the doc and the samples/templates as understand this is basic,

  • Sorry for not understanding Jim but the only thing came out in my head was using var MySettings; in the AppBase and all I had was black screen. I looked on other samples in the SDK and I haven't found something similar to this. The only AppBase that had something similar was the Crystal watch face but it was different too because the code had onSettingsChanged in the view.mc file too which is not happening in my view.mc

  • This is why you need to get a better understanding of monkey C, classes, etc.  What .mc something is in doesn't mean which class it's in, or if something is in the view, it may be called from AppBase.

  • Having a separate settings class has pros and cons.

    Pros: cleaner design, code is easier to maintain

    Cons: consumes more memory (not an issue in your case), more code to write

    In your case, you can work iteratively if you are more concerned about getting your code in a working state

    e.g.

    1) Move the reading of settings to a separate *function* in your View class, without trying to create a whole new Settings class. This allows you to accomplish the original goal of not reading settings or loading resources in onUpdate(), because that can slow your app down (especially for non-watchface apps, like a datafield where onUpdate would be called every second.)

    2) When you're comfortable, move settings to a separate class, if you want. This is the kind of thing I personally wouldn't do if I'm short on memory (which I don't think you are), as it does consume more memory for code and objects at run-time

    In your case, since part of the goal is to load resources at the same time that you load settings, it's also simpler to have a single loadSettings() function in your view which loads both settings and resources. If you went the route of having a separate class for settings, then it might not make sense to load resources there, which would make your code a bit more complicated.

    So let's go back to your previous code which did *not* have a settings class.

    In your View class, you would define a new function to load settings, as well as some member variables to store them, and member variables to store your loaded resources. This is just a snippet, to give you an idea of the kind of changes you'd make.

    function initialize() {
        // ...
        loadSettings(true);
    }
    
    var settingBG; // variable which stores the current value of the "BG" setting
    var resourceNotificationIcon; // in onUpdate, pass this to dcDraw() instead of loading the resource every single time
    
    // Load settings and load resources which depend on settings
    function loadSettings(isInit) {
        var newSettingBG = Application.Properties.getValue("BG");
    
        // If "BG" setting has changed (or we're loading settings for the first time), load the appropriate resource(s)
        if (isInit || settingBG != newSettingBG) {
            settingBG = newSettingBG;
    
            if (settingBG == 0) {
                resourceNotificationIcon = WatchUi.loadResource(Rez.Drawables.NotificationIcon);
                BGC = Graphics.COLOR_BLACK; // you could also keep this logic in onUpdate(), as it's not expensive like loadResource
            } else {
                resourceNotificationIcon = WatchUi.loadResource(Rez.Drawables.InvNotificationIcon);
                BGC = Graphics.COLOR_WHITE; // you could also keep this logic in onUpdate(), as it's not expensive like loadResource
            }
        }
        // ...
    }

    In your App class, call this function in onSettingsChanged()

    function onSettingsChanged() {
        view.loadSettings(false);
        WatchUi.requestUpdate();
    }

  • Hey Flowstate, thanks a lot! I really appreciate your help and the time you invested for this. Your explanations on the code itself made it much clearer. I expected everything to work just as planned but I encountered a problem almost a hour ago with the BGC. for some reason the background is black only and the screen clear isn't working well because pixels stay on the watch face. I started to move the BGC everywhere and then I saw that for some reason it doesn't change. Even if I change the settings in onUpdate() to: 

     dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
            dc.clear();

    The result stays the same. I am sorry that I still can't understand what is the problem with my code but I really tried as much as I could to find where I've messed up. I even tried to do the whole process again yet there was no difference.

    I am adding the full code of the view.mc and the app.mc because I believe that the problem is there: https://pastebin.com/KiqKJYHg

    import Toybox.Application;
    import Toybox.Lang;
    import Toybox.WatchUi;
    
    class DigitalElegantApp extends Application.AppBase {
    	var view;
    	
        function initialize() {
            AppBase.initialize();
        }
    	
        // onStart() is called on application start up
        function onStart(state as Dictionary?) as Void {
        }
    
        // onStop() is called when your application is exiting
        function onStop(state as Dictionary?) as Void {
        }
    
        // Return the initial view of your application here
        function getInitialView() {
            view=new DigitalElegantView();
            return [view];
        }
    
        // New app settings have been received so trigger a UI update
    function onSettingsChanged() {
        view.loadSettings(false);
        WatchUi.requestUpdate();
    }
    
    }
    
    function getApp() as DigitalElegantApp {
        return Application.getApp() as DigitalElegantApp;
    }

    I am adding pictures of it so it will be easier to understand: BLACK BG

    WHITE BG: 

    I have a feeling that is something small that I am missing up here but it is driving me insane how I can't make it work.

  • dc.clear() erases the screen with the background color, not the foreground color. See:
    [https://developer.garmin.com/connect-iq/api-docs/Toybox/Graphics/Dc.html#clear-instance_function]

    Your current code sets the background color to transparent, just before dc.clear() is called.

    Try changing

    function onUpdate(dc as Dc) as Void {
        dc.setColor(BGC, Graphics.COLOR_TRANSPARENT);
        dc.clear()
    to
    function onUpdate(dc as Dc) as Void {
        dc.setColor(BGC, BGC);
        dc.clear()
    Also, I'm sure you're aware, but your onUpdate() function still loads properties. Ideally you would move all of the Properties.getValue() calls to loadSettings(). Another optimization would be to only call getDeviceSettings() once in onUpdate() and store the result in a local variable so you can reuse it.
    Hey Flowstate, thanks a lot!

    No worries!

  • Oh wow I don't know how it went out of my mind. It's something I've done already. Sorry that I had to bother you with this question. Anyways, thanks for the help, everything works fine now, really appreciate the help from you and Jim in this whole discussion.