-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (38 loc) · 897 Bytes
/
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
const stardate = require('stardate-converter');
module.exports = (app) => {
const plugin = {};
let timer;
plugin.id = 'signalk-stardate';
plugin.name = 'Stardate';
plugin.description = 'Provides SignalK the current stardate';
plugin.start = () => {
plugin.stardate();
timer = setInterval(() => {
plugin.stardate();
}, 60000);
app.debug('stardate started');
};
plugin.stardate = () => {
app.handleMessage(plugin.id, {
updates: [
{
values: [
{
path: 'navigation.stardate',
value: stardate(new Date()),
meta: {
displayName: 'Stardate',
units: 'stardate',
},
},
],
},
],
});
};
plugin.stop = () => {
clearInterval(timer);
app.debug('stardate stopped');
};
return plugin;
};