-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add 126720 for Raymarine Display Group Brightness (#113)
- Loading branch information
1 parent
57c2e80
commit d4380ff
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
const _ = require('lodash') | ||
|
||
module.exports = (app, plugin) => { | ||
return { | ||
title: 'Raymarine (Seatalk) Display Brightness (126720)', | ||
optionKey: 'RAYMARINE', | ||
context: 'vessels.self', | ||
properties: { | ||
groups: { | ||
title: 'Group Mapping', | ||
type: 'array', | ||
items: { | ||
type: 'object', | ||
properties: { | ||
signalkId: { | ||
title: 'Signal K Group id', | ||
type: 'string', | ||
}, | ||
instanceId: { | ||
title: 'NMEA2000 Group Instance Id', | ||
type: 'string', | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
testOptions: { | ||
RAYMARINE: { | ||
groups: [{ | ||
signalkId: 'helm2', | ||
instanceId: 'Helm 2' | ||
}] | ||
} | ||
}, | ||
|
||
conversions: (options) => { | ||
if (!_.get(options, 'RAYMARINE.groups')) { | ||
return null | ||
} | ||
return options.RAYMARINE.groups.map(group => { | ||
return { | ||
keys: [`electrical.displays.raymarine.${group.signalkId}.brightness`], | ||
callback: (brightness) => { | ||
return [{ | ||
pgn: 126720, | ||
"dst": 255, | ||
"Manufacturer Code": "Raymarine", | ||
"Industry Code": "Marine Industry", | ||
"Proprietary ID": "0x0c8c", | ||
"Group": group.instanceId, | ||
"Unknown 1": 1, | ||
"Command": "Brightness", | ||
"Brightness": brightness * 100, | ||
"Unknown 2": 0 | ||
}] | ||
}, | ||
tests: [{ | ||
input: [0.85], | ||
expected: [{ | ||
"prio": 2, | ||
"pgn": 126720, | ||
"dst": 255, | ||
"fields": { | ||
"Manufacturer Code": "Raymarine", | ||
"Industry Code": "Marine Industry", | ||
"Proprietary ID": "0x0c8c", | ||
"Group": "Helm 2", | ||
"Unknown 1": 1, | ||
"Command": "Brightness", | ||
"Brightness": 85, | ||
"Unknown 2": 0 | ||
} | ||
}] | ||
}] | ||
} | ||
}) | ||
} | ||
} | ||
} |