-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (36 loc) · 1.38 KB
/
index.js
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
43
require("dotenv").config();
const { Notion: Mind } = require("@neurosity/notion");
const { chart, hkc, hkcd, auth, State} = require("./modules");
(async function main() {
var mind = new Mind();
//login
mind = await auth(mind);
//build array for chartData
var state = new State();
console.log('awaiting mind signal');
mind
.predictions(process.env.ACTION)
.subscribe((prediction) => {
//draw the chart
state = chart(prediction.probability, state);
switch(process.env.TYPE){
case 'hold' :
//if the model is over threshold confidence, trigger a the action
//this will call the force push function
if (prediction.probability > process.env.THRESHOLD && state.isTrigger){
//this is the function called when trigger is pushed
state = !process.env.DEMO ? hkc(state) : hkcd(state);
}
//if isTrigger is false, try to trigger if we go under threashold confidence
if (prediction.probability < process.env.THRESHOLD && !state.isTrigger){
state = !process.env.DEMO ? hkc(state) : hkcd(state);
} ;
break;
default:
//default action is to single tap key, off -on toggle
if (prediction.probability > process.env.THRESHOLD){
state = !process.env.DEMO ? hkc(state) : hkcd(state);
} ;
}
});
})();