Skip to content

Commit fa91299

Browse files
author
thyttan
committed
Merge branch 'spotrem' into app-loader
2 parents 4601fdf + 6666f7a commit fa91299

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

modules/Dial_Display.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,20 @@ function DialDisplay(options) {
1414
}, options);
1515

1616
this.value = 0;
17-
this.reset();
17+
this.isFullDraw = true;
1818
}
1919

20-
DialDisplay.prototype.reset = function() {
21-
this.isFirstDraw = true;
20+
DialDisplay.prototype.queueRedraw = function() {
21+
this.isFullDraw = true;
22+
this.prevDrawnValue = null;
2223
};
2324

2425
DialDisplay.prototype.set = function(value) {
25-
this.prevValue = this.value;
2626
this.value = value;
2727
};
2828

2929
DialDisplay.prototype.step = function(step) {
3030
"ram";
31-
let prevValue = this.prevValue != null ? this.prevValue : this.value;
3231
this.value += step;
3332
//g.setFont("Vector:30");
3433
//g.drawString(this.value);
@@ -47,22 +46,22 @@ DialDisplay.prototype.step = function(step) {
4746
if (!isFill) g.drawCircle(x, y, rad);
4847
if (isFill) g.fillCircle(x, y, rad);
4948
}
50-
if (this.isFirstDraw) {
49+
if (this.isFullDraw) {
5150
g.setColor(0,0,0).fillCircle(CENTER.x, CENTER.y, 25);
5251
g.setColor(1,1,1).drawCircle(CENTER.x, CENTER.y, 25);
5352
for (let i=0; i<this.options.stepsPerWholeTurn; i++) {
5453
drawCircle(i, 1, 1, 1, 1, true);
5554
}
56-
this.isFirstDraw = false;
55+
this.isFullDraw = false;
5756
}
5857

5958
//drawCircle(this.value, 1, 1, 1, 2, false);
6059
//drawCircle(prevValue, 0, 0, 0, 2, false);
61-
g.setColor(0,0,0).drawLine(CENTER.x, CENTER.y, CENTER.x+23*Math.sin(prevValue*(2*Math.PI/this.options.stepsPerWholeTurn)), CENTER.y-23*Math.cos(prevValue*(2*Math.PI/this.options.stepsPerWholeTurn)));
60+
g.setColor(0,0,0).drawLine(CENTER.x, CENTER.y, CENTER.x+23*Math.sin(this.prevDrawnValue*(2*Math.PI/this.options.stepsPerWholeTurn)), CENTER.y-23*Math.cos(this.prevDrawnValue*(2*Math.PI/this.options.stepsPerWholeTurn)));
6261
g.setColor(1,1,1).drawLine(CENTER.x, CENTER.y, CENTER.x+23*Math.sin(this.value*(2*Math.PI/this.options.stepsPerWholeTurn)), CENTER.y-23*Math.cos(this.value*(2*Math.PI/this.options.stepsPerWholeTurn)));
6362
g.setColor(0,0,0).fillCircle(CENTER.x, CENTER.y, 9);
6463

65-
delete this.prevValue;
64+
this.prevDrawnValue = this.value;
6665
};
6766

6867
exports = DialDisplay;

modules/Dial_Display.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dialDisplay.step(-1);
1616
var value = dialDisplay.value;
1717

1818
// ... after some time:
19-
dialDisplay.reset();
19+
dialDisplay.queueRedraw();
2020
dialDisplay.set(0);
2121
```
2222

@@ -37,11 +37,10 @@ var DialDisplay = require("Dial_Display");
3737
var dialDisplay = new DialDisplay(options);
3838

3939
var cb = (step) => {
40-
dialDisplay.reset();
4140
dialDisplay.step(step);
4241
};
4342

44-
var dial = require("Dial")(cb, options)
43+
var dial = require("dial")(cb, options)
4544
Bangle.on("drag", dial);
4645
```
4746

@@ -65,7 +64,7 @@ Defaults:
6564
The Dial Display has three functions:
6665
`step(amount)` - +1 or -1 to step the dial.
6766
`set(value)` - set the value for the next `step()` to act on.
68-
`reset()` - draw all of the dial (instead of just the indicator) on the next `step()`.
67+
`queueRedraw()` - draw all of the dial (instead of just the indicator) on the next `step()`.
6968

7069
Notes:
7170
======

0 commit comments

Comments
 (0)