drawArc on Fenix3

Hi,

If I use the function dc.drawArc in a View which is working in the simulator, I get an exclamation mark when I upload it to my Fenix 3. Is this function not supported in SW version 4.70?

KR,
Christof
  • Ideas welcome!

    Hi,

    As I said, the support is nice, I definitely need it, I own my watch some weeks, so I am still learning.

    I added the App to GitHub ( see https://github.com/oe8bck/StartTimer ) If you have an idea, why the App is not closed correctly, please tell me!

    KR,
    Christof
  • Christof,

    Are you testing the code in the simulator at all? If you get an error in the simulator, you should see a message printed to the console. Additionally, you can attempt to catch the exception that is being thrown, and you can inspect that to figure out what happened.

    Travis
  • Salt branch

    Hi, thanks for your support!

    Yes, it runs in the simulator, no errors given. There is a different behaviour in the simulator, I cannot end the app with the buttons. When I choose "File->Suspend App" then the Simulator crashes (no error given in the console output) Coosing "File->Kill App" works as expected (simulator does not crash)

    Hot wo catch the exception and debug it when it's not visible in the simulator? (as I said, I am quite new to this)

    I am thinking if the timer is the problem, I will try to stop it when the app is closed (onStop())

    KR,
    Christof
  • If you add the following code to InputDelegate the app should exit on the simulator when you press the back button...

    function onBack() {
    Ui.popView(Ui.SLIDE_IMMEDIATE);
    return true;
    }
  • Hot wo catch the exception and debug it when it's not visible in the simulator? (as I said, I am quite new to this)

    You can create a log file on the device, and then use Sys.println() to write text to the log file. If your program name is MyTest.prg, you would create a log file named GARMIN/APPS/LogsMyTest.txt.

    I am thinking if the timer is the problem, I will try to stop it when the app is closed (onStop())

    It is always a good idea to cleanup resources. It looks like you might want to move the timer into the app, and add methods for accessing it. Something like this should work...

    class MyApp extends App.AppBase {

    hidden var timer;
    hidden var timer_callback;

    function initialize() {
    }

    function onStart() {
    timer_callback = null;
    resumeTimer();
    }

    function onStop() {
    pauseTimer();
    timer_callback = null;
    }

    function pauseTimer() {
    if (timer != null) {
    timer.stop();
    timer = null;
    }
    }

    function resumeTimer() {
    if (timer == null) {
    timer = new Timer.Timer();
    timer.start(self.method(:onTimer), 1000, true);
    }
    }

    function onTimer() {
    if (timer_callback != null) {
    timer_callback.invoke();
    }
    }

    function setTimerCallback(callback) {
    timer_callback = callback;
    }

    function getInitialView() {
    return [ new MyWatchView() , new InputDelegate()];
    }
    }

    class MyWatchView extends Ui.View {

    function initialize() {
    App.getApp().setTimerCallback(self.method(:timerCallback));
    }

    function timerCallback() {
    counter -= 1;
    if (counter < 0)
    {
    counter = counter_start-1;
    }

    Ui.requestUpdate();
    }

    function onHide() {
    Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:onPosition));
    App.getApp().pauseTimer();
    }

    function onShow() {
    Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));
    App.getApp().resumeTimer();
    }

    // rest of your code...

    }
  • Timer

    Hi,

    Thanks for the code snippet, it was easy to change the code this way! I also added a number picker (from another thread here) and vibration alarm. Now I am coming closer to the features I want to implement.

    In the simulator it works as expected, I did not test it on the real watch, let's see if it still crashes the watch when re-entering the App. I had a look, but I cannot find the log file you mentioned above, there is no such .txt file. Did I miss some setting?

    BTW, I just saw that
    function onBack() {
    Ui.popView(Ui.SLIDE_IMMEDIATE);
    return true;
    }
    is still missing. I will add it and see if this helps against crashing.

    KR,
    Christof
  • I had a look, but I cannot find the log file you mentioned above, there is no such .txt file. Did I miss some setting?

    The file isn't there unless you make it.... As I said above, you must create the file.
  • Log File

    Hi Trevis,

    Sorry for the stupid questions, your support is definitely necessary ;)

    The file isn't there unless you make it.... As I said above, you must create the file.


    I searched the API how to create the log file. But I did not find anything how to do it within the App. So I asked google and there I found that I should generate the file with my PC. Is this the way to do it? Just a "touch /GARMIN/APPS/LOGS/FC662511.TXT" if the name of the App file is FC662511.PRG?
    (https://apps.garmin.com/en-IE/apps/ded87d46-5477-4ca7-a247-847b896393e0)

    The App freezes the watch when I ran it once and then want to re-enter it with the START button. I think there is some memory issue, I have to track it down in detail.

    KR,
    Christof
  • You don't create the log file from the ConnectIQ API. Connect your device to a PC/Mac. Create a text file in the appropriate location. Eject the device.

    If your app is running low on memory, adding tracing code will only exacerbate the problem as adding any code or string data will increase the memory requirements.

    Travis
  • Logfile

    Well, creating the file with the PC works, now I get the logging. I attached one.
    ---
    counter_start:240
    UnexpectedTypeException: Expected String, given
    initialize in D:\Projects\outdoor\Fenix3\TVM\api\Ant.mb:122
    counter_start:240
    UnexpectedTypeException: Expected String, given
    initialize in D:\Projects\outdoor\Fenix3\TVM\api\Ant.mb:122
    ---

    "counter_start:" is triggered by a println, but what's the other message about?

    BTW: I updated the github source code:
    https://github.com/oe8bck/StartTimer

    The

    KR,
    Christof