Skip to content

Commit

Permalink
Merge pull request #4 from NicholasRasi/new_data
Browse files Browse the repository at this point in the history
Save data
  • Loading branch information
markdotai authored Jul 21, 2022
2 parents fac5bbb + 70e8f85 commit 4667c43
Show file tree
Hide file tree
Showing 8 changed files with 385 additions and 167 deletions.
189 changes: 95 additions & 94 deletions manifest.xml
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>
36 changes: 36 additions & 0 deletions resources/fit.xml
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>
3 changes: 2 additions & 1 deletion resources/settings/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<property id="LastMAC" type="string"></property> <!-- last MAC address -->
<property id="LastLock" type="boolean">false</property> <!-- lock to last -->
<property id="Item1" type="number">1</property> <!-- default show battery available -->
<property id="Layout" type="number">0</property> <!-- default horizontal layout -->
<property id="Item1" type="number">1</property> <!-- default show battery available -->
<property id="Item2" type="number">0</property> <!-- default off -->
<property id="Item3" type="number">0</property> <!-- default off -->
<property id="Item4" type="number">0</property> <!-- default off -->
Expand Down
8 changes: 8 additions & 0 deletions resources/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
<settingConfig type="boolean" />
</setting>

<setting propertyKey="@Properties.Layout" title="@Strings.LayoutTitle">
<settingConfig type="list">
<listEntry value="0">@Strings.HorizontalLayout</listEntry>
<listEntry value="1">@Strings.VerticalLayout</listEntry>
<listEntry value="2">@Strings.DiamondLayout</listEntry>
</settingConfig>
</setting>

<setting propertyKey="@Properties.Item1" title="@Strings.Item1Title">
<settingConfig type="list">
<listEntry value="0">@Strings.ShowOff</listEntry>
Expand Down
15 changes: 15 additions & 0 deletions resources/strings/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<string id="LastMACTitle">Last EMTB MAC Address</string>
<string id="LastLockTitle">Lock to MAC Address</string>
<string id="LayoutTitle">Layout</string>
<string id="Item1Title">Item 1</string>
<string id="Item2Title">Item 2</string>
<string id="Item3Title">Item 3</string>
Expand Down Expand Up @@ -30,4 +31,18 @@
<string id="LabelCadence">CADEN</string>
<string id="LabelAssistanceLevel">ASS-L</string>
<string id="LabelSpeed">SPEED</string>

<!-- Fit Contribution Fields -->
<string id="BatteryField">Battery</string>
<string id="ConsumedBatteryField">Consumed Battery</string>
<string id="BatteryUnitField">%</string>
<string id="CadenceField">Cadence</string>
<string id="CadenceUnitField">RPM</string>
<string id="AssistanceLevelField">Assistance Level</string>
<string id="AssistanceLevelUnitField">-</string><!-- // assistance level unit? -->

<!-- Layout -->
<string id="HorizontalLayout">Horizontal</string>
<string id="VerticalLayout">Vertical</string>
<string id="DiamondLayout">Diamond</string>
</strings>
8 changes: 5 additions & 3 deletions source/emtbDelegateMookup.mc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ class emtbDelegateMookup
function startConnecting()
{
mainView.values[1] = -1;
mainView.values[3] = -1;
mainView.values[6] = -1;

mainView.values[3] = -1;
mainView.values[6] = -1;
mainView.values[7] = -1;
mainView.values[8] = -1;
mainView.values[9] = -1;
state = State_Connecting;

connectedMACArray = null;
Expand Down
89 changes: 89 additions & 0 deletions source/emtbFitContributor.mc
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;
}
}
Loading

0 comments on commit 4667c43

Please sign in to comment.