mirror of
https://github.com/dyuri/garmin-repafield.git
synced 2026-09-23 20:24:21 +00:00
dist/pace/apace (TODO bg params)
This commit is contained in:
@@ -21,8 +21,19 @@ class Background extends WatchUi.Drawable {
|
||||
}
|
||||
|
||||
function draw(dc as Dc) as Void {
|
||||
dc.setColor(Graphics.COLOR_TRANSPARENT, mColor);
|
||||
var x = 132;
|
||||
var y = 62;
|
||||
var width = 300;
|
||||
var height = 260;
|
||||
var diff = -20;
|
||||
dc.setColor(0x002244, mColor);
|
||||
dc.clear();
|
||||
dc.fillPolygon([[x+width, y], [x, y], [x-diff, y+height], [x+width, y+height]]);
|
||||
dc.setColor(0x003366, mColor);
|
||||
dc.setPenWidth(1);
|
||||
dc.drawLine(x+width, y, x, y);
|
||||
dc.drawLine(x, y, x-diff, y+height);
|
||||
dc.drawLine(x-diff, y+height, x+width, y+height);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,19 +58,25 @@ class Track extends WatchUi.Drawable {
|
||||
|
||||
// color
|
||||
if (_offCourse > 50.0f) {
|
||||
dc.setColor(0xFF0000, Graphics.COLOR_TRANSPARENT);
|
||||
dc.setColor(0x8800FF, Graphics.COLOR_TRANSPARENT);
|
||||
} else if (trackPercentage < 0.2) {
|
||||
dc.setColor(0xFFFF00, Graphics.COLOR_TRANSPARENT);
|
||||
dc.setColor(0x4400FF, Graphics.COLOR_TRANSPARENT);
|
||||
} else if (trackPercentage < 0.4) {
|
||||
dc.setColor(0xAAFF00, Graphics.COLOR_TRANSPARENT);
|
||||
dc.setColor(0x0000FF, Graphics.COLOR_TRANSPARENT);
|
||||
} else if (trackPercentage < 0.6) {
|
||||
dc.setColor(0x88FF00, Graphics.COLOR_TRANSPARENT);
|
||||
dc.setColor(0x0055FF, Graphics.COLOR_TRANSPARENT);
|
||||
} else if (trackPercentage < 0.8) {
|
||||
dc.setColor(0x44FF00, Graphics.COLOR_TRANSPARENT);
|
||||
dc.setColor(0x00AAFF, Graphics.COLOR_TRANSPARENT);
|
||||
} else {
|
||||
dc.setColor(0x00FF00, Graphics.COLOR_TRANSPARENT);
|
||||
dc.setColor(0x00FFFF, Graphics.COLOR_TRANSPARENT);
|
||||
}
|
||||
|
||||
dc.drawArc(w / 2, h / 2, w / 2 - 2, Graphics.ARC_COUNTER_CLOCKWISE, astart, astart + (aend-astart) * trackPercentage);
|
||||
var acurrent = astart + (aend - astart) * trackPercentage;
|
||||
if (acurrent < astart + 1) {
|
||||
acurrent = astart + 1;
|
||||
} else if (acurrent > aend) {
|
||||
acurrent = aend;
|
||||
}
|
||||
dc.drawArc(w / 2, h / 2, w / 2 - 2, Graphics.ARC_COUNTER_CLOCKWISE, astart, acurrent);
|
||||
}
|
||||
}
|
||||
|
||||
+26
-2
@@ -14,6 +14,7 @@ class RepaFieldView extends WatchUi.DataField {
|
||||
hidden var toDestination as Float;
|
||||
hidden var distance as Float;
|
||||
hidden var timer as Numeric;
|
||||
hidden var timerState as Number;
|
||||
hidden var offCourse as Float;
|
||||
|
||||
function initialize() {
|
||||
@@ -25,6 +26,7 @@ class RepaFieldView extends WatchUi.DataField {
|
||||
toDestination = 0.0f;
|
||||
distance = 0.0f;
|
||||
timer = 0;
|
||||
timerState = Activity.TIMER_STATE_OFF;
|
||||
offCourse = 0.0f;
|
||||
}
|
||||
|
||||
@@ -109,6 +111,11 @@ class RepaFieldView extends WatchUi.DataField {
|
||||
} else {
|
||||
timer = 0;
|
||||
}
|
||||
if (info.timerState != null) {
|
||||
timerState = info.timerState;
|
||||
} else {
|
||||
timerState = Activity.TIMER_STATE_OFF;
|
||||
}
|
||||
if (info.distanceToDestination != null) {
|
||||
toDestination = info.distanceToDestination as Float;
|
||||
} else {
|
||||
@@ -124,8 +131,8 @@ class RepaFieldView extends WatchUi.DataField {
|
||||
// Display the value you computed here. This will be called
|
||||
// once a second when the data field is visible.
|
||||
function onUpdate(dc as Dc) as Void {
|
||||
// Set the background color
|
||||
(View.findDrawableById("Background") as Background).setColor(getBackgroundColor());
|
||||
// Set the background color - don't ;)
|
||||
// (View.findDrawableById("Background") as Background).setColor(getBackgroundColor());
|
||||
|
||||
// HR value
|
||||
var hrColor = calculateHRColor(hrValue);
|
||||
@@ -164,9 +171,26 @@ class RepaFieldView extends WatchUi.DataField {
|
||||
var trh = timer / 3600;
|
||||
var trm = (timer % 3600) / 60;
|
||||
var trs = timer % 60;
|
||||
if (timerState == Activity.TIMER_STATE_ON) {
|
||||
timerField.setColor(Graphics.COLOR_WHITE);
|
||||
} else if (timerState == Activity.TIMER_STATE_PAUSED) {
|
||||
timerField.setColor(Graphics.COLOR_YELLOW);
|
||||
} else {
|
||||
timerField.setColor(Graphics.COLOR_RED);
|
||||
}
|
||||
timerField.setText(trh.format("%02d") + ":" + trm.format("%02d") + ":" + trs.format("%02d"));
|
||||
}
|
||||
|
||||
// distance
|
||||
var dstField = View.findDrawableById("distance") as Text;
|
||||
if (dstField != null) {
|
||||
if (distance >= 10000) {
|
||||
dstField.setText((distance / 1000).format("%.1f"));
|
||||
} else {
|
||||
dstField.setText((distance / 1000).format("%.2f"));
|
||||
}
|
||||
}
|
||||
|
||||
// Set the foreground color and value
|
||||
var value = View.findDrawableById("value") as Text;
|
||||
if (value != null) {
|
||||
|
||||
Reference in New Issue
Block a user