mirror of
https://github.com/dyuri/garmin-repafield.git
synced 2025-12-18 04:04:02 +00:00
#4 next nav point on track
This commit is contained in:
parent
61eb7e9a86
commit
8069e80ce1
@ -1,20 +0,0 @@
|
|||||||
import Toybox.Application;
|
|
||||||
import Toybox.Graphics;
|
|
||||||
import Toybox.WatchUi;
|
|
||||||
|
|
||||||
// TODO: stamina not supported yet in the API
|
|
||||||
|
|
||||||
class Stamina extends WatchUi.Drawable {
|
|
||||||
|
|
||||||
function initialize() {
|
|
||||||
var dictionary = {
|
|
||||||
:identifier => "Stamina"
|
|
||||||
};
|
|
||||||
|
|
||||||
Drawable.initialize(dictionary);
|
|
||||||
}
|
|
||||||
|
|
||||||
function draw(dc as Dc) as Void {
|
|
||||||
dc.setColor(0xFF8800, Graphics.COLOR_TRANSPARENT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -6,6 +6,7 @@ import Toybox.Lang;
|
|||||||
class Track extends WatchUi.Drawable {
|
class Track extends WatchUi.Drawable {
|
||||||
|
|
||||||
hidden var _toDestination as Float;
|
hidden var _toDestination as Float;
|
||||||
|
hidden var _toNextPoint as Float;
|
||||||
hidden var _distance as Float;
|
hidden var _distance as Float;
|
||||||
hidden var _offCourse as Float;
|
hidden var _offCourse as Float;
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ class Track extends WatchUi.Drawable {
|
|||||||
Drawable.initialize(dictionary);
|
Drawable.initialize(dictionary);
|
||||||
|
|
||||||
_toDestination = 0.0f;
|
_toDestination = 0.0f;
|
||||||
|
_toNextPoint = 0.0f;
|
||||||
_distance = 0.0f;
|
_distance = 0.0f;
|
||||||
_offCourse = 0.0f;
|
_offCourse = 0.0f;
|
||||||
}
|
}
|
||||||
@ -25,6 +27,10 @@ class Track extends WatchUi.Drawable {
|
|||||||
_toDestination = tdst;
|
_toDestination = tdst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setToNextPoint(tnp as Float) as Void {
|
||||||
|
_toNextPoint = tnp;
|
||||||
|
}
|
||||||
|
|
||||||
function setDistance(dst as Float) as Void {
|
function setDistance(dst as Float) as Void {
|
||||||
_distance = dst;
|
_distance = dst;
|
||||||
}
|
}
|
||||||
@ -33,6 +39,13 @@ class Track extends WatchUi.Drawable {
|
|||||||
_offCourse = off;
|
_offCourse = off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setTrackData(tdst as Float, tnp as Float, dst as Float, off as Float) as Void {
|
||||||
|
_toDestination = tdst;
|
||||||
|
_toNextPoint = tnp;
|
||||||
|
_distance = dst;
|
||||||
|
_offCourse = off;
|
||||||
|
}
|
||||||
|
|
||||||
function draw(dc as Dc) as Void {
|
function draw(dc as Dc) as Void {
|
||||||
if (_toDestination == 0.0f) {
|
if (_toDestination == 0.0f) {
|
||||||
return;
|
return;
|
||||||
@ -78,5 +91,20 @@ class Track extends WatchUi.Drawable {
|
|||||||
acurrent = aend;
|
acurrent = aend;
|
||||||
}
|
}
|
||||||
dc.drawArc(w / 2, h / 2, w / 2 - 2, Graphics.ARC_COUNTER_CLOCKWISE, astart, acurrent);
|
dc.drawArc(w / 2, h / 2, w / 2 - 2, Graphics.ARC_COUNTER_CLOCKWISE, astart, acurrent);
|
||||||
|
|
||||||
|
// next point
|
||||||
|
if (_toNextPoint > 0.0f) {
|
||||||
|
var nextPercentage = _toNextPoint / _toDestination;
|
||||||
|
|
||||||
|
var anext = acurrent + (aend - acurrent) * nextPercentage;
|
||||||
|
if (anext < astart + 1) {
|
||||||
|
anext = astart + 1;
|
||||||
|
} else if (anext > aend) {
|
||||||
|
anext = aend;
|
||||||
|
}
|
||||||
|
dc.setPenWidth((dc.getWidth() * 0.01).toNumber());
|
||||||
|
dc.setColor(0xFFFF00, Graphics.COLOR_TRANSPARENT);
|
||||||
|
dc.drawArc(w / 2, h / 2, w / 2 - 2, Graphics.ARC_COUNTER_CLOCKWISE, acurrent, anext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,6 +84,8 @@ class RepaFieldView extends WatchUi.DataField {
|
|||||||
hidden var ahrValue as Numeric;
|
hidden var ahrValue as Numeric;
|
||||||
hidden var mhrValue as Numeric;
|
hidden var mhrValue as Numeric;
|
||||||
hidden var toDestination as Float;
|
hidden var toDestination as Float;
|
||||||
|
hidden var toNextPoint as Float;
|
||||||
|
hidden var nextPointName as String;
|
||||||
hidden var distance as Float;
|
hidden var distance as Float;
|
||||||
hidden var timer as Numeric;
|
hidden var timer as Numeric;
|
||||||
hidden var timerState as Number;
|
hidden var timerState as Number;
|
||||||
@ -123,6 +125,8 @@ class RepaFieldView extends WatchUi.DataField {
|
|||||||
vsZones = [-16.6, -1.6, 1.6, 5.0, 10.0, 16.6, 25.0];
|
vsZones = [-16.6, -1.6, 1.6, 5.0, 10.0, 16.6, 25.0];
|
||||||
vsZoneColors = gradeZoneColors;
|
vsZoneColors = gradeZoneColors;
|
||||||
toDestination = 0.0f;
|
toDestination = 0.0f;
|
||||||
|
toNextPoint = 0.0f;
|
||||||
|
nextPointName = "";
|
||||||
distance = 0.0f;
|
distance = 0.0f;
|
||||||
timer = 0;
|
timer = 0;
|
||||||
timerState = Activity.TIMER_STATE_OFF;
|
timerState = Activity.TIMER_STATE_OFF;
|
||||||
@ -299,6 +303,16 @@ class RepaFieldView extends WatchUi.DataField {
|
|||||||
} else {
|
} else {
|
||||||
toDestination = 0.0f;
|
toDestination = 0.0f;
|
||||||
}
|
}
|
||||||
|
if (info has :distanceToNextPoint && info.distanceToNextPoint != null) {
|
||||||
|
toNextPoint = info.distanceToNextPoint as Float;
|
||||||
|
} else {
|
||||||
|
toNextPoint = 0.0f;
|
||||||
|
}
|
||||||
|
if (info has :nameOfNextPoint && info.nameOfNextPoint != null) {
|
||||||
|
nextPointName = info.nameOfNextPoint as String;
|
||||||
|
} else {
|
||||||
|
nextPointName = "";
|
||||||
|
}
|
||||||
if (info has :offCourseDistance && info.offCourseDistance != null) {
|
if (info has :offCourseDistance && info.offCourseDistance != null) {
|
||||||
offCourse = info.offCourseDistance as Float;
|
offCourse = info.offCourseDistance as Float;
|
||||||
} else {
|
} else {
|
||||||
@ -390,9 +404,7 @@ class RepaFieldView extends WatchUi.DataField {
|
|||||||
|
|
||||||
// track
|
// track
|
||||||
if (fTrack != null) {
|
if (fTrack != null) {
|
||||||
fTrack.setToDestination(toDestination);
|
fTrack.setTrackData(toDestination, toNextPoint, distance, offCourse);
|
||||||
fTrack.setDistance(distance);
|
|
||||||
fTrack.setOffCourse(offCourse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// time
|
// time
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user