Skip to content

Commit

Permalink
Merge pull request #7 from phillipivan/main
Browse files Browse the repository at this point in the history
Add variable support for crosspoint feedback
  • Loading branch information
phillipivan authored Jul 24, 2024
2 parents 5b15c3b + 47a8dd3 commit a6b2f29
Show file tree
Hide file tree
Showing 13 changed files with 685 additions and 694 deletions.
Empty file added DEBUG-PACKAGED
Empty file.
5 changes: 5 additions & 0 deletions companion/HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ The Action Recorder will translate any connection messages into new connect acti

## Version History

### Version 1.2.0
- Add variable support for crosspoint feedback
- Convert to ESM
- Minor fixes

### Version 1.1.0
- Add action recorder support

Expand Down
4 changes: 2 additions & 2 deletions companion/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "ntp-technology-dot",
"shortname": "DOT Protocol",
"description": "NTP DOT Protocol for control of audio routers with Bitfocus Companion",
"version": "1.0.2",
"version": "0.0.0",
"license": "MIT",
"repository": "git+https://github.com/bitfocus/companion-module-ntp-technology-dot.git",
"bugs": "https://github.com/bitfocus/companion-module-ntp-technology-dot/issues",
Expand All @@ -17,7 +17,7 @@
"type": "node18",
"api": "nodejs-ipc",
"apiVersion": "0.0.0",
"entrypoint": "../main.js"
"entrypoint": "../src/main.js"
},
"legacyIds": [],
"manufacturer": "NTP Technology",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "ntp-technology-dot",
"version": "1.1.0",
"version": "1.2.0",
"main": "src/main.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"format": "prettier --write",
Expand Down
109 changes: 40 additions & 69 deletions src/actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const { paramSep, addrSep, nullParam, SOM, control, appTag, addrCmd } = require('./consts.js')
import { paramSep, addrSep, nullParam, SOM, control, appTag, addrCmd } from './consts.js'

module.exports = function (self) {
export default async function (self) {
const optionSrc = {
id: 'src',
type: 'dropdown',
label: 'Source',
default: 1,
choices: self.sources,
useVariables: true,
allowCustom: true,
tooltip: 'Variable must return an integer src number',
}
self.setActionDefinitions({
crosspoint: {
name: 'Crosspoint',
Expand All @@ -14,18 +24,9 @@ module.exports = function (self) {
choices: self.destinations,
useVariables: true,
allowCustom: true,
tooltip: 'Varible must return an integer dst number',
},
{
id: 'src',
type: 'dropdown',
label: 'Source',
default: 1,
choices: self.sources,
useVariables: true,
allowCustom: true,
tooltip: 'Varible must return an integer src number',
tooltip: 'Variable must return an integer dst number',
},
optionSrc,
{
id: 'method',
type: 'dropdown',
Expand All @@ -36,17 +37,17 @@ module.exports = function (self) {
},
],
callback: async ({ options }) => {
let dst = parseInt(await self.parseVariablesInString(options.dst))
let cmd = ''
const dst = parseInt(await self.parseVariablesInString(options.dst))
let cmd
if (isNaN(dst) || dst < 1 || dst > self.config.dst) {
self.log('warn', `an invalid dst varible has been passed: ${dst}`)
self.log('warn', `an invalid dst variable has been passed: ${dst}`)
return undefined
}
if (options.method == control.reqSet) {
cmd = SOM + control.reqSet + appTag.crosspoint + dst + paramSep
let src = parseInt(await self.parseVariablesInString(options.src))
if (isNaN(src) || src < 0 || src > self.config.src) {
self.log('warn', `an invalid src varible has been passed: ${src} `)
self.log('warn', `an invalid src variable has been passed: ${src} `)
return undefined
}
cmd += src + addrSep + addrCmd.xpt
Expand All @@ -58,9 +59,9 @@ module.exports = function (self) {
self.addCmdtoQueue(cmd)
},
learn: async (action) => {
let dst = parseInt(await self.parseVariablesInString(action.options.dst))
const dst = parseInt(await self.parseVariablesInString(action.options.dst))
if (isNaN(dst) || dst < 1 || dst > self.config.dst) {
self.log('warn', `an invalid varible has been passed: ${dst}`)
self.log('warn', `an invalid variable has been passed: ${dst}`)
return undefined
}
const source = self.connections[dst]
Expand All @@ -70,35 +71,21 @@ module.exports = function (self) {
}
},
subscribe: async (action) => {
let cmd = SOM + control.reqInterrogate + appTag.crosspoint
let dst = parseInt(await self.parseVariablesInString(action.options.dst))
const dst = parseInt(await self.parseVariablesInString(action.options.dst))
if (isNaN(dst) || dst < 1 || dst > self.config.dst) {
self.log('warn', `an invalid varible has been passed: ${dst}`)
self.log('warn', `an invalid variable has been passed: ${dst}`)
return undefined
}
cmd += dst + paramSep + nullParam + addrSep + addrCmd.xpt
const cmd =
SOM + control.reqInterrogate + appTag.crosspoint + dst + paramSep + nullParam + addrSep + addrCmd.xpt
self.addCmdtoQueue(cmd)
let src = parseInt(await self.parseVariablesInString(action.options.src))
if (isNaN(src) || src < 0 || src > self.config.src) {
self.log('warn', `an invalid src varible has been passed: ${src} `)
return undefined
}
},
},
source_gain: {
name: 'Input - Gain',
description: 'Microphone Gain',
options: [
{
id: 'src',
type: 'dropdown',
label: 'Source',
default: 1,
choices: self.sources,
useVariables: true,
allowCustom: true,
tooltip: 'Varible must return an integer src number',
},
optionSrc,
{
id: 'gain',
type: 'dropdown',
Expand All @@ -107,34 +94,26 @@ module.exports = function (self) {
choices: self.crosspoint_gain,
useVariables: true,
allowCustom: true,
tooltip: 'Varible must return an integer gain number between 0 and 7',
tooltip: 'Variable must return an integer gain number between 0 and 7',
},
],
callback: async ({ options }) => {
let src = parseInt(await self.parseVariablesInString(options.src))
let gain = parseInt(await self.parseVariablesInString(options.gain))
const src = parseInt(await self.parseVariablesInString(options.src))
const gain = parseInt(await self.parseVariablesInString(options.gain))
if (isNaN(src) || src < 1 || src > self.config.src || isNaN(gain) || gain < 0 || gain > 7) {
self.log('warn', `an invalid varible has been passed: src: ${src} gain: ${gain}`)
self.log('warn', `an invalid variable has been passed: src: ${src} gain: ${gain}`)
return undefined
}
let cmd = SOM + control.reqGainSet + appTag.crosspoint + src + paramSep + options.gain + addrSep + addrCmd.gain
const cmd =
SOM + control.reqGainSet + appTag.crosspoint + src + paramSep + options.gain + addrSep + addrCmd.gain
self.addCmdtoQueue(cmd)
},
},
source_p48: {
name: 'Input - P48',
description: 'Microphone Phantom Power',
options: [
{
id: 'src',
type: 'dropdown',
label: 'Source',
default: 1,
choices: self.sources,
useVariables: true,
allowCustom: true,
tooltip: 'Varible must return an integer src number',
},
optionSrc,
{
id: 'p48',
type: 'dropdown',
Expand All @@ -146,29 +125,20 @@ module.exports = function (self) {
},
],
callback: async ({ options }) => {
let src = parseInt(await self.parseVariablesInString(options.src))
const src = parseInt(await self.parseVariablesInString(options.src))
if (isNaN(src) || src < 1 || src > self.config.src) {
self.log('warn', `an invalid varible has been passed: src: ${src}`)
self.log('warn', `an invalid variable has been passed: src: ${src}`)
return undefined
}
let cmd = SOM + control.reqP48Set + appTag.crosspoint + src + paramSep + options.p48 + addrSep + addrCmd.p48
const cmd = SOM + control.reqP48Set + appTag.crosspoint + src + paramSep + options.p48 + addrSep + addrCmd.p48
self.addCmdtoQueue(cmd)
},
},
source_delay: {
name: 'Input - Delay',
description: 'Input Delay',
options: [
{
id: 'src',
type: 'dropdown',
label: 'Source',
default: 1,
choices: self.sources,
useVariables: true,
allowCustom: true,
tooltip: 'Varible must return an integer src number',
},
optionSrc,
{
id: 'delay',
type: 'number',
Expand All @@ -181,12 +151,13 @@ module.exports = function (self) {
},
],
callback: async ({ options }) => {
let src = parseInt(await self.parseVariablesInString(options.src))
const src = parseInt(await self.parseVariablesInString(options.src))
if (isNaN(src) || src < 1 || src > self.config.src) {
self.log('warn', `an invalid varible has been passed: src: ${src}`)
self.log('warn', `an invalid variable has been passed: src: ${src}`)
return undefined
}
let cmd = SOM + control.reqDlySet + appTag.crosspoint + src + paramSep + options.delay + addrSep + addrCmd.delay
const cmd =
SOM + control.reqDlySet + appTag.crosspoint + src + paramSep + options.delay + addrSep + addrCmd.delay
self.addCmdtoQueue(cmd)
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/choices.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { control } = require('./consts.js')
module.exports = {
import { control } from './consts.js'
export const choices = {
crosspoint_gain: [
{ id: 0, label: '0dB' },
{ id: 1, label: '10dB' },
Expand Down
Loading

0 comments on commit a6b2f29

Please sign in to comment.