Skip to content

Commit

Permalink
Started refactoring of track navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
andan67 committed Dec 29, 2021
1 parent b46c74b commit 67536a7
Show file tree
Hide file tree
Showing 12 changed files with 545 additions and 532 deletions.
23 changes: 12 additions & 11 deletions connectiq/source/Data.mc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using Toybox.Sensor;
using Toybox.UserProfile;
using Toybox.WatchUi;
using Toybox.Application;
using Track;

module Data {
const dataFieldMenuLabels = Application.getApp().split(WatchUi.loadResource(Rez.Strings.dm_labels),'|');
Expand Down Expand Up @@ -106,29 +107,29 @@ module Data {
dataValue = Activity.getActivityInfo().averageHeartRate;
break;
case 9: // LAP_TIMER
dataValue = Trace.autolapDistance > 0 ? Data.msToTime(Trace.lapTime.toLong(), false) : null;
dataValue = Track.autolapDistance > 0 ? Data.msToTime(Track.lapTime.toLong(), false) : null;
break;
case 10: // LAP_DISTANCE
dataValue = Trace.autolapDistance > 0 ? (0.001*Data.Trace.lapDistance).format("%.2f") : null;
dataValue = Track.autolapDistance > 0 ? (0.001*Data.Track.lapDistance).format("%.2f") : null;
break;
case 11: // LAP_PACE
dataValue = (Trace.autolapDistance > 0 && Trace.lapTime > 0) ?
Data.convertSpeedToPace(1000*Trace.lapDistance/Trace.lapTime) : null;
dataValue = (Track.autolapDistance > 0 && Track.lapTime > 0) ?
Data.convertSpeedToPace(1000*Track.lapDistance/Track.lapTime) : null;
break;
case 12: // LAP_SPEED
dataValue = (Trace.autolapDistance > 0 && Trace.lapTime > 0) ?
(3600*Trace.lapDistance/Trace.lapTime).format("%.2f") : null;
dataValue = (Track.autolapDistance > 0 && Track.lapTime > 0) ?
(3600*Track.lapDistance/Track.lapTime).format("%.2f") : null;
break;
case 13: // LAST_LAP_PACE
dataValue = (Trace.autolapDistance > 0 && Trace.lapTimeP > 0) ?
Data.convertSpeedToPace(1000*Trace.lapDistanceP/Trace.lapTimeP) : null;
dataValue = (Track.autolapDistance > 0 && Track.lapTimeP > 0) ?
Data.convertSpeedToPace(1000*Track.lapDistanceP/Track.lapTimeP) : null;
break;
case 14: // LAST_LAP_SPEED
dataValue = (Trace.autolapDistance > 0 && Trace.lapTime > 0) ?
(3600*Trace.lapDistance/Trace.lapTime).format("%.2f") : null;
dataValue = (Track.autolapDistance > 0 && Track.lapTime > 0) ?
(3600*Track.lapDistance/Track.lapTime).format("%.2f") : null;
break;
case 15: // LAP
dataValue = Trace.autolapDistance > 0 ? Trace.lapCounter : null;
dataValue = Track.autolapDistance > 0 ? Track.lapCounter : null;
break;
case 16: // ALTITUDE
data = Activity.getActivityInfo().altitude;
Expand Down
6 changes: 3 additions & 3 deletions connectiq/source/DataView.mc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Toybox.WatchUi;
using Toybox.Activity;
using Data;
using Trace;
using Track;


class DataView extends GenericView {
Expand Down Expand Up @@ -166,7 +166,7 @@ class LapView extends WatchUi.View {
dc.setColor(Graphics.COLOR_DK_GRAY, Graphics.COLOR_BLACK);
dc.clear();
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
dc.drawText(dc.getWidth()/2, dc.getFontHeight(Graphics.FONT_LARGE), Graphics.FONT_LARGE, "Lap " + Trace.lapCounter, Graphics.TEXT_JUSTIFY_CENTER);
dc.drawText(dc.getWidth()/2, dc.getHeight()/2 - dc.getFontHeight(Graphics.FONT_NUMBER_MEDIUM)/2, Graphics.FONT_NUMBER_HOT, Data.msToTime(Trace.lapTime.toLong(), true), Graphics.TEXT_JUSTIFY_CENTER);
dc.drawText(dc.getWidth()/2, dc.getFontHeight(Graphics.FONT_LARGE), Graphics.FONT_LARGE, "Lap " + Track.lapCounter, Graphics.TEXT_JUSTIFY_CENTER);
dc.drawText(dc.getWidth()/2, dc.getHeight()/2 - dc.getFontHeight(Graphics.FONT_NUMBER_MEDIUM)/2, Graphics.FONT_NUMBER_HOT, Data.msToTime(Track.lapTime.toLong(), true), Graphics.TEXT_JUSTIFY_CENTER);
}
}
20 changes: 13 additions & 7 deletions connectiq/source/GenericView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,24 @@ class GenericView extends WatchUi.View {
}

function drawStartStop(dc) {
if($.sessionEvent == 1) {
// display activity started symbol

var pixelwidth2 = 0.5 * dc.getWidth();
var pixelHeight2 = 0.5 * dc.getHeight();
var pixelMin = dc.getWidth() < dc.getHeight() ? dc.getHeight() : dc.getHeight();


if($.sessionEvent == 1) {
// display activity started symbol
dc.setColor(Graphics.COLOR_DK_GREEN, Graphics.COLOR_TRANSPARENT);
dc.fillPolygon([
[Transform.pixelWidth2 - 0.12*Transform.pixelMin,Transform.pixelHeight2 - 0.21*Transform.pixelMin ],
[Transform.pixelWidth2 - 0.12*Transform.pixelMin,Transform.pixelHeight2 + 0.21*Transform.pixelMin ],
[Transform.pixelWidth2 + 0.24*Transform.pixelMin,Transform.pixelHeight2 ]]);
[pixelWidth2 - 0.12 * pixelMin, pixelHeight2 - 0.21 * pixelMin ],
[pixelWidth2 - 0.12 * pixelMin, pixelHeight2 + 0.21 * pixelMin ],
[pixelWidth2 + 0.24 * pixelMin, pixelHeight2 ]]);
} else if($.sessionEvent == 2) {
// display activity stopped symbol
dc.setColor(Graphics.COLOR_DK_RED, Graphics.COLOR_TRANSPARENT);
dc.fillRectangle(Transform.pixelWidth2 - 0.21*Transform.pixelMin,
Transform.pixelHeight2 - 0.21*Transform.pixelMin, 0.42*Transform.pixelMin, 0.42*Transform.pixelMin);
dc.fillRectangle(pixelWidth2 - 0.21 * pixelMin,
pixelHeight2 - 0.21 * pixelMin, 0.42 * pixelMin, 0.42 * pixelMin);
}
}

Expand Down
1 change: 0 additions & 1 deletion connectiq/source/ListMenu.mc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ using Toybox.WatchUi as Ui;
using Toybox.System as Sys;
using Toybox.Graphics as Gfx;

using Trace;
using MenuDelegates;


Expand Down
40 changes: 18 additions & 22 deletions connectiq/source/MenuDelegates.mc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Toybox.Lang;
using Toybox.ActivityRecording;
using Toybox.Application;

using Trace;
using Track;

module MenuDelegates {

Expand All @@ -18,17 +18,17 @@ module MenuDelegates {
case :autolap:
return [["off","100m","200m","400m","500m","1km","2km","5km"],
[0.0,100.0,200.0,400.0,500.0,1000.0,2000.0,5000.0],
Trace.autolapDistance];
Track.autolapDistance];
case :bc_number:
return [null, [1,2,5,10,20,50,100], Trace.breadCrumbNumber];
return [null, [1,2,5,10,20,50,100], Track.breadCrumbNumber];
case :bc_distance:
return [["off","50m","100m","200m","500m","1km","2km","5km","10km","20km"],
[0.0,50.0,100.0,200.0,500.0,1000.0,2000.0,5000.0,10000.0,20000.0],
Trace.breadCrumbDist];
Track.breadCrumbDist];
case :orient:
return [WatchUi.loadResource(Rez.Strings.orient_opts),
null,
Transform.getOrientation()];
Track.getOrientation()];
case :activity:
return [WatchUi.loadResource(Rez.Strings.activities),
[ActivityRecording.SPORT_GENERIC, ActivityRecording.SPORT_RUNNING,
Expand Down Expand Up @@ -177,14 +177,14 @@ module MenuDelegates {
switch(menu.id) {
case :orient:
if(value == 0) {
Transform.northHeading = false;
Transform.centerMap = false;
Track.northHeading = false;
Track.centerMap = false;
} else {
Transform.northHeading = true;
Transform.centerMap = (value == 2);
Track.northHeading = true;
Track.centerMap = (value == 2);
}
Application.getApp().setProperty("northHeading", Transform.northHeading);
Application.getApp().setProperty("centerMap", Transform.centerMap);
Application.getApp().setProperty("northHeading", Track.northHeading);
Application.getApp().setProperty("centerMap", Track.centerMap);
break;
case :background:
$.isDarkMode = value;
Expand All @@ -197,16 +197,16 @@ module MenuDelegates {
}
break;
case :autolap:
Trace.setAutolapDistance(value);
Track.setAutolapDistance(value);
Application.getApp().setProperty("autolapDistance",value);
break;
case :breadcrumbs:
switch(menu.getSelectedId()) {
case :bc_set:
Trace.putBreadcrumbLastPosition();
Track.putBreadcrumbLastPosition();
break;
case :bc_clear:
Trace.reset();
Track.reset();
break;
case :bc_number:
case :bc_distance:
Expand All @@ -218,12 +218,12 @@ module MenuDelegates {
}
break;
case :bc_distance:
Trace.breadCrumbDist = value;
Application.getApp().setProperty("breadCrumbDist", Trace.breadCrumbDist);
Track.breadCrumbDist = value;
Application.getApp().setProperty("breadCrumbDist", Track.breadCrumbDist);
break;
case :bc_number:
Trace.setBreadCrumbNumber(value);
Application.getApp().setProperty("breadCrumbNumber", Trace.breadCrumbNumber);
Track.setBreadCrumbNumber(value);
Application.getApp().setProperty("breadCrumbNumber", Track.breadCrumbNumber);
break;
case :activity:
$.activityType = value;
Expand Down Expand Up @@ -312,10 +312,6 @@ module MenuDelegates {
} else {
System.println("Delete track");
$.track=$.track.clean();
if(Trace.lat_last_pos != null) {
Transform.setViewCenter(Trace.lat_last_pos,Trace.lon_last_pos);
}
//Trace.reset();
}
}
}
Expand Down
146 changes: 0 additions & 146 deletions connectiq/source/Trace.mc

This file was deleted.

Loading

0 comments on commit 67536a7

Please sign in to comment.