-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBluetoothIndicator.mc
42 lines (34 loc) · 1.21 KB
/
BluetoothIndicator.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
42
using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.BluetoothLowEnergy as Bt;
class BluetoothIndicator extends Ui.Drawable {
hidden var x, y, bluetooth = null;
function initialize(params) {
Drawable.initialize(params);
x = params.get(:x);
y = params.get(:y);
}
function draw(dc) {
var w = 15;
if (bluetooth == null || System.getClockTime().sec == 0) {
bluetooth = System.getDeviceSettings().phoneConnected;
}
var color = Gfx.COLOR_RED;
if (bluetooth == true) {
color = Gfx.COLOR_BLUE;
}
drawBtIcon(dc, x, y, 1.4, 0, color);
}
function drawBtIcon(dc, centerX, centerY, symbolScale, radius, color) {
dc.setPenWidth(2);
dc.setColor(color, Gfx.COLOR_TRANSPARENT);
var btSymbol = [ [0, 9], [6, 3], [3, 0], [3, 12], [6, 9], [-1, 2] ];
for (var i = 0; i < btSymbol.size() - 1; i++) {
dc.drawLine(symbolScale * btSymbol[i][0] + centerX - 15,
symbolScale * btSymbol[i][1] + centerY - radius / 1.6,
symbolScale * btSymbol[i + 1][0] + centerX - 15,
symbolScale * btSymbol[i + 1][1] + centerY - radius / 1.6);
}
dc.setPenWidth(1);
}
}