mirror of
https://github.com/dyuri/garmin-repafield.git
synced 2025-12-16 19:24:01 +00:00
dist/pace/apace (TODO bg params)
This commit is contained in:
parent
8f339d6d21
commit
d545d7bf0f
@ -1,7 +1,7 @@
|
||||
<layouts>
|
||||
<!-- A generic, centered layout. -->
|
||||
<layout id="MainLayout">
|
||||
<drawable class="Background" />
|
||||
<drawable class="Background"/>
|
||||
<drawable class="HeartRate" id="HeartRate">
|
||||
<param name="y">64</param>
|
||||
</drawable>
|
||||
@ -17,7 +17,14 @@
|
||||
<label id="time" x="center" y="370" color="Graphics.COLOR_LT_GRAY" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_XTINY" />
|
||||
<label id="timer" x="center" y="330" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_SMALL" />
|
||||
|
||||
<!-- TODO distance, pace, avg pace, time, timer, elevation, egain, calories -->
|
||||
<!-- distance/pace/avg pace -->
|
||||
<label id="pace" x="80%" y="80" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_RIGHT" font="Graphics.FONT_NUMBER_MEDIUM" text="12.34"/>
|
||||
<label id="paceLabel" x="81%" y="136" color="0x004488" justification="Graphics.TEXT_JUSTIFY_LEFT" font="Graphics.FONT_XTINY" text="pace"/>
|
||||
<label id="apace" x="80%" y="178" color="0x4488FF" justification="Graphics.TEXT_JUSTIFY_RIGHT" font="Graphics.FONT_LARGE" text="12.34"/>
|
||||
<label id="apaceLabel" x="81%" y="200" color="0x004488" justification="Graphics.TEXT_JUSTIFY_LEFT" font="Graphics.FONT_XTINY" text="apace"/>
|
||||
<label id="distance" x="80%" y="224" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_RIGHT" font="Graphics.FONT_NUMBER_MEDIUM" />
|
||||
<label id="distanceLabel" x="81%" y="272" color="0x004488" justification="Graphics.TEXT_JUSTIFY_LEFT" font="Graphics.FONT_TINY" text="km"/>
|
||||
<!-- TODO distance, pace, avg pace, elevation, egain, calories -->
|
||||
</layout>
|
||||
|
||||
<!-- Layouts used for the for the four quadrants. -->
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user