Skip to content

Commit 656294b

Browse files
author
thyttan
committed
Dial: add contents to documentation
1 parent e7b0af4 commit 656294b

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

modules/Dial.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,60 @@
1-
Dial Library
2-
============
1+
Bangle.js Dial Library
2+
======================
33

4+
> Take a look at README.md for hints on developing with this library.
45
6+
Usage
7+
-----
8+
9+
```JS
10+
var Dial = require("Dial");
11+
var dial = new Dial(cb, options)
12+
Bangle.on("drag", dial);
13+
14+
or
15+
16+
var dial = require("Dial")(cb, options);
17+
Bangle.on("drag", dial);
18+
```
19+
20+
For example:
21+
22+
```JS
23+
let cb = (plusOrMinusOne)=>{print(plusOrMinusOne)};
24+
let options = {
25+
stepsPerWholeTurn : 6,
26+
dialRect : {
27+
x: 0,
28+
y: 0,
29+
w: g.getWidth()/2,
30+
h: g.getHeight()/2,
31+
}
32+
}
33+
34+
let dial = require("Dial")(cb, options);
35+
Bangle.on("drag", dial);
36+
```
37+
38+
`cb` (first argument) is a callback function that should expect either `+1` or `-1` as argument when called.
39+
40+
`options` (second argument) (optional) is an object containing:
41+
42+
stepsPerWholeTurn - how many steps there are in one complete turn of the dial.
43+
dialRect - decides the area of the screen the dial is set up on.
44+
45+
Defaults:
46+
```js
47+
{ stepsPerWholeTurn : 7
48+
dialRect : {
49+
x: 0,
50+
y: 0,
51+
w: g.getWidth(),
52+
h: g.getHeight(),
53+
},
54+
}
55+
```
56+
57+
Notes
58+
-----
59+
60+
A complementary library for drawing graphics for the dial would be neat and is being considered.

0 commit comments

Comments
 (0)