Skip to content

Commit 571d593

Browse files
committed
added scribble light on/off command
1 parent 39140b1 commit 571d593

File tree

2 files changed

+56
-7
lines changed

2 files changed

+56
-7
lines changed

src/actions/common.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ import { WingConfig } from '../config.js'
2222
import * as ActionUtil from './utils.js'
2323
import { StateUtil } from '../state/index.js'
2424
import { FadeDurationChoice } from '../choices/fades.js'
25+
import { getIdLabelPair } from '../choices/utils.js'
2526

2627
export enum CommonActions {
27-
SetColor = 'set-color',
28+
SetScribbleLight = 'set-scribble-light',
29+
SetScribbleLightColor = 'set-scribble-light-color',
2830
SetName = 'set-name',
31+
SetSolo = 'set-solo',
32+
ClearSolo = 'clear-solo',
2933
// Gain
3034
SetGain = 'set-gain',
3135
StoreGain = 'store-gain',
@@ -46,9 +50,7 @@ export enum CommonActions {
4650
RestorePanorama = 'restore-panorama',
4751
DeltaPanorama = 'panorama-delta',
4852
UndoDeltaPanorama = 'undo-panorama',
49-
// Solo
50-
SetSolo = 'set-solo',
51-
ClearSolo = 'clear-solo',
53+
5254
//////////// SEND
5355
SetSendMute = 'set-send-mute',
5456
// Send Fader
@@ -89,9 +91,40 @@ export function createCommonActions(self: InstanceBaseExt<WingConfig>): Companio
8991
const allSendSources = [...state.namedChoices.channels, ...state.namedChoices.auxes, ...state.namedChoices.busses]
9092

9193
const actions: { [id in CommonActions]: CompanionActionWithCallback | undefined } = {
92-
[CommonActions.SetColor]: {
93-
name: 'Set Color',
94-
description: 'Set the scribble strip color of a channel, aux, bus, matrix or main.',
94+
// TODO: add DCAs once merged
95+
[CommonActions.SetScribbleLight]: {
96+
name: 'Set Scribble Light',
97+
description: 'Set or toggle the scribble light state of a channel, aux, bus, matrix or main.',
98+
options: [
99+
GetDropdown('Selection', 'sel', [...allChannels]),
100+
GetDropdown(
101+
'Scribble Light',
102+
'led',
103+
[getIdLabelPair('1', 'On'), getIdLabelPair('0', 'Off'), getIdLabelPair('2', 'Toggle')],
104+
'1',
105+
),
106+
],
107+
callback: async (event) => {
108+
const sel = event.options.sel as string
109+
const cmd = ActionUtil.getScribblelightCommand(sel, getNodeNumber(event, 'sel'))
110+
const val = ActionUtil.getNumber(event, 'led')
111+
const currentVal = StateUtil.getBooleanFromState(cmd, state)
112+
if (val < 2) {
113+
send(cmd, val)
114+
} else {
115+
send(cmd, Number(!currentVal))
116+
}
117+
},
118+
subscribe: (event) => {
119+
const sel = event.options.sel as string
120+
const cmd = ActionUtil.getScribblelightCommand(sel, getNodeNumber(event, 'sel'))
121+
ensureLoaded(cmd)
122+
},
123+
},
124+
// TODO: add dca's
125+
[CommonActions.SetScribbleLightColor]: {
126+
name: 'Set Scribble Light Color',
127+
description: 'Set the scribble light color of a channel, aux, bus, matrix or main.',
95128
options: [GetDropdown('Selection', 'sel', allChannels), GetColorDropdown('color', 'Color')],
96129
callback: async (event) => {
97130
const sel = event.options.sel as string

src/actions/utils.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,19 @@ export function getMainSendMuteCommand(sel: string, src: number, dest: number):
234234
}
235235
return cmd
236236
}
237+
238+
export function getScribblelightCommand(sel: string, val: number): string {
239+
let cmd = ''
240+
if (sel.startsWith('/ch')) {
241+
cmd = ChannelCommands.ScribbleLight(val)
242+
} else if (sel.startsWith('/aux')) {
243+
cmd = AuxCommands.ScribbleLight(val)
244+
} else if (sel.startsWith('/bus')) {
245+
cmd = BusCommands.ScribbleLight(val)
246+
} else if (sel.startsWith('/mtx')) {
247+
cmd = MatrixCommands.ScribbleLight(val)
248+
} else if (sel.startsWith('/main')) {
249+
cmd = MainCommands.ScribbleLight(val)
250+
}
251+
return cmd
252+
}

0 commit comments

Comments
 (0)