diff --git a/bin/SnapshotWatch-settings.json b/bin/SnapshotWatch-settings.json
index a4964b6..864156d 100644
--- a/bin/SnapshotWatch-settings.json
+++ b/bin/SnapshotWatch-settings.json
@@ -1 +1 @@
-{"settings":[{"key":"showHeartRate","valueType":"boolean","defaultValue":true,"configTitle":"ShowHeartRateLabel","configPrompt":null,"configHelpUrl":null,"configError":null,"configType":"boolean","configReadonly":false,"configRequired":false,"configOptions":null,"configMin":null,"configMax":null,"configMaxLength":null},{"key":"showSecondTime","valueType":"boolean","defaultValue":false,"configTitle":"ShowSecondTimeLabel","configPrompt":null,"configHelpUrl":null,"configError":null,"configType":"boolean","configReadonly":false,"configRequired":false,"configOptions":null,"configMin":null,"configMax":null,"configMaxLength":null},{"key":"secondTimeOffset","valueType":"number","defaultValue":0,"configTitle":"SecondTimeOffsetLabel","configPrompt":null,"configHelpUrl":null,"configError":null,"configType":"numeric","configReadonly":false,"configRequired":false,"configOptions":null,"configMin":null,"configMax":null,"configMaxLength":null}],"languages":{"valyrian":{"ShowHeartRateLabel":"Show heart rate graph and min/max values","ShowSecondTimeLabel":"Show second (digital) time","SecondTimeOffsetLabel":"Second (digital) time hour offset (integer, +-24)","AppName":"SnapshotWatch"}}}
\ No newline at end of file
+{"settings":[{"key":"showHeartRate","valueType":"boolean","defaultValue":true,"configTitle":"ShowHeartRateLabel","configPrompt":null,"configHelpUrl":null,"configError":null,"configType":"boolean","configReadonly":false,"configRequired":false,"configOptions":null,"configMin":null,"configMax":null,"configMaxLength":null},{"key":"graphColour","valueType":"number","defaultValue":0,"configTitle":"GraphColourLabel","configPrompt":null,"configHelpUrl":null,"configError":null,"configType":"list","configReadonly":false,"configRequired":true,"configOptions":[{"display":"DK_GRAY","value":0},{"display":"RED","value":1},{"display":"DK_RED","value":2},{"display":"ORANGE","value":3},{"display":"YELLOW","value":4},{"display":"GREEN","value":5},{"display":"DK_GREEN","value":6},{"display":"BLUE","value":7},{"display":"DK_BLUE","value":8},{"display":"PURPLE","value":9},{"display":"PINK","value":10}],"configMin":null,"configMax":null,"configMaxLength":null},{"key":"useZonesColour","valueType":"boolean","defaultValue":true,"configTitle":"UseZonesColourLabel","configPrompt":null,"configHelpUrl":null,"configError":null,"configType":"boolean","configReadonly":false,"configRequired":false,"configOptions":null,"configMin":null,"configMax":null,"configMaxLength":null},{"key":"showSecondTime","valueType":"boolean","defaultValue":false,"configTitle":"ShowSecondTimeLabel","configPrompt":null,"configHelpUrl":null,"configError":null,"configType":"boolean","configReadonly":false,"configRequired":false,"configOptions":null,"configMin":null,"configMax":null,"configMaxLength":null},{"key":"secondTimeOffset","valueType":"number","defaultValue":0,"configTitle":"SecondTimeOffsetLabel","configPrompt":null,"configHelpUrl":null,"configError":null,"configType":"numeric","configReadonly":false,"configRequired":false,"configOptions":null,"configMin":null,"configMax":null,"configMaxLength":null}],"languages":{"valyrian":{"UseZonesColourLabel":"Additionally colour code graph by profile heart rate zones?","DK_GRAY":"Dark Gray","DK_GREEN":"Dark Green","BLUE":"Blue","SecondTimeOffsetLabel":"Second (digital) time hour offset (integer, +-24)","PURPLE":"Purple","GREEN":"Green","DK_RED":"Dark Red","DK_BLUE":"Dark Blue","AppName":"SnapshotWatch","RED":"Red","PINK":"Pink","ShowHeartRateLabel":"Show heart rate graph and min/max values","GraphColourLabel":"Heart rate graph colour","ShowSecondTimeLabel":"Show second (digital) time","YELLOW":"Yellow","ORANGE":"Orange"}}}
\ No newline at end of file
diff --git a/bin/SnapshotWatch.prg b/bin/SnapshotWatch.prg
index 6a8d290..4e06dc9 100644
Binary files a/bin/SnapshotWatch.prg and b/bin/SnapshotWatch.prg differ
diff --git a/bin/SnapshotWatch.prg.debug.xml b/bin/SnapshotWatch.prg.debug.xml
index 450f7ce..a4934eb 100644
--- a/bin/SnapshotWatch.prg.debug.xml
+++ b/bin/SnapshotWatch.prg.debug.xml
@@ -35,352 +35,382 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-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
-
-
+
+
+
+
+
+
+
-
-
+
+
+
-
+
-
+
+
+
+
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+
-
-
+
+
+
-
+
-
-
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
+
-
-
-
+
+
+
+
@@ -388,69 +418,70 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -493,6 +524,10 @@
+
+
+
+
diff --git a/manifest.xml b/manifest.xml
index 49b1a42..83af5e1 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -7,6 +7,7 @@
+
diff --git a/resources/resources.xml b/resources/resources.xml
index 56910b9..1ab1ef5 100644
--- a/resources/resources.xml
+++ b/resources/resources.xml
@@ -2,12 +2,27 @@
true
+ 0
+ true
false
0
Show heart rate graph and min/max values
+ Heart rate graph colour
+ Dark Gray
+ Red
+ Dark Red
+ Orange
+ Yellow
+ Green
+ Dark Green
+ Blue
+ Dark Blue
+ Purple
+ Pink
+ Additionally colour code graph by profile heart rate zones?
Show second (digital) time
Second (digital) time hour offset (integer, +-24)
@@ -16,6 +31,24 @@
+
+
+ @Strings.DK_GRAY
+ @Strings.RED
+ @Strings.DK_RED
+ @Strings.ORANGE
+ @Strings.YELLOW
+ @Strings.GREEN
+ @Strings.DK_GREEN
+ @Strings.BLUE
+ @Strings.DK_BLUE
+ @Strings.PURPLE
+ @Strings.PINK
+
+
+
+
+
diff --git a/source/SnapshotWatchView.mc b/source/SnapshotWatchView.mc
index 0cc45df..dc7e8e4 100644
--- a/source/SnapshotWatchView.mc
+++ b/source/SnapshotWatchView.mc
@@ -9,6 +9,7 @@ using Toybox.Application as App;
using Toybox.ActivityMonitor as ActMon;
using Toybox.SensorHistory as Sensor;
using Toybox.Activity as Activity;
+using Toybox.UserProfile as User;
enum
{
@@ -24,6 +25,11 @@ class SnapshotWatchView extends Ui.WatchFace {
var showSecondTime = false;
var secondTimeOffset = 0;
+ var arrayColours = new [11];
+ var graphColour = 0;
+ var useZonesColour = true;
+ var heartRateZones;
+
var background_color = Gfx.COLOR_BLACK;
// var background_color = Gfx.COLOR_DK_GRAY;
@@ -43,6 +49,10 @@ class SnapshotWatchView extends Ui.WatchFace {
width_screen = dc.getWidth();
height_screen = dc.getHeight();
+ arrayColours = [Gfx.COLOR_DK_GRAY, Gfx.COLOR_RED, Gfx.COLOR_DK_RED, Gfx.COLOR_ORANGE, Gfx.COLOR_YELLOW, Gfx.COLOR_GREEN, Gfx.COLOR_DK_GREEN, Gfx.COLOR_BLUE, Gfx.COLOR_DK_BLUE, Gfx.COLOR_PURPLE, Gfx.COLOR_PINK];
+ heartRateZones = User.getHeartRateZones(User.getCurrentSport());
+// heartRateZones = [98, 127, 146, 166, 185, 195];
+
//get hash marks position
for(var i = 0; i < 60; i+=1)
{
@@ -69,6 +79,8 @@ class SnapshotWatchView extends Ui.WatchFace {
if (usePreferences)
{
showHeartRate = Application.getApp().getProperty("showHeartRate");
+ graphColour = Application.getApp().getProperty("graphColour");
+ useZonesColour = Application.getApp().getProperty("useZonesColour");
showSecondTime = Application.getApp().getProperty("showSecondTime");
secondTimeOffset = Application.getApp().getProperty("secondTimeOffset");
}
@@ -198,8 +210,6 @@ class SnapshotWatchView extends Ui.WatchFace {
if (sample.getMax() != null)
{ heartMax = sample.getMax(); }
- dc.setColor(Gfx.COLOR_DK_GREEN, Gfx.COLOR_TRANSPARENT);
-
var maxSecs = 14355; //14400 = 4 hours
var totHeight = 44;
var totWidth = 165;
@@ -275,10 +285,12 @@ class SnapshotWatchView extends Ui.WatchFace {
// only plot bar if we have valid values
if (heartBinMax > 0 && heartBinMax >= heartBinMin)
{
- var height = ((heartBinMax+heartBinMin)/2-heartMin*0.9) / (heartMax-heartMin*0.9) * totHeight;
+ var heartBinMid = (heartBinMax+heartBinMin)/2;
+ var height = (heartBinMid-heartMin*0.9) / (heartMax-heartMin*0.9) * totHeight;
var xVal = (width_screen-totWidth)/2 + totWidth - i*binPixels -2;
var yVal = height_screen/2+28 + totHeight - height;
+ dc.setColor(arrayColours[getHRColour(heartBinMid)], Gfx.COLOR_TRANSPARENT);
dc.fillRectangle(xVal, yVal, binPixels, height);
// Sys.println(i + ": " + binWidthSecs + " " + secsBin + " " + heartBinMin + " " + heartBinMax);
@@ -294,6 +306,23 @@ class SnapshotWatchView extends Ui.WatchFace {
}
+ function getHRColour(heartrate)
+ {
+ if (!useZonesColour || heartrate == null || heartrate < heartRateZones[1])
+ { return graphColour; }
+// else if (heartrate >= heartRateZones[0] && heartrate < heartRateZones[1])
+// { return 0; }
+ else if (heartrate >= heartRateZones[1] && heartrate < heartRateZones[2])
+ { return 7; }
+ else if (heartrate >= heartRateZones[2] && heartrate < heartRateZones[3])
+ { return 6; }
+ else if (heartrate >= heartRateZones[3] && heartrate < heartRateZones[4])
+ { return 3; }
+ else
+ { return 2; }
+ }
+
+
//! Draw the watch hand
function drawHand(dc, angle, whichHand, width, handColour)
{