DEV Community

Cover image for Day 55 of #100DaysOfCode: Learn Monkey C (Garmin Connect IQ)- Retrieve common data
Jen-Hsuan Hsieh
Jen-Hsuan Hsieh

Posted on

Day 55 of #100DaysOfCode: Learn Monkey C (Garmin Connect IQ)- Retrieve common data

Introduction

We can use Monkey C and Connect IQ SDK to customize the appearance of Garmin devices. The article is the note for learning Monkey C.

Welcome to visit the following articles to learn Garmin Connect IQ developing

Start/Finish an activity

  • Click the right-top button
class ExampleDelegate extends Ui.BehaviorDelegate {
    function initialize() {
        BehaviorDelegate.initialize();
    }
    function onKey(evt) {
        var lastKey=evt.getKey();
        if(lastKey==Ui.KEY_ENTER || lastKey==Ui.KEY_START) {
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Retrieve common data

1.ActivityInfo Common indicators

Usages

using Toybox.Activity;
class ExampleView extends Ui.View {
    function updateData() {
        var actInfo = Activity.getActivityInfo();
        Sys.println(actInfo.currentCadence);
        Sys.println(actInfo.currentHeartRate);
        Sys.println(actInfo.elapsedDistance);
        Sys.println(actInfo.elapsedTime);
    }
}
Enter fullscreen mode Exit fullscreen mode

2.Running dynamics data Common indicators

Usages

using Toybox.System;
using Toybox.AntPlus;
using Toybox.System as Sys;

class RunDataProvider {
    var RD;

    function initialize() {
        var listener = new Toybox.AntPlus.RunningDynamicsListener();
        RD = new Toybox.AntPlus.RunningDynamics(listener);
    }

    function getRunningData() {
        return RD.getRunningDynamics();
    }
}


using Toybox.Activity;
class ExampleView extends Ui.View {
    var mRunDataProvider = null;
    function initialize() {
        View.initialize();
        mRunningDataProvider = new $.RunningDataProvider();
    }

    function updateData() {
        var runningData = mRunDataProvider.getRunningData();
        Sys.println(runningData.stepLength);
        Sys.println(runningData.verticalOscillation);
        Sys.println(runningData.groundContactTime);
        Sys.println(runningData.groundContactBalance);
    }
}
Enter fullscreen mode Exit fullscreen mode

Usages


using Toybox.UserProfile;
module ExampleModule {
var heartRateZone = "";
    function getMyHeartRateZone(){
        heartRateZone = "";
        var hrz = UserProfile.getHeartRateZones(UserProfile.HR_ZONE_SPORT_GENERIC);
        for(var i = 0; i < 5; i++){
            heartRateZone += hrz[i] + ",";
        }
        heartRateZone += hrz[5];
    }
}


using Toybox.Timer;
class ExampleView extends Ui.View {
    var _refresher = new Timer.Timer();
    function initialize() {
        View.initialize();
        Ui.requestUpdate();
        _refresher.start(method(:onTimer), 1000, true);
    }
    function onTimer(){
        Sys.println(JapanWearableExpo2020.heartRateZone());
    }
}

Enter fullscreen mode Exit fullscreen mode

That's it!

Articles

There are some of my articles. Feel free to check if you like!

Top comments (1)

Collapse
 
ikif profile image
Ikif

Example\source\RunDataProvider.mc:26: Undefined symbol "RunningDataProvider" detected.