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) {
}
}
}
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);
}
}
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);
}
}
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());
}
}
That's it!
Articles
There are some of my articles. Feel free to check if you like!
- My blog-posts for software developing: https://medium.com/a-layman
- My web resume: https://jenhsuan.github.io/ALayman/cover.html
- Facebook page: https://www.facebook.com/imalayman
- My latest side project - Daily Learning: https://daily-learning.herokuapp.com/
Top comments (1)
Example\source\RunDataProvider.mc:26: Undefined symbol "RunningDataProvider" detected.