-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from NicholasRasi/new_data
Save data
- Loading branch information
Showing
8 changed files
with
385 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,95 @@ | ||
<!-- 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"> | ||
<iq:application entry="emtbApp" id="49fe48135c21499a8d906605009d399d" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.1.0" name="@Strings.AppName" type="datafield" version="1.0.9"> | ||
<iq:products> | ||
<iq:product id="d2air"/> | ||
<iq:product id="descentmk2"/> | ||
<iq:product id="descentmk2s"/> | ||
<iq:product id="edge1030"/> | ||
<iq:product id="edge1030plus"/> | ||
<iq:product id="edge530"/> | ||
<iq:product id="edge830"/> | ||
<iq:product id="edgeexplore"/> | ||
<iq:product id="enduro"/> | ||
<iq:product id="fenix5plus"/> | ||
<iq:product id="fenix5splus"/> | ||
<iq:product id="fenix5xplus"/> | ||
<iq:product id="fenix6"/> | ||
<iq:product id="fenix6pro"/> | ||
<iq:product id="fenix6s"/> | ||
<iq:product id="fenix6spro"/> | ||
<iq:product id="fenix6xpro"/> | ||
<iq:product id="fr245"/> | ||
<iq:product id="fr245m"/> | ||
<iq:product id="fr55"/> | ||
<iq:product id="fr645m"/> | ||
<iq:product id="fr745"/> | ||
<iq:product id="fr945"/> | ||
<iq:product id="fr945lte"/> | ||
<iq:product id="legacyherocaptainmarvel"/> | ||
<iq:product id="legacyherofirstavenger"/> | ||
<iq:product id="legacysagadarthvader"/> | ||
<iq:product id="legacysagarey"/> | ||
<iq:product id="marqadventurer"/> | ||
<iq:product id="marqathlete"/> | ||
<iq:product id="marqaviator"/> | ||
<iq:product id="marqcaptain"/> | ||
<iq:product id="marqcommander"/> | ||
<iq:product id="marqdriver"/> | ||
<iq:product id="marqexpedition"/> | ||
<iq:product id="marqgolfer"/> | ||
<iq:product id="montana7xx"/> | ||
<iq:product id="venu"/> | ||
<iq:product id="venu2"/> | ||
<iq:product id="venu2s"/> | ||
<iq:product id="venud"/> | ||
<iq:product id="venusqm"/> | ||
<iq:product id="vivoactive3m"/> | ||
<iq:product id="vivoactive3mlte"/> | ||
<iq:product id="vivoactive4"/> | ||
<iq:product id="vivoactive4s"/> | ||
</iq:products> | ||
<iq:permissions> | ||
<iq:uses-permission id="BluetoothLowEnergy"/> | ||
</iq:permissions> | ||
<iq:languages> | ||
<iq:language>ara</iq:language> | ||
<iq:language>bul</iq:language> | ||
<iq:language>ces</iq:language> | ||
<iq:language>dan</iq:language> | ||
<iq:language>deu</iq:language> | ||
<iq:language>dut</iq:language> | ||
<iq:language>eng</iq:language> | ||
<iq:language>est</iq:language> | ||
<iq:language>fin</iq:language> | ||
<iq:language>fre</iq:language> | ||
<iq:language>gre</iq:language> | ||
<iq:language>heb</iq:language> | ||
<iq:language>hrv</iq:language> | ||
<iq:language>hun</iq:language> | ||
<iq:language>ind</iq:language> | ||
<iq:language>ita</iq:language> | ||
<iq:language>jpn</iq:language> | ||
<iq:language>kor</iq:language> | ||
<iq:language>lav</iq:language> | ||
<iq:language>lit</iq:language> | ||
<iq:language>nob</iq:language> | ||
<iq:language>pol</iq:language> | ||
<iq:language>por</iq:language> | ||
<iq:language>ron</iq:language> | ||
<iq:language>rus</iq:language> | ||
<iq:language>slo</iq:language> | ||
<iq:language>slv</iq:language> | ||
<iq:language>spa</iq:language> | ||
<iq:language>swe</iq:language> | ||
<iq:language>tha</iq:language> | ||
<iq:language>tur</iq:language> | ||
<iq:language>ukr</iq:language> | ||
<iq:language>vie</iq:language> | ||
<iq:language>zhs</iq:language> | ||
<iq:language>zht</iq:language> | ||
<iq:language>zsm</iq:language> | ||
</iq:languages> | ||
<iq:barrels/> | ||
</iq:application> | ||
</iq:manifest> | ||
<!-- 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"> | ||
<iq:application entry="emtbApp" id="49fe48135c21499a8d906605009d399d" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.1.0" name="@Strings.AppName" type="datafield" version="1.0.9"> | ||
<iq:products> | ||
<iq:product id="d2air"/> | ||
<iq:product id="descentmk2"/> | ||
<iq:product id="descentmk2s"/> | ||
<iq:product id="edge1030"/> | ||
<iq:product id="edge1030plus"/> | ||
<iq:product id="edge530"/> | ||
<iq:product id="edge830"/> | ||
<iq:product id="edgeexplore"/> | ||
<iq:product id="enduro"/> | ||
<iq:product id="fenix5plus"/> | ||
<iq:product id="fenix5splus"/> | ||
<iq:product id="fenix5xplus"/> | ||
<iq:product id="fenix6"/> | ||
<iq:product id="fenix6pro"/> | ||
<iq:product id="fenix6s"/> | ||
<iq:product id="fenix6spro"/> | ||
<iq:product id="fenix6xpro"/> | ||
<iq:product id="fr245"/> | ||
<iq:product id="fr245m"/> | ||
<iq:product id="fr55"/> | ||
<iq:product id="fr645m"/> | ||
<iq:product id="fr745"/> | ||
<iq:product id="fr945"/> | ||
<iq:product id="fr945lte"/> | ||
<iq:product id="legacyherocaptainmarvel"/> | ||
<iq:product id="legacyherofirstavenger"/> | ||
<iq:product id="legacysagadarthvader"/> | ||
<iq:product id="legacysagarey"/> | ||
<iq:product id="marqadventurer"/> | ||
<iq:product id="marqathlete"/> | ||
<iq:product id="marqaviator"/> | ||
<iq:product id="marqcaptain"/> | ||
<iq:product id="marqcommander"/> | ||
<iq:product id="marqdriver"/> | ||
<iq:product id="marqexpedition"/> | ||
<iq:product id="marqgolfer"/> | ||
<iq:product id="montana7xx"/> | ||
<iq:product id="venu"/> | ||
<iq:product id="venu2"/> | ||
<iq:product id="venu2s"/> | ||
<iq:product id="venud"/> | ||
<iq:product id="venusqm"/> | ||
<iq:product id="vivoactive3m"/> | ||
<iq:product id="vivoactive3mlte"/> | ||
<iq:product id="vivoactive4"/> | ||
<iq:product id="vivoactive4s"/> | ||
</iq:products> | ||
<iq:permissions> | ||
<iq:uses-permission id="BluetoothLowEnergy"/> | ||
<iq:uses-permission id="FitContributor"/> | ||
</iq:permissions> | ||
<iq:languages> | ||
<iq:language>ara</iq:language> | ||
<iq:language>bul</iq:language> | ||
<iq:language>ces</iq:language> | ||
<iq:language>dan</iq:language> | ||
<iq:language>deu</iq:language> | ||
<iq:language>dut</iq:language> | ||
<iq:language>eng</iq:language> | ||
<iq:language>est</iq:language> | ||
<iq:language>fin</iq:language> | ||
<iq:language>fre</iq:language> | ||
<iq:language>gre</iq:language> | ||
<iq:language>heb</iq:language> | ||
<iq:language>hrv</iq:language> | ||
<iq:language>hun</iq:language> | ||
<iq:language>ind</iq:language> | ||
<iq:language>ita</iq:language> | ||
<iq:language>jpn</iq:language> | ||
<iq:language>kor</iq:language> | ||
<iq:language>lav</iq:language> | ||
<iq:language>lit</iq:language> | ||
<iq:language>nob</iq:language> | ||
<iq:language>pol</iq:language> | ||
<iq:language>por</iq:language> | ||
<iq:language>ron</iq:language> | ||
<iq:language>rus</iq:language> | ||
<iq:language>slo</iq:language> | ||
<iq:language>slv</iq:language> | ||
<iq:language>spa</iq:language> | ||
<iq:language>swe</iq:language> | ||
<iq:language>tha</iq:language> | ||
<iq:language>tur</iq:language> | ||
<iq:language>ukr</iq:language> | ||
<iq:language>vie</iq:language> | ||
<iq:language>zhs</iq:language> | ||
<iq:language>zht</iq:language> | ||
<iq:language>zsm</iq:language> | ||
</iq:languages> | ||
<iq:barrels/> | ||
</iq:application> | ||
</iq:manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<fitContributions> | ||
<!-- GRAPH : Battery --> | ||
<fitField id="0" | ||
displayInChart="true" | ||
sortOrder="0" | ||
precision="2" | ||
chartTitle="@Strings.BatteryField" | ||
dataLabel="@Strings.BatteryField" | ||
unitLabel="@Strings.BatteryUnitField" | ||
fillColor="#0099FF" /> | ||
<!-- GRAPH : Cadence --> | ||
<fitField id="1" | ||
displayInChart="true" | ||
sortOrder="1" | ||
precision="2" | ||
chartTitle="@Strings.CadenceField" | ||
dataLabel="@Strings.CadenceField" | ||
unitLabel="@Strings.CadenceUnitField" | ||
fillColor="#0099FF" /> | ||
<!-- GRAPH : Assistance Level --> | ||
<fitField id="2" | ||
displayInChart="true" | ||
sortOrder="2" | ||
precision="2" | ||
chartTitle="@Strings.AssistanceLevelField" | ||
dataLabel="@Strings.AssistanceLevelField" | ||
unitLabel="@Strings.AssistanceLevelUnitField" | ||
fillColor="#0099FF" /> | ||
<!-- SUMMARY : Consumed Battery --> | ||
<fitField id="3" | ||
displayInActivitySummary="true" | ||
sortOrder="3" | ||
precision="2" | ||
dataLabel="@Strings.ConsumedBatteryField" | ||
unitLabel="@Strings.BatteryUnitField" /> | ||
</fitContributions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using Toybox.FitContributor as Fit; | ||
using Toybox.Lang; | ||
using Toybox.WatchUi; | ||
|
||
|
||
class emtbFitContributor { | ||
|
||
// Field ids | ||
private const FIELD_BATTERY = 0; | ||
private const FIELD_CADENCE = 1; | ||
private const FIELD_ASSISTANCE_LEVEL = 2; | ||
private const FIELD_CONSUMED_BATTERY = 3; | ||
|
||
private var _timerRunning as Boolean = false; | ||
private var _firstBatteryValue = -1; | ||
|
||
// FIT Contributions variables | ||
private var _batteryField; | ||
private var _cadenceField; | ||
private var _assistanceLevelField; | ||
private var _consumedBatteryField; | ||
|
||
//! Constructor | ||
//! @param dataField Data field to use to create fields | ||
public function initialize(emtbField as emtbView) { | ||
System.println(emtbField.toString()); | ||
|
||
// Create the custom FIT data field we want to record | ||
_batteryField = emtbField.createField( | ||
WatchUi.loadResource(Rez.Strings.BatteryField), | ||
FIELD_BATTERY, | ||
Fit.DATA_TYPE_UINT8, | ||
{:mesgType=>Fit.MESG_TYPE_RECORD, :units=>WatchUi.loadResource(Rez.Strings.BatteryUnitField)} | ||
); | ||
|
||
_cadenceField = emtbField.createField( | ||
WatchUi.loadResource(Rez.Strings.CadenceField), | ||
FIELD_CADENCE, | ||
Fit.DATA_TYPE_UINT8, | ||
{:mesgType=>Fit.MESG_TYPE_RECORD, :units=>WatchUi.loadResource(Rez.Strings.CadenceUnitField)} | ||
); | ||
|
||
_assistanceLevelField = emtbField.createField( | ||
WatchUi.loadResource(Rez.Strings.AssistanceLevelField), | ||
FIELD_ASSISTANCE_LEVEL, | ||
Fit.DATA_TYPE_UINT8, | ||
{:mesgType=>Fit.MESG_TYPE_RECORD, :units=>WatchUi.loadResource(Rez.Strings.AssistanceLevelUnitField)} | ||
); | ||
|
||
_consumedBatteryField = emtbField.createField( | ||
WatchUi.loadResource(Rez.Strings.ConsumedBatteryField), | ||
FIELD_CONSUMED_BATTERY, | ||
Fit.DATA_TYPE_UINT8, | ||
{:mesgType=>Fit.MESG_TYPE_SESSION, :units=>WatchUi.loadResource(Rez.Strings.BatteryUnitField)} | ||
); | ||
|
||
|
||
_batteryField.setData(0); | ||
_cadenceField.setData(0); | ||
_assistanceLevelField.setData(0); | ||
_consumedBatteryField.setData(0); | ||
} | ||
|
||
//! Update data and fields | ||
//! @param battery level, cadence and assistance value | ||
public function update(battery, cadence, assistanceLevel) as Void { | ||
System.println("Updating fit..."); | ||
|
||
if (_timerRunning) { | ||
// Update fields | ||
_batteryField.setData(battery); | ||
_cadenceField.setData(cadence); | ||
_assistanceLevelField.setData(assistanceLevel); | ||
|
||
if (_firstBatteryValue == -1 && battery > 0) | ||
{ | ||
_firstBatteryValue = battery; | ||
} | ||
|
||
_consumedBatteryField.setData(_firstBatteryValue - battery); | ||
} | ||
} | ||
|
||
//! Set whether the timer is running | ||
//! @param state Whether the timer is running | ||
public function setTimerRunning(state as Boolean) as Void { | ||
_timerRunning = state; | ||
} | ||
} |
Oops, something went wrong.