-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStepsGoalGraph.mc
41 lines (32 loc) · 1018 Bytes
/
StepsGoalGraph.mc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.BluetoothLowEnergy as Bt;
class StepsGoalGraph extends Ui.Drawable {
hidden var x, y, width, percentage = null;
function initialize(params) {
Drawable.initialize(params);
x = params.get(:x);
y = params.get(:y);
width = params.get(:width);
}
function draw(dc) {
if (percentage == null || System.getClockTime().sec % 30 == 0) {
var info = ActivityMonitor.getInfo();
var steps = info.steps;
var stepsGoal = info.stepGoal;
if (stepsGoal != 0) {
percentage = steps.toDouble() / stepsGoal.toDouble();
}
if (percentage > 1) {
percentage = 1;
}
}
dc.setColor(Gfx.COLOR_DK_GRAY, Gfx.COLOR_DK_GRAY);
dc.setPenWidth(9);
dc.drawLine(x, y, x + width, y);
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_WHITE);
dc.setPenWidth(5);
dc.drawLine(x, y, x + (width * percentage), y);
dc.setPenWidth(1);
}
}