-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
84 lines (64 loc) · 1.96 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const { Notion: Mind } = require("@neurosity/notion");
const inquirer = require("inquirer");
const { argv } = require("yargs");
const { getLoginPrompts, getDevicesPrompt } = require("./lib/prompts");
async function init() {
console.log("Login with your Neurosity account to access the brain");
const loginForm = await inquirer.prompt(getLoginPrompts());
const mind = new Mind({ autoSelectDevice: false });
await mind.login(loginForm);
const devices = await mind.getDevices();
const selectedDevice = await inquirer.prompt(
getDevicesPrompt(devices)
);
const info = await mind.selectDevice((devices) =>
devices.find(
(device) => device.deviceId === selectedDevice.deviceId
)
);
console.clear();
const { screen, charts } = require("./lib/ui");
const Brainwaves = require("./lib/brainwaves");
const Awareness = require("./lib/awareness");
const PowerByBand = require("./lib/powerByBand");
const { tween } = require("./lib/tween");
const { getStatusString } = require("./lib/status");
const kinesisEscCmd = argv["kinesis-esc-cmd"];
screen.render();
charts.deviceNickname.setContent(
`${info.deviceNickname} (OS v${info.osVersion})`
);
const brainwaves = new Brainwaves(info);
const awareness = new Awareness();
const powerByBand = new PowerByBand();
mind.brainwaves("raw").subscribe((epoch) => {
brainwaves.render(epoch);
});
mind.brainwaves("powerByBand").subscribe((bands) => {
powerByBand.render(bands.data);
});
mind
.focus()
.pipe(tween())
.subscribe((focus) => {
awareness.renderFocus(focus);
});
mind
.calm()
.pipe(tween())
.subscribe((calm) => {
awareness.renderCalm(calm);
});
mind.status().subscribe((status) => {
const statusString = getStatusString(status);
charts.status.setContent(statusString);
});
if (kinesisEscCmd) {
mind.kinesis(kinesisEscCmd).subscribe(() => {
process.exit();
});
}
}
module.exports = {
init
};