#GARMIN – Read and display sensors data in a #ConnectIq app

Hi !

In today’s sample I’ll show how to create a WatchFace app which displays the current time and also the heart rate of the smart watch user. Most of the details will be added in the references section where you can find plenty of information on how the MonkeyC language works, or the different types of apps supported for Garmin watches.

The final output of the app in the simulator will be like this:

2016 02 22 Garmin HrData

So, once we created an app in Eclipse, next step is to configure some project properties. I selected the app type as “Watch App” so I can access to the sensors information. Other project types does not allow access to sensors information.

image

I also selected the target platform with my current smartwatch,m and finally I grant permissions to the app to access sensors information.

You can also update all this information in the [manifest.xml] file.

image

In the Developer Guide there is specific section for the build and package of applications where the manifest.xml file details are exposed. Once we have our app configured to access the sensors information, we can create some code to display this information.

In the following sample, there are some important topics

  • When the app is initialized, I allow the access to the Heart Rate sensor data
  • The the HR data is updated, there is a callback function to onSensor() method
  • In the onSensor() method I store the data in a local variable, display this information in the console log, and also I force an app User Interface layout update
  • In the Layout update method, I display the current time and also the current Heart rate sensor information

image

So, right now we have the basic code to create and app and display HR sensor data. If we run the app in the simulator, we’ll realize that the sensors data is NULL. We can emulate the data from the emulator with the options “Simulation // FIT Data // Simulate Data”

image

And now you can start to get some dummy HR data to your app.

From this post on, I’ll also start to also share the code in my GitHub repo: https://github.com/elbruno/Blog/tree/master/Garmin

Greetings @ Toronto

– El Bruno

References

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s