From 037d7aea89c2e1674de49c834447c00f1fcfc779 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Fri, 15 Feb 2019 22:38:29 +0100 Subject: [PATCH 01/10] added basic color integration into componentjs hotcuebutton --- res/controllers/midi-components-0.0.js | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 4e5dec43d168..01efbee7001a 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -290,6 +290,28 @@ print('ERROR: No hotcue number specified for new HotcueButton.'); return; } + if (options.sendRGB !== undefined || options.colors !== undefined) { + print("COLORS ENABLED for component "+options.number); + this.colorIdKey = 'hotcue_' + this.number + '_color_id'; + if (options.colors === undefined) { + options.colors = color.predefinedColorsList(); + } + this.output = function (value, group, control) { + this.colorOutput(value) + }; + this.connect = function () { + print("CALLED CONNECT"); + if (undefined !== this.group && + undefined !== this.outKey && + undefined !== this.output && + typeof this.output === 'function') { + this.connections[0] = engine.makeConnection(this.group, this.outKey, this.output); + } + if (undefined !== this.group) { + this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, this.output); + } + }; + } this.number = options.number; this.outKey = 'hotcue_' + this.number + '_enabled'; Button.call(this, options); @@ -301,6 +323,31 @@ shift: function () { this.inKey = 'hotcue_' + this.number + '_clear'; }, + getColor: function () { + return color.jsColorFrom(engine.getValue(this.group,this.colorIdKey)) + }, + colorOutput: function (value) { + print("called colorOutput with "+value); + if (value > 0) { + var id = engine.getValue(this.group,this.colorIdKey) + var color = options.colors[id] + if (color instanceof Array) { + if (color.length !== 3) { + print("invalid color array for id: "+id); + return; + } + if (this.sendRGB === undefined) { + print("no custom method for sending rgb defined!"); + return; + } + this.sendRGB(color); + } else if (typeof color === 'number') { + this.send(color); + } + } else { + this.send(this.off); + } + }, }); var SamplerButton = function (options) { From 706aff5861d041cfb57285e5100b477279240fd0 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Fri, 15 Feb 2019 23:02:44 +0100 Subject: [PATCH 02/10] split hotcuecolor functionality into child object to simplify code --- res/controllers/midi-components-0.0.js | 95 +++++++++++++------------- 1 file changed, 49 insertions(+), 46 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 01efbee7001a..405c192ea37d 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -290,28 +290,6 @@ print('ERROR: No hotcue number specified for new HotcueButton.'); return; } - if (options.sendRGB !== undefined || options.colors !== undefined) { - print("COLORS ENABLED for component "+options.number); - this.colorIdKey = 'hotcue_' + this.number + '_color_id'; - if (options.colors === undefined) { - options.colors = color.predefinedColorsList(); - } - this.output = function (value, group, control) { - this.colorOutput(value) - }; - this.connect = function () { - print("CALLED CONNECT"); - if (undefined !== this.group && - undefined !== this.outKey && - undefined !== this.output && - typeof this.output === 'function') { - this.connections[0] = engine.makeConnection(this.group, this.outKey, this.output); - } - if (undefined !== this.group) { - this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, this.output); - } - }; - } this.number = options.number; this.outKey = 'hotcue_' + this.number + '_enabled'; Button.call(this, options); @@ -323,33 +301,57 @@ shift: function () { this.inKey = 'hotcue_' + this.number + '_clear'; }, - getColor: function () { - return color.jsColorFrom(engine.getValue(this.group,this.colorIdKey)) - }, - colorOutput: function (value) { - print("called colorOutput with "+value); - if (value > 0) { - var id = engine.getValue(this.group,this.colorIdKey) - var color = options.colors[id] - if (color instanceof Array) { - if (color.length !== 3) { - print("invalid color array for id: "+id); - return; - } - if (this.sendRGB === undefined) { - print("no custom method for sending rgb defined!"); - return; - } - this.sendRGB(color); - } else if (typeof color === 'number') { - this.send(color); + }); + + var HotcueColorButton = function (options) { + if (options.sendRGB === undefined && options.colors === undefined) { + print("ERROR: no color palette or sendRGB method defined"); + return; + } + if (options.colors === undefined) { + options.colors = color.predefinedColorsList(); + } + this.colorIdKey = 'hotcue_' + options.number + '_color_id'; + print(this.colorIdKey); + HotcueButton.call(this, options); + } + HotcueColorButton.prototype = new HotcueButton({ + getColor: function () { + return color.jsColorFrom(engine.getValue(this.group,this.colorIdKey)) + }, + output: function (value) { + if (value > 0) { + var id = engine.getValue(this.group,this.colorIdKey) + var color = options.colors[id] + if (color instanceof Array) { + if (color.length !== 3) { + print("invalid color array for id: "+id); + return; } - } else { - this.send(this.off); + if (this.sendRGB === undefined) { + print("no custom method for sending rgb defined!"); + return; + } + this.sendRGB(color); + } else if (typeof color === 'number') { + this.send(color); } - }, + } else { + this.send(this.off); + } + }, + connect: function () { + if (undefined !== this.group && + undefined !== this.outKey && + undefined !== this.output && + typeof this.output === 'function') { + this.connections[0] = engine.makeConnection(this.group, this.outKey, this.output); + } + if (undefined !== this.group) { + this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, this.output); + } + }, }); - var SamplerButton = function (options) { if (options.number === undefined) { print('ERROR: No sampler number specified for new SamplerButton.'); @@ -1093,6 +1095,7 @@ exports.SyncButton = SyncButton; exports.LoopToggleButton = LoopToggleButton; exports.HotcueButton = HotcueButton; + exports.HotcueColorButton = HotcueColorButton; exports.SamplerButton = SamplerButton; exports.EffectAssignmentButton = EffectAssignmentButton; exports.Pot = Pot; From fdc2bf9957c705f367c24608ef514ac602cf8e1e Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Sat, 16 Feb 2019 00:09:30 +0100 Subject: [PATCH 03/10] improved error messages; removed debug statements --- res/controllers/midi-components-0.0.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 405c192ea37d..4dabfe83cc1a 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -312,7 +312,6 @@ options.colors = color.predefinedColorsList(); } this.colorIdKey = 'hotcue_' + options.number + '_color_id'; - print(this.colorIdKey); HotcueButton.call(this, options); } HotcueColorButton.prototype = new HotcueButton({ @@ -322,14 +321,14 @@ output: function (value) { if (value > 0) { var id = engine.getValue(this.group,this.colorIdKey) - var color = options.colors[id] + var color = this.colors[id] if (color instanceof Array) { if (color.length !== 3) { - print("invalid color array for id: "+id); + print("ERROR: invalid color array for id: "+id); return; } if (this.sendRGB === undefined) { - print("no custom method for sending rgb defined!"); + print("ERROR: no custom method for sending rgb defined!"); return; } this.sendRGB(color); From 1fd3f0a03863e8fae2335a477ce5ac03229aae26 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Sun, 17 Feb 2019 12:36:55 +0100 Subject: [PATCH 04/10] fixed inconsistent indentation --- res/controllers/midi-components-0.0.js | 86 +++++++++++++------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 4dabfe83cc1a..7a8f831f6d53 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -303,53 +303,53 @@ }, }); - var HotcueColorButton = function (options) { - if (options.sendRGB === undefined && options.colors === undefined) { - print("ERROR: no color palette or sendRGB method defined"); - return; - } - if (options.colors === undefined) { - options.colors = color.predefinedColorsList(); - } - this.colorIdKey = 'hotcue_' + options.number + '_color_id'; - HotcueButton.call(this, options); + var HotcueColorButton = function(options) { + if (options.sendRGB === undefined && options.colors === undefined) { + print("ERROR: no color palette or sendRGB method defined"); + return; + } + if (options.colors === undefined) { + options.colors = color.predefinedColorsList(); + } + this.colorIdKey = 'hotcue_' + options.number + '_color_id'; + HotcueButton.call(this, options); } HotcueColorButton.prototype = new HotcueButton({ - getColor: function () { - return color.jsColorFrom(engine.getValue(this.group,this.colorIdKey)) - }, - output: function (value) { - if (value > 0) { - var id = engine.getValue(this.group,this.colorIdKey) - var color = this.colors[id] - if (color instanceof Array) { - if (color.length !== 3) { - print("ERROR: invalid color array for id: "+id); - return; - } - if (this.sendRGB === undefined) { - print("ERROR: no custom method for sending rgb defined!"); - return; + getColor: function() { + return color.jsColorFrom(engine.getValue(this.group, this.colorIdKey)) + }, + output: function(value) { + if (value > 0) { + var id = engine.getValue(this.group, this.colorIdKey) + var color = this.colors[id] + if (color instanceof Array) { + if (color.length !== 3) { + print("ERROR: invalid color array for id: " + id); + return; + } + if (this.sendRGB === undefined) { + print("ERROR: no custom method for sending rgb defined!"); + return; + } + this.sendRGB(color); + } else if (typeof color === 'number') { + this.send(color); } - this.sendRGB(color); - } else if (typeof color === 'number') { - this.send(color); + } else { + this.send(this.off); } - } else { - this.send(this.off); - } - }, - connect: function () { - if (undefined !== this.group && - undefined !== this.outKey && - undefined !== this.output && - typeof this.output === 'function') { - this.connections[0] = engine.makeConnection(this.group, this.outKey, this.output); - } - if (undefined !== this.group) { - this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, this.output); - } - }, + }, + connect: function() { + if (undefined !== this.group && + undefined !== this.outKey && + undefined !== this.output && + typeof this.output === 'function') { + this.connections[0] = engine.makeConnection(this.group, this.outKey, this.output); + } + if (undefined !== this.group) { + this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, this.output); + } + }, }); var SamplerButton = function (options) { if (options.number === undefined) { From c0a7e133dff5cc6efa219fdc50a46b0fc66eaa0a Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Sun, 3 Mar 2019 12:18:31 +0100 Subject: [PATCH 05/10] fixed getColor; was using a not exposed API method --- res/controllers/midi-components-0.0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 7a8f831f6d53..1469ada6c5d5 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -316,7 +316,7 @@ } HotcueColorButton.prototype = new HotcueButton({ getColor: function() { - return color.jsColorFrom(engine.getValue(this.group, this.colorIdKey)) + return color.predefinedColorFromId(engine.getValue(this.group, this.colorIdKey)); }, output: function(value) { if (value > 0) { From 86a745fa42f4e8a62cc37ab66fe122be750c81d2 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Mon, 4 Mar 2019 21:36:15 +0100 Subject: [PATCH 06/10] consolidated hotcuecolorbutton and regular hotcuebutton into same class --- res/controllers/midi-components-0.0.js | 81 +++++++++++++------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 1469ada6c5d5..777d38737a94 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -290,6 +290,14 @@ print('ERROR: No hotcue number specified for new HotcueButton.'); return; } + if (options.colors !== undefined || options.sendRGB !== undefined) { + + this.colorIdKey = 'hotcue_' + options.number + '_color_id'; + + if (options.colors === undefined) { + options.colors = color.predefinedColorsList(); + } + } this.number = options.number; this.outKey = 'hotcue_' + this.number + '_enabled'; Button.call(this, options); @@ -301,53 +309,45 @@ shift: function () { this.inKey = 'hotcue_' + this.number + '_clear'; }, - }); - - var HotcueColorButton = function(options) { - if (options.sendRGB === undefined && options.colors === undefined) { - print("ERROR: no color palette or sendRGB method defined"); - return; - } - if (options.colors === undefined) { - options.colors = color.predefinedColorsList(); - } - this.colorIdKey = 'hotcue_' + options.number + '_color_id'; - HotcueButton.call(this, options); - } - HotcueColorButton.prototype = new HotcueButton({ getColor: function() { - return color.predefinedColorFromId(engine.getValue(this.group, this.colorIdKey)); + if (this.colorIdKey !== undefined) { + return color.predefinedColorFromId(engine.getValue(this.group,this.colorIdKey)); + } else { + return false; + } }, output: function(value) { - if (value > 0) { - var id = engine.getValue(this.group, this.colorIdKey) - var color = this.colors[id] - if (color instanceof Array) { - if (color.length !== 3) { - print("ERROR: invalid color array for id: " + id); - return; - } - if (this.sendRGB === undefined) { - print("ERROR: no custom method for sending rgb defined!"); - return; - } - this.sendRGB(color); - } else if (typeof color === 'number') { - this.send(color); - } + var outval = this.outValueScale(value); + if (this.colorIdKey !== undefined && outval !== this.off) { + this.outputColor(engine.getValue(this.group, this.colorIdKey)); } else { - this.send(this.off); + this.send(outval); } }, - connect: function() { - if (undefined !== this.group && - undefined !== this.outKey && - undefined !== this.output && - typeof this.output === 'function') { - this.connections[0] = engine.makeConnection(this.group, this.outKey, this.output); + outputColor: function (id) { + var color = this.colors[id]; + if (color instanceof Array) { + if (color.length !== 3) { + print("ERROR: invalid color array for id: " + id); + return; + } + if (this.sendRGB === undefined) { + print("ERROR: no custom method for sending rgb defined!"); + return; + } + this.sendRGB(color); + } else if (typeof color === 'number') { + this.send(color); } - if (undefined !== this.group) { - this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, this.output); + }, + connect: function() { + Button.prototype.connect.call(this); // call parent connect + if (undefined !== this.group && this.colorIdKey !== undefined) { + this.connections.push(engine.makeConnection(this.group, this.colorIdKey, function (id) { + if (engine.getValue(this.group,this.outKey)) { + this.outputColor(id); + } + })); } }, }); @@ -1094,7 +1094,6 @@ exports.SyncButton = SyncButton; exports.LoopToggleButton = LoopToggleButton; exports.HotcueButton = HotcueButton; - exports.HotcueColorButton = HotcueColorButton; exports.SamplerButton = SamplerButton; exports.EffectAssignmentButton = EffectAssignmentButton; exports.Pot = Pot; From fb7f058ad9224fc3e99b08a6c0b01c4144e58434 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Thu, 2 May 2019 19:56:33 +0200 Subject: [PATCH 07/10] Implemented changes from Be's latest Review. --- res/controllers/midi-components-0.0.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 777d38737a94..0c754c0d6bc3 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -313,7 +313,7 @@ if (this.colorIdKey !== undefined) { return color.predefinedColorFromId(engine.getValue(this.group,this.colorIdKey)); } else { - return false; + return null; } }, output: function(value) { @@ -332,7 +332,7 @@ return; } if (this.sendRGB === undefined) { - print("ERROR: no custom method for sending rgb defined!"); + print("ERROR: no function defined for sending RGB colors"); return; } this.sendRGB(color); From 552d625d4ad0378df5f782528d9c6adbb1b7c427 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Tue, 11 Jun 2019 12:15:43 +0200 Subject: [PATCH 08/10] replaced connections.push(); deleted some blank lines --- res/controllers/midi-components-0.0.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 0c754c0d6bc3..342045728dc9 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -291,9 +291,7 @@ return; } if (options.colors !== undefined || options.sendRGB !== undefined) { - this.colorIdKey = 'hotcue_' + options.number + '_color_id'; - if (options.colors === undefined) { options.colors = color.predefinedColorsList(); } @@ -343,11 +341,11 @@ connect: function() { Button.prototype.connect.call(this); // call parent connect if (undefined !== this.group && this.colorIdKey !== undefined) { - this.connections.push(engine.makeConnection(this.group, this.colorIdKey, function (id) { + this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, function (id) { if (engine.getValue(this.group,this.outKey)) { this.outputColor(id); } - })); + }); } }, }); From 810e1ea9ede28edb102c79288739bc8676a03aac Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Mon, 8 Jul 2019 22:05:53 +0200 Subject: [PATCH 09/10] added comment about using send & outputColor --- res/controllers/midi-components-0.0.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 342045728dc9..5d3106cbcc14 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -316,6 +316,10 @@ }, output: function(value) { var outval = this.outValueScale(value); + // WARNING: outputColor only handles hotcueColors + // and there is no hotcueColor for turning the controller + // off. so s`send()` is responsible for turning the + // actual LED off. if (this.colorIdKey !== undefined && outval !== this.off) { this.outputColor(engine.getValue(this.group, this.colorIdKey)); } else { From 9f029aa1d0892be481ec368db83b1911129e1ed4 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Wed, 10 Jul 2019 16:39:28 +0200 Subject: [PATCH 10/10] Fixed Typos Co-Authored-By: Be --- res/controllers/midi-components-0.0.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 5d3106cbcc14..de21bc40993e 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -317,8 +317,8 @@ output: function(value) { var outval = this.outValueScale(value); // WARNING: outputColor only handles hotcueColors - // and there is no hotcueColor for turning the controller - // off. so s`send()` is responsible for turning the + // and there is no hotcueColor for turning the LED + // off. So the `send()` function is responsible for turning the // actual LED off. if (this.colorIdKey !== undefined && outval !== this.off) { this.outputColor(engine.getValue(this.group, this.colorIdKey));