mirror of
https://github.com/dyuri/garmin-repafield.git
synced 2025-12-16 19:24:01 +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 {
|
||||
|
||||
hidden var _toDestination as Float;
|
||||
hidden var _toNextPoint as Float;
|
||||
hidden var _distance as Float;
|
||||
hidden var _offCourse as Float;
|
||||
|
||||
@ -17,6 +18,7 @@ class Track extends WatchUi.Drawable {
|
||||
Drawable.initialize(dictionary);
|
||||
|
||||
_toDestination = 0.0f;
|
||||
_toNextPoint = 0.0f;
|
||||
_distance = 0.0f;
|
||||
_offCourse = 0.0f;
|
||||
}
|
||||
@ -25,6 +27,10 @@ class Track extends WatchUi.Drawable {
|
||||
_toDestination = tdst;
|
||||
}
|
||||
|
||||
function setToNextPoint(tnp as Float) as Void {
|
||||
_toNextPoint = tnp;
|
||||
}
|
||||
|
||||
function setDistance(dst as Float) as Void {
|
||||
_distance = dst;
|
||||
}
|
||||
@ -33,6 +39,13 @@ class Track extends WatchUi.Drawable {
|
||||
_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 {
|
||||
if (_toDestination == 0.0f) {
|
||||
return;
|
||||
@ -78,5 +91,20 @@ class Track extends WatchUi.Drawable {
|
||||
acurrent = aend;
|
||||
}
|
||||
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 mhrValue as Numeric;
|
||||
hidden var toDestination as Float;
|
||||
hidden var toNextPoint as Float;
|
||||
hidden var nextPointName as String;
|
||||
hidden var distance as Float;
|
||||
hidden var timer as Numeric;
|
||||
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];
|
||||
vsZoneColors = gradeZoneColors;
|
||||
toDestination = 0.0f;
|
||||
toNextPoint = 0.0f;
|
||||
nextPointName = "";
|
||||
distance = 0.0f;
|
||||
timer = 0;
|
||||
timerState = Activity.TIMER_STATE_OFF;
|
||||
@ -299,6 +303,16 @@ class RepaFieldView extends WatchUi.DataField {
|
||||
} else {
|
||||
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) {
|
||||
offCourse = info.offCourseDistance as Float;
|
||||
} else {
|
||||
@ -390,9 +404,7 @@ class RepaFieldView extends WatchUi.DataField {
|
||||
|
||||
// track
|
||||
if (fTrack != null) {
|
||||
fTrack.setToDestination(toDestination);
|
||||
fTrack.setDistance(distance);
|
||||
fTrack.setOffCourse(offCourse);
|
||||
fTrack.setTrackData(toDestination, toNextPoint, distance, offCourse);
|
||||
}
|
||||
|
||||
// time
|
||||
|
||||
Loading…
Reference in New Issue
Block a user