Skip to content

Commit 63102ad

Browse files
authored
Merge pull request #63 from google/garmin_datafield
Add Garmin app to display a datafield
2 parents 5c698ff + 55b111a commit 63102ad

File tree

10 files changed

+487
-0
lines changed

10 files changed

+487
-0
lines changed

garmin/PlusCodeDatafield/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>PlusCodeDatafield</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>connectiq.builder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>connectiq.projectNature</nature>
16+
</natures>
17+
</projectDescription>

garmin/PlusCodeDatafield/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Plus code datafield for Garmin Connect IQ devices.
2+
3+
[<img src="https://developer.garmin.com/img/connect-iq/brand/available-badge.svg" alt="Drawing" width=200 style="width: 200px;"/>](https://apps.garmin.com/en-US/apps/74d90879-fbac-48e7-8405-28af2a0a55a7#0)
4+
5+
6+
Plus codes are short codes you can use to refer to a place, that are easier
7+
to use than latitude and longitude. They were designed to provide an
8+
address-like solution for the areas of the world where street addresses do not
9+
exist or are not widely known. Plus codes are free and the software is open
10+
source. See the [demo site](https://plus.codes) or the
11+
[Github project](https://github.com/google/open-location-code).
12+
13+
This datafield displays the plus code for your current location. It doesn't
14+
use any network because plus codes can be computed offline.
15+
16+
Codes are displayed with the first four digits (the area code) small, and the
17+
remaining digits larger (this is the local code).
18+
19+
For example, it might display:
20+
21+
| 8FVC |
22+
| ------- |
23+
| **8FXR+QH** |
24+
25+
To tell someone within 30-50 km (20-30 miles), you can just tell them 8FXR+QH.
26+
If they are further away, you can tell them the whole code, or you can give
27+
them the second part and a nearby town or city. (For example, 8FXR+QH Zurich.)
28+
29+
They can enter the code into Google Maps, or into
30+
[plus.codes](https://plus.codes).
31+
32+
The code will fade if the location accuracy is poor or the GPS signal is lost.
33+
34+
The code precision is approximately 14 by 14 meters.
35+
36+
A built version of the datafield is available on the Garmin Connect IQ
37+
[app store](https://apps.garmin.com/en-US/apps/74d90879-fbac-48e7-8405-28af2a0a55a7#0),
38+
or you can build your own version.
39+
40+
## Build and Installation
41+
42+
If you're using the
43+
[normal](https://developer.garmin.com/connect-iq/programmers-guide/getting-started/)
44+
Garmin development process, just open this directory in Eclipse.
45+
46+
If running on Linux, see below for instructions on getting your machine
47+
set up and the Garmin Connect IQ tools installed. Once done, you should be
48+
able to compile the app with:
49+
50+
```shell
51+
monkeyc -w -y developer_key.der -m manifest.xml -z resources/strings.xml -z resources/drawables.xml -z resources/layouts.xml -o bin/PlusCodeDatafield.prg source/*
52+
```
53+
54+
That will create a file called `PlusCodeDatafield.prg` in the `bin` directory.
55+
Copy that file to the `Garmin/Apps` directory on your device. Restart it, and
56+
you should be able to add it to your data screens!
57+
58+
## Supported Devices
59+
60+
All languages are supported.
61+
62+
The following devices are supported:
63+
64+
* D2 Bravo
65+
* Edge 520, 820, 1000 (including Explore)
66+
* fēnix Chronos, fēnix3, fēnix5
67+
* tactix Bravo
68+
* quatix 3
69+
* Forerunner 230/235/630/735xt/920xt
70+
* Vivoactive, Vivoactive HR
71+
* Epix
72+
* Oregon 700/750/750t
73+
* Rino 750/750t
74+
75+
## Logging issues
76+
77+
Create an issue on the project site by
78+
[clicking here](https://github.com/google/open-location-code/issues/new?title=Issue%20with%20Garmin%20datafield&body=Provide%20your%20device%20model%20and%20what%20the%20problem%20is.%20Including%20screenshots%20would%20really%20help.&labels=garmin).
79+
80+
## Using Connect IQ on Linux
81+
82+
See [this overview](http://blog.aaronboman.com/programming/connectiq/2014/11/13/the-garmin-connect-iq-sdk-on-ubuntu-linux/)
83+
for general information.
84+
85+
There seem to have been some changes to the `monkeyc` command since that blog
86+
article was published:
87+
88+
* You must include your [developer key](https://developer.garmin.com/connect-iq/programmers-guide/getting-started/#generatingadeveloperkeyciq1.3) with the `-y` option
89+
* You must include the source files on the command line

garmin/PlusCodeDatafield/manifest.xml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. --><iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3">
2+
<iq:application entry="PlusCodeDatafield" id="81C7E83C447948789C2B1F6BCA03787F" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="1.2.0" name="@Strings.AppName" type="datafield">
3+
4+
<iq:products>
5+
<iq:product id="fenix5"/>
6+
<iq:product id="fenix5x"/>
7+
<iq:product id="fenix5s"/>
8+
<iq:product id="fr630"/>
9+
<iq:product id="fr235"/>
10+
<iq:product id="fr735xt"/>
11+
<iq:product id="vivoactive"/>
12+
<iq:product id="fenix3"/>
13+
<iq:product id="fenix3_hr"/>
14+
<iq:product id="fenixchronos"/>
15+
<iq:product id="d2bravo"/>
16+
<iq:product id="d2bravo_titanium"/>
17+
<iq:product id="fr920xt"/>
18+
<iq:product id="epix"/>
19+
<iq:product id="edge_1000"/>
20+
<iq:product id="edge_520"/>
21+
<iq:product id="vivoactive_hr"/>
22+
<iq:product id="edge820"/>
23+
<iq:product id="oregon7xx"/>
24+
<iq:product id="rino7xx"/>
25+
</iq:products>
26+
27+
<iq:permissions>
28+
</iq:permissions>
29+
30+
<iq:languages>
31+
<iq:language>ara</iq:language>
32+
<iq:language>bul</iq:language>
33+
<iq:language>ces</iq:language>
34+
<iq:language>dan</iq:language>
35+
<iq:language>deu</iq:language>
36+
<iq:language>dut</iq:language>
37+
<iq:language>eng</iq:language>
38+
<iq:language>fin</iq:language>
39+
<iq:language>fre</iq:language>
40+
<iq:language>gre</iq:language>
41+
<iq:language>heb</iq:language>
42+
<iq:language>hrv</iq:language>
43+
<iq:language>hun</iq:language>
44+
<iq:language>ind</iq:language>
45+
<iq:language>ita</iq:language>
46+
<iq:language>jpn</iq:language>
47+
<iq:language>kor</iq:language>
48+
<iq:language>nob</iq:language>
49+
<iq:language>pol</iq:language>
50+
<iq:language>por</iq:language>
51+
<iq:language>rus</iq:language>
52+
<iq:language>slo</iq:language>
53+
<iq:language>slv</iq:language>
54+
<iq:language>spa</iq:language>
55+
<iq:language>swe</iq:language>
56+
<iq:language>tha</iq:language>
57+
<iq:language>tur</iq:language>
58+
<iq:language>zhs</iq:language>
59+
<iq:language>zht</iq:language>
60+
<iq:language>zsm</iq:language>
61+
</iq:languages>
62+
63+
</iq:application>
64+
</iq:manifest>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<drawables>
2+
<bitmap id="LauncherIcon" filename="launcher_icon.png" />
3+
</drawables>
Loading
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<layouts>
2+
<!-- A generic, centered layout with a large font size. -->
3+
<layout id="MainLayout">
4+
<drawable class="PlusCodeBackground" />
5+
<label id="areacode" x="0" y="0" color="Gfx.COLOR_BLACK" justification="Gfx.TEXT_JUSTIFY_CENTER" font="Gfx.FONT_TINY" />
6+
<label id="localcode" x="0" y="0" color="Gfx.COLOR_BLACK" justification="Gfx.TEXT_JUSTIFY_CENTER" font="Gfx.FONT_LARGE" />
7+
</layout>
8+
9+
<!-- Layouts used for the for the four quadrants, e.g. on watches. -->
10+
<layout id="TopLeftLayout">
11+
<drawable class="PlusCodeBackground" />
12+
<label id="areacode" x="99" y="58" color="Gfx.COLOR_BLACK" justification="Gfx.TEXT_JUSTIFY_RIGHT" font="Gfx.FONT_TINY" />
13+
<label id="localcode" x="99" y="75" color="Gfx.COLOR_BLACK" justification="Gfx.TEXT_JUSTIFY_RIGHT" font="Gfx.FONT_SMALL" />
14+
</layout>
15+
<layout id="TopRightLayout">
16+
<drawable class="PlusCodeBackground" />
17+
<label id="areacode" x="8" y="58" color="Gfx.COLOR_BLACK" justification="Gfx.TEXT_JUSTIFY_LEFT" font="Gfx.FONT_TINY" />
18+
<label id="localcode" x="8" y="75" color="Gfx.COLOR_BLACK" justification="Gfx.TEXT_JUSTIFY_LEFT" font="Gfx.FONT_SMALL" />
19+
</layout>
20+
<layout id="BottomLeftLayout">
21+
<drawable class="PlusCodeBackground" />
22+
<label id="areacode" x="99" y="5" color="Gfx.COLOR_BLACK" justification="Gfx.TEXT_JUSTIFY_RIGHT" font="Gfx.FONT_TINY" />
23+
<label id="localcode" x="99" y="22" color="Gfx.COLOR_BLACK" justification="Gfx.TEXT_JUSTIFY_RIGHT" font="Gfx.FONT_SMALL" />
24+
</layout>
25+
<layout id="BottomRightLayout">
26+
<drawable class="PlusCodeBackground" />
27+
<label id="areacode" x="8" y="5" color="Gfx.COLOR_BLACK" justification="Gfx.TEXT_JUSTIFY_LEFT" font="Gfx.FONT_TINY" />
28+
<label id="localcode" x="8" y="22" color="Gfx.COLOR_BLACK" justification="Gfx.TEXT_JUSTIFY_LEFT" font="Gfx.FONT_SMALL" />
29+
</layout>
30+
</layouts>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<strings>
2+
<string id="AppName">Plus codes</string>
3+
<string id="default_label">plus.codes</string>
4+
<string id="default_value">---</string>
5+
</strings>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2017 Google Inc. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the 'License');
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an 'AS IS' BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using Toybox.WatchUi as Ui;
16+
using Toybox.Application as App;
17+
using Toybox.Graphics as Gfx;
18+
19+
/**
20+
* Provides a Drawable object for the background of the datafield.
21+
* It's used in the layout.
22+
*/
23+
class PlusCodeBackground extends Ui.Drawable {
24+
25+
hidden var mColor;
26+
27+
function initialize() {
28+
var dictionary = {
29+
:identifier => "Background"
30+
};
31+
32+
Drawable.initialize(dictionary);
33+
}
34+
35+
function setColor(color) {
36+
mColor = color;
37+
}
38+
39+
function draw(dc) {
40+
dc.setColor(Gfx.COLOR_TRANSPARENT, mColor);
41+
dc.clear();
42+
}
43+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2017 Google Inc. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the 'License');
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an 'AS IS' BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using Toybox.Application as App;
16+
17+
/**
18+
* Main class to draw the datafield.
19+
* Initialises and returns the app.
20+
*/
21+
class PlusCodeDatafield extends App.AppBase {
22+
23+
function initialize() {
24+
AppBase.initialize();
25+
}
26+
27+
// onStart() is called on application start up
28+
function onStart(state) {
29+
}
30+
31+
// onStop() is called when your application is exiting
32+
function onStop(state) {
33+
}
34+
35+
// Return the initial view of your application here
36+
function getInitialView() {
37+
return [ new PlusCodeView() ];
38+
}
39+
}

0 commit comments

Comments
 (0)