From e7b8a5c5054b3289faac7604a4cdb9051de3ae7f Mon Sep 17 00:00:00 2001 From: Samuel Leihkamm Date: Sat, 12 Oct 2024 18:03:48 +0100 Subject: [PATCH] feature: add 126720 for Raymarine Display Group Brightness --- conversions/raymarineBrightness.js | 80 ++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 conversions/raymarineBrightness.js diff --git a/conversions/raymarineBrightness.js b/conversions/raymarineBrightness.js new file mode 100644 index 0000000..42dcd17 --- /dev/null +++ b/conversions/raymarineBrightness.js @@ -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 + } + }] + }] + } + }) + } + } +}