#Garmin – Display charts and several sensors information at once

Hi !

Today’s post is a quick one for Friday. My main goal in the past days was to complete all the necesarry stuff I’ll need to live in Toronto, and in the meantime I’ll continue to play around with the ConnectIQ Garmin SDK.

As you can see in the next video, I get to a point where

  • The app can read information from different sensors: position and heart rate
  • Based on a SDK sample the app can draw a chart for the HR data
  • The app creates a dinamyc layout with different (and ugly!) colors when the device is using sensors data or not

2016 02 25 Garmin display multiple sensors

So, the important stuff for this demo is

  • The app must be configured to use Sensors and Position information, in the app properties

image

  • The App class will initialize the sensors and positions. On each “get data” event, it will invoke the View class to display this data
  • The View class has some code to dinamically work in the layout to create texts and charts for the View

image

  • The chart used for the Heart Rate data is a Graph.mc file from the SDK samples

And that’s it ! the app is kind of smart enought to display real time information of positions and sensors in a very simple way!

GitHub Source Code: https://github.com/elbruno/Blog/tree/master/Garmin

Greetings @ Toronto

-El Bruno

References

#Garmin – Working with resources and cultures in a #ConnectIQ app

Hi !

When we create an app for a Garmin device, working with a resources is a #MustHave. We need to take take of simple stuff like change the culture of an app, In the following video, the main label of the app will change every time I change the culture of the smartwatch.

2016 02 24 Garmin Resource Languages

About Resources and Cultures

The ConnectIQ apps have a standard resource structure where we can define strings, store images and also define UI layouts or menus for our apps. We can find all of this elements in the main root folder of our project.

image

The root content folder for this is “resources”. For each different culture, we can add our owns folders and add only the different elements we need for each culture. In example, the main resource has this content in the “resources\strings\strings.xml” file

<strings>
<string id=”AppName”>App04</string>
<string id=”prompt”>Hello Martina</string>
<string id=”menu_label_1″>Item 1</string>
<string id=”menu_label_2″>Item 2</string>
</strings>

The same content for the Spanish culture will be located in “resources-spa\strings\strings.xml” and includes this content

<strings>
<string id=”AppName”>App04</string>
    <string id=”prompt”>Hola Martina</string>
    <string id=”menu_label_1″>Item 1</string>
<string id=”menu_label_2″>Item 2</string>
</strings>

There is also another important element in the app: the layouts (clearly explained in the programmers guide). I created a custom layout stored in a file named “resources\layouts\layoutcustom.xml”, which includes the following content

<layout id=”CustomLayout”>
<label x=”center” y=”5″ text=”@Strings.prompt” color=”Gfx.COLOR_WHITE” justification=”Gfx.TEXT_JUSTIFY_CENTER” />
<bitmap id=”id_martina” x=”center” y=”30″ filename=”../drawables/martina.png” />
</layout>

There are several elements which can be used in a layout file, like texts, images, shapes, etc. Again the programmers guide explains all the necessary information for this.

Resource Compiler

Finally we have the resource compiler. Every time we built our app, the resource compiler creates a set of classes which will allow us to work with this elements. If we have any issue or bad defined file, we’ll get some guidance in the Console log for Connect IQ.

image

Once we have a successful build in our app, we can access to this elements via code using the Rez module. This is an autogenerated module with a structure similar to this one

module Rez
{
    module Drawables
    {
        var bitmap_id = 123;
    }
    module Strings
    {
       var hello_id = 456;
    }
    module Fonts
    {
       var font_id = 789;
    }
}

In our sample, in order to access and use the Custom Layout, the way to do this is

image

In the same way we can access strings, fonts, bitmaps, etc.

In the next post more stuff and maybe some Azure connected sample.

GitHub Source Code: https://github.com/elbruno/Blog/tree/master/Garmin

Greetings @ Toronto

-El Bruno

References

#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

#Garmin – #Eclipse and #ConnectIQ as a good starting point to create #SmartWatch apps

Hello!

After yesterday’s Hello world, today I’l write a post on a more friendly way to create Garmin apps. The Garmin Development team, has chosen MonkeyC as Development language and Eclipse as IDE for development, and the truth that fit the development environment is fairly simple.

Setup Development Environment

First we must download a version of Eclipse Luna. Choose the option for Java Developers, in the first step of the installer.

image

Once we have installed Eclipse, we must add the extension to work with Garmin Apps projects. So we access to the menu “Help / / Install new Software”

image

We must add the software from

http://developer.garmin.com/downloads/connect-iq/eclipse/:

Once added the URL we should add the tools of Connect IQ

image

We accept the EULA, restart Eclipse and now is time to configure the location of the Connect IQ SDK in Eclipse. In the “Windows / / Preferences” menu select the option Connect IQ and the same configure the location of the SDK,

image

Important: You must select the location Root of the SDK, not the directory BIN, for exampleC:\Garmin\connectiq-sdk-win-1.2.4”

My First App, Hello World !

Now we can now create our first project for a Garmin app. Let’s start with “File / / New Project” and then select “Connect IQ / / Connect IQ Project”

image

After you define a name for the App, comes to define the type of app. There are 4 options

  • Watch Faces – These replace the main watch face and are the home screen of the watch.
  • Data Fields – Data fields run within Garmin activities. They allow developers to compute values based off of the current activity, such as running, biking, etc.
  • Widgets – Widgets are full screen pages that can be embedded into the main page loop. They are loaded when brought on-screen and shut down when the user switches to the next widget. Widgets will timeout and automatically shutdown after a device specific period of inactivity.
  • Wearable Apps – Started from the action list, wearable apps can be used to implement use cases like third party activities, games, and other user-initiated actions. Apps push a page onto the UI and exit when the user backs out of the last page of the page stack. While running, the app has full control of the UI.

For this sample I will create a WatchFace app for my Garmin Forerunner 235

image

There is a couple more extra options to choose, like the WatchFace type and the supported languages. And now we have a minimmun set of code to be build and run Eclipse for Garmin Connect IQ App

image

In the meny “Run // Run Configurations” we add some options to build, and run the app in the emulator.

image

So, after we create this new build configuration we can run the app. In the next image, you can see the emulator running the app, displaying my name and also the time in a simple way (line 42)

image

So that’s it as starting sample. More in the next posts !!!

Greetings @ Toronto

-El Bruno

References

#Garmin – #ConnectIQ y #Eclipse, una forma facil de comenzar

Hola !

Después del hola mundo de ayer, hoy vamos a ver algo más amigable para crear apps. El equipo de Garmin, ha elegido Eclipse como IDE para el desarrollo, y la verdad que montar el entorno de desarrollo es bastante simple.

Setup Development Environment

En primer lugar debemos descargar úna versión de Eclipse Luna. Elegimos la opción para Java Developers, en el primer paso del instalador.

image

Una vez que tenemos instalado Eclipse, debemos agregar la extensión para poder trabajar con proyectos para Garmin Apps. Lanzamos el menu “ Help // Install new Software “

image

Debemos agregar el software desde

http://developer.garmin.com/downloads/connect-iq/eclipse/:

Una vez agregada la URL debemos agregar las tools de Connect IQ

image

Aceptamos el EULA, reiniciamos Eclipse y ahora es momento de configurar en Eclipse la ubicación del Connect IQ SDK. En el menu “Windows // Preferences” seleccionamos la opción Connect IQ y en la misma configuramos la ubicación del SDK,

image

Importante: Hay que seleccionar la ubicación Root del SDK, no el directorio BIN, por ejemplo “C:\Garmin\connectiq-sdk-win-1.2.4”

My First App, Hello World !

Ahora ya podemos crear nuestro primer proyecto. Para esto seleccionamos “File // New Project” Y luego seleccionamos “Connect IQ // Connect IQ Project”

image

Después de definir un nombre para la App, llega el momento de definir el tipo de app. Hay 4 opciones

  • Watch Faces – These replace the main watch face and are the home screen of the watch.
  • Data Fields – Data fields run within Garmin activities. They allow developers to compute values based off of the current activity, such as running, biking, etc.
  • Widgets – Widgets are full screen pages that can be embedded into the main page loop. They are loaded when brought on-screen and shut down when the user switches to the next widget. Widgets will timeout and automatically shutdown after a device specific period of inactivity.
  • Wearable Apps – Started from the action list, wearable apps can be used to implement use cases like third party activities, games, and other user-initiated actions. Apps push a page onto the UI and exit when the user backs out of the last page of the page stack. While running, the app has full control of the UI.

En este caso, crearé una WatchFace y para mi Garmin Forerunner 235

image

Seleccionamos otras opciones más, como el tipo de WatchFace y los idiomas soportados. Ahora ya tenemos nuestro proyecto / con el mínimo de código para ser ejecutado en Eclipse.

image

Desde el menú “Run // Run Configurations” debemos configurar las opciones para la compilación y despliegue en el simulador o en el reloj.

image

Creamos una nueva configuración y ya podemos ejecutar la app. En la siguiente imagen podemos ver como he agregado una nueva línea en la app para que muestre mi nombre antes de mostrar la hora.

image

Como ejemplo para el primer día, creo que me vale. Mañana más !!!

Saludos @ Toronto

-El Bruno

References

#Garmin – How to setup the #Dev Enviromnent and a quick #HelloWorld to try the Emulator!

Hello!

In today’s post I will show how to configure the development environment to code and build an app for Garmin ConnectIQ SDK.

The first thing we need is to have a Java development kit version installed on our computer. In the references section, I have put the link to the JDK 8.

Now you can download and use the Garmin ConnectIQ SDK. To use it, we must just download the ZIP, unzip it and add the bin path to our local PATH.

01

Now we can use the 3 main tools included in the SDK:

  • connectIQ, launches the local emulator app
  • monkeyc, is the compiler to built an app from source code and resource files
  • monkeydo, it will run an app in the emulator

Using one of the examples in the SDK, I updated the “ConfirmationDialog” sample, so that it displays a different dialog. I’ve update the files

  • \manifest.xml
  • resources\strings.xml
  • sources\ConfirmationDialogApp.mc
  • sources\ConfirmationDialogView.mc

now I can compile and built the app. The command that I should throw to compile the app is as follows:

monkeyc -o ConfirmationDialog.prg -m manifest.xml

The output of the build process will generate an app in a file called “ConfirmationDialog.prg“. The next step is to launch the emulator and run the app compiled on it.

The commands for these actions are the following

set path=%PATH”;”c:\Program Files (x86)\Garmin\connectiq-sdk-win-1.2.4\bin\”
monkeyc -o ConfirmationDialog.prg.prg -m manifest.xml
connectiq
monkeydo ConfirmationDialog.prg.prg

Executed once we can already see the app, in simulation mode

02

And that’s it, we already have compiled, built and run an app in the Simulator. In next posts, I will see what I discover about the internal structure of the apps, and what else I learn.

Greetings @ Toronto

-El Bruno

References

#Garmin – Configurar el entorno de desarrollo y #HelloWorld con el emulador!

Hola !

En el post de hoy mostraré como configurar el entorno de desarrollo para crear una app para Garmin con ConnectIQ SDK.

Lo primero que necesitamos es tener una versión de Java development kit instalada en nuestro ordenador. En la sección de referencias he puesto el link a la versión JDK 8.

Ahora ya podemos descargar y utilizar el SDK de Garmin. Para utilizarlo, solo debemos decargar el ZIP, descomprimir el mismo y agregar la ruta bin a nuestro PATH local.

01

Ahora ya podremos utilizar las 3 herramientas básicas que se incluyen en el SDK:

  • connectIQ, lanza el emulador local de apps
  • monkeyc, es el compilador para generar las apps
  • monkeydo, ejecuta una app compilada en el emulador

Utilizando uno de los ejemplos del SDK, he modificado el ejemplo “ConfirmationDialog”, para que muestre un diálogo diferente. Después de modificar los archivos

  • \manifest.xml
  • resources\strings.xml
  • sources\ConfirmationDialogApp.mc
  • sources\ConfirmationDialogView.mc

ya puedo compilar la app. El comando que debo lanzar para compilar la app es el siguiente:

monkeyc -o ConfirmationDialog.prg -m manifest.xml

El output del proceso de compilación generará una app en un archivo llamado “ConfirmationDialog.prg”. El siguiente paso es lanzar el emulador y ejecutar la app compilada en el mismo.

Los comandos para estas acciones son los siguientes

set path=%PATH”;”c:\Program Files (x86)\Garmin\connectiq-sdk-win-1.2.4\bin\”
monkeyc -o ConfirmationDialog.prg.prg -m manifest.xml
connectiq
monkeydo ConfirmationDialog.prg.prg

Una vez ejecutados ya podemos ver la app, en el modo simulación

02

Y listo, ya tenemos una app compilada y ejecutada en nuestro simulador de apps para Garmin. En próximos posts veré que descubro de la estructura interna de las apps, y lo que vaya aprendiendo.

Saludos @ Toronto

-El Bruno

References

#Garmin – Next Challenge: #ConnectIQ SDK & #MonekyC

Clipboard02

Hello!

The process of installation in Toronto is taking shape. While I continue with the steps necessary to live here, I give me the luxury of jogging at – 10 ° C to learn a little.

Best of all this, is that the past February 14, Pao gave me a Garmin Forerunner 235 to replace my M400 Polar, already a bit old. After giving some kilometers to the legs, I began to know the ecosystem of Garmin, the truth is that it has left me quite stunned.

In addition to its sports capabilities based on own sensors as the Heart Rate, GPS, etc.; the smartwatch is a BLE connection constant with the smartphone. When vi BLE, began to see whether there was the possibility of doing “more” with the Garmin.

I gave a good taste, when I got to the Connect IQ SDK, which is the basis for developing apps for Garmin devices. As in all these cases, I didn’t expect to do anything, but I’ve taken me a pleasant surprise: Connect IQ SDK supports Windows, Android, and iOS.

Now my next step is to use Visual Studio 2015 as development tool, which is going to be some kind of weird. I’ve just found that the programming language is Monkey C. Which is something completely new for me. I have seen that it is a mixture between Java and C, which can give me many fun times.

As well, to see that I can get the Garmin. And even compare it with other SmartWatchs who worked with their SDKs, such as the Microsoft Band and the Pebble.

12729172_10154696739543475_7717662869701989285_n

Saludos @ Toronto

-El Bruno

References

#Garmin – Próximo desafio: #ConnectIQ SDK y #MonekyC

Clipboard02

Hola !

El proceso de instalación en Toronto va tomando forma. Mientras sigo con los trámites necesarios para vivir aquí, me puedo dar el lujo de salir a correr a -10ºC para conocer un poco.

Lo mejor de todo esto, es que el pasado 14 de Febrero, Pao me regaló un Garmin Forerunner 235 para reemplazar a mi Polar M400, que ya un poco viejo. Después de darle un poco de Kilómetros a las piernas, empecé a conocer el ecosistema de Garmin, la verdad es que me ha dejado bastante asombrado.

Además de sus capacidades deportivas que se basan en los sensores propios como el Heart Rate, GPS, etc.; el smartwatch tiene una conexión BLE constante con el smartphone. Cuando ví lo de BLE, comencé a ver si existía la posiblidad de hacer “algo más” con el Garmin.

Me dí un buen gusto, cuando llegué al Connect IQ SDK, que es la base para desarrollas apps para devices Garmin. Como en todos estos casos, no esperaba poder hacer nada, pero me he llevado una agradable sorpresa: Connect IQ SDK soporta Windows, Android e iOS.

Ahora solo me queda ver como montar los proyectos con Visual Studio 2015. Porque, no lo he comentado, el lenguaje de programación es Monkey C. Algo completamente nuevo para mi, y que he visto que es una mezcla entre Java y C, que puede darme mucha alegrías.

Pues bien, a ver que puedo sacar del Garmin. E inclusive compararlo con otros SmartWatchs con los que trabajado con sus SDKs, como la Microsoft Band y el Pebble.

12729172_10154696739543475_7717662869701989285_n

 

Saludos @ Toronto

-El Bruno

References