-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.js
45 lines (34 loc) · 1 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
const blessed = require('blessed')
const contrib = require('blessed-contrib')
const mind = require('wits')
const channels = require('./lib/channels')
require('./lib/override-blessed-contrib')
const screen = blessed.screen()
const grid = new contrib.grid({
rows: 12,
cols: 12,
screen: screen,
hideBorder: false,
dashboardMargin: 0,
color: 'black'
})
const widgets = {};
['monitor', 'gyroxy', 'battery', 'log', 'channels'].forEach(w => widgets[w] = require(`./widgets/${w}`)(grid))
screen.key(['escape', 'q', 'C-c'], (ch, key) => {
return process.exit(0)
})
screen.on('resize', function () {
widgets.forEach(w => w.emit('attach'))
})
screen.render()
setInterval(() => screen.render(), 250)
mind.setLogger(widgets.log.update)
setTimeout(() => {
mind.open()
mind.read(data => {
widgets.battery.update(data.battery)
widgets.channels.update(data.cq)
widgets.gyroxy.update([data.gyro.x, data.gyro.y])
widgets.monitor.update(data.levels)
})
}, 100)