Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions resources/properties.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<properties>
<property id="excludeExternalHR" type="boolean">false</property>
</properties>
5 changes: 5 additions & 0 deletions resources/settings/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<settings>
<setting propertyKey="@Properties.excludeExternalHR" title="@Strings.excludeExternalHRTitle">
<settingConfig type="boolean" />
</setting>
</settings>
4 changes: 4 additions & 0 deletions resources/strings/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@

<string id="menu_label_1">Item 1</string>
<string id="menu_label_2">Item 2</string>

<string id="settingsTitle">Settings</string>
<string id="excludeExternalHRTitle">Exclude External HR</string>
<string id="excludeExternalHRDescription">Disable external heart rate sensor (SENSOR_HEARTRATE) and use only onboard sensor for SDK 3.2+</string>
</strings>
12 changes: 10 additions & 2 deletions source/QZCompanionGarminView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,28 @@ class QZCompanionGarminView extends WatchUi.View {
function initialize() {
View.initialize();
var deviceSettings = System.getDeviceSettings().monkeyVersion;
var excludeExternalHR = Application.Properties.getValue("excludeExternalHR");

// Now you can use apiLevel as needed
System.println("API Level: " + deviceSettings);
System.println("Exclude External HR: " + excludeExternalHR);

if((deviceSettings[0] == 3 && deviceSettings[1] >= 2) || deviceSettings[0] > 3) {
Sensor.setEnabledSensors( [Sensor.SENSOR_ONBOARD_HEARTRATE, Sensor.SENSOR_HEARTRATE, Sensor.SENSOR_FOOTPOD, Sensor.SENSOR_BIKEPOWER, Sensor.SENSOR_BIKECADENCE, Sensor.SENSOR_BIKESPEED] );
if(excludeExternalHR) {
// Exclude external HR sensor (SENSOR_HEARTRATE), use only onboard
Sensor.setEnabledSensors( [Sensor.SENSOR_ONBOARD_HEARTRATE, Sensor.SENSOR_FOOTPOD, Sensor.SENSOR_BIKEPOWER, Sensor.SENSOR_BIKECADENCE, Sensor.SENSOR_BIKESPEED] );
} else {
// Include both onboard and external HR sensors
Sensor.setEnabledSensors( [Sensor.SENSOR_ONBOARD_HEARTRATE, Sensor.SENSOR_HEARTRATE, Sensor.SENSOR_FOOTPOD, Sensor.SENSOR_BIKEPOWER, Sensor.SENSOR_BIKECADENCE, Sensor.SENSOR_BIKESPEED] );
}
} else {
Sensor.setEnabledSensors( [Sensor.SENSOR_HEARTRATE, Sensor.SENSOR_FOOTPOD, Sensor.SENSOR_BIKEPOWER, Sensor.SENSOR_BIKECADENCE, Sensor.SENSOR_BIKESPEED] );
}
Sensor.enableSensorEvents(method(:onSnsr));

timer = new Timer.Timer();
timer.start(method(:tick), 1000, true);
Communications.registerForPhoneAppMessages(method(:phoneMessageCallback));
Communications.registerForPhoneAppMessages(method(:phoneMessageCallback));
}

// Load your resources here
Expand Down