diff --git a/feedbacks.js b/feedbacks.js index 7fb6e3258dfe9827e74234adcc9506838ec0c8db..531f879e9f8baf1c040d516516b5b88cced9aedd 100644 --- a/feedbacks.js +++ b/feedbacks.js @@ -1,33 +1,45 @@ -const { combineRgb } = require('@companion-module/base') +const {combineRgb} = require('@companion-module/base') module.exports = async function (self) { - self.setFeedbackDefinitions({ - PadStatus: { - name: 'Pad Status', - type: 'boolean', - label: 'Pad Status', - defaultStyle: { - bgcolor: combineRgb(255, 0, 0), - color: combineRgb(0, 0, 0), - }, - options: [ - { - id: 'name', - type: 'textinput', - label: 'Pad Name', - default: '', - }, - ], - callback: (feedback, context) => { + self.setFeedbackDefinitions({ + PadStatus: { + name: 'Pad Status', + type: 'advanced', + label: 'Pad Status', + options: [ + { + id: 'name', + type: 'textinput', + label: 'Pad Name', + default: '', + }, + ], + callback: (feedback, context) => { self.log('debug', `Update feedback for pad name ${feedback.options.name}`); - const pad = self.currentProject.findPadByName(feedback.options.name); + const pad = self.currentProject.findPadByName(feedback.options.name); if (pad != null) { self.log('debug', `Update feedback for pad id ${pad.id} with status ${pad.status}`); - return pad.status === 'PLAY'; + if (pad.status === 'PLAY') { + return { + bgcolor: hexStringToNumber(pad.design.play.hi), + color: hexStringToNumber(pad.design.play.font) + }; + } else { + return { + bgcolor: hexStringToNumber(pad.design.normal.hi), + color: hexStringToNumber(pad.design.normal.font) + }; + } } else { - return false; + return { + bgcolor: combineRgb(0, 0, 0) + }; } - }, - }, - }) + }, + }, + }) +} + +function hexStringToNumber(string) { + return parseInt(string.replace(/^#/, ''), 16) } diff --git a/receive/project_update.js b/receive/project_update.js index 80a9ebebb94a593cad754d7e7253cb75ca0b5c8a..352005556680d300cca46bfde333e772585cb7bc 100644 --- a/receive/project_update.js +++ b/receive/project_update.js @@ -5,5 +5,6 @@ module.exports = class ProjectUpdate extends MessageExecutable { handleMessage(plugin, message) { plugin.currentProject = new Project(message) + plugin.checkFeedbacks(); } } \ No newline at end of file