Skip to content

Commit 2b4af27

Browse files
committed
added color choices for AES status feedback
1 parent c249974 commit 2b4af27

File tree

2 files changed

+28
-39
lines changed

2 files changed

+28
-39
lines changed

src/choices/common.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
combineRgb,
32
CompanionInputFieldDropdown,
43
CompanionInputFieldNumber,
54
CompanionInputFieldTextInput,
@@ -414,40 +413,6 @@ export function getTimeFormatChoices(): DropdownChoice[] {
414413
]
415414
}
416415

417-
export function getTriStateColor(
418-
text: string | undefined,
419-
okText?: string,
420-
errorText?: string,
421-
okColor?: number,
422-
errorColor?: number,
423-
thirdColor?: number,
424-
): number {
425-
if (text == (okText ?? 'OK')) {
426-
return okColor ?? combineRgb(0, 255, 0)
427-
} else if (text == (errorText ?? 'ERR')) {
428-
return errorColor ?? combineRgb(255, 0, 0)
429-
} else {
430-
return thirdColor ?? combineRgb(255, 255, 0)
431-
}
432-
}
433-
434-
export function getTriStateTextColor(
435-
text: string | undefined,
436-
okText?: string,
437-
errorText?: string,
438-
okColor?: number,
439-
errorColor?: number,
440-
thirdColor?: number,
441-
): number {
442-
if (text == (okText ?? 'OK')) {
443-
return okColor ?? combineRgb(0, 0, 0)
444-
} else if (text == (errorText ?? 'ERR')) {
445-
return errorColor ?? combineRgb(255, 255, 255)
446-
} else {
447-
return thirdColor ?? combineRgb(0, 0, 0)
448-
}
449-
}
450-
451416
export function getDelayModes(): DropdownChoice[] {
452417
return [
453418
getIdLabelPair('M', 'Meters'),

src/feedbacks.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
CompanionFeedbackInfo,
1212
} from '@companion-module/base'
1313
// import { compareNumber, GetDropdownFeedback, GetNumberComparator, GetPanoramaSliderFeedback } from './choices/common.js'
14-
import { GetDropdown, GetMuteDropdown, getTriStateColor, getTriStateTextColor } from './choices/common.js'
14+
import { GetDropdown, GetMuteDropdown } from './choices/common.js'
1515
import { getTalkbackOptions } from './choices/config.js'
1616
import { ConfigurationCommands } from './commands/config.js'
1717
import { getNodeNumber } from './actions/utils.js'
@@ -136,13 +136,37 @@ export function GetFeedbacksList(
136136
getIdLabelPair('B', 'AES B'),
137137
getIdLabelPair('C', 'AES C'),
138138
]),
139+
{
140+
type: 'colorpicker',
141+
id: 'okcolor',
142+
label: 'Ok',
143+
tooltip: 'Color of the button when an AES connection is OK',
144+
default: combineRgb(0, 255, 0),
145+
},
146+
{
147+
type: 'colorpicker',
148+
id: 'errcolor',
149+
label: 'Error',
150+
tooltip: 'Color of the button when an AES connection is not OK',
151+
default: combineRgb(255, 0, 0),
152+
},
153+
{
154+
type: 'colorpicker',
155+
id: 'nccolor',
156+
label: 'Not Connected',
157+
tooltip: 'Color of the button when the status of an AES connection is unknown/not connected.',
158+
default: combineRgb(0, 0, 0),
159+
},
139160
],
140161
callback: (event: CompanionFeedbackInfo): CompanionAdvancedFeedbackResult => {
141162
const cmd = StatusCommands.AesStatus(event.options.aes as string)
142163
const val = StateUtil.getStringFromState(cmd, state)
143-
return {
144-
bgcolor: getTriStateColor(val),
145-
color: getTriStateTextColor(val),
164+
if (val == 'OK') {
165+
return event.options.okcolor as CompanionAdvancedFeedbackResult
166+
} else if (val == 'ERR') {
167+
return event.options.errcolor as CompanionAdvancedFeedbackResult
168+
} else {
169+
return event.options.nccolor as CompanionAdvancedFeedbackResult
146170
}
147171
},
148172
subscribe: (event): void => {

0 commit comments

Comments
 (0)