Skip to content

Commit

Permalink
prodigy-mx: add test sources
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffhouse committed May 25, 2024
1 parent b198157 commit c121863
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/modules/prodigy-mx/container/services/group-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ module.exports = async (type = "source") => {
});
}

if (type === "source") {
groups.push({
label: `Test`,
value: range(1666, 6),
fixed: true,
});
}

// then overwrite labels with custom labels from config
groups = groups.map((group, index) => {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/prodigy-mx/container/services/source-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module.exports = async (destinationIndex = null, groupIndex = 0) => {
}

const inputLabels = await mongoSingle.get("input_labels");

if (inputLabels) {
outputArray["sources"] = inputLabels
.filter((labelItem, index) => validSources.includes(index))
Expand Down Expand Up @@ -80,6 +81,5 @@ module.exports = async (destinationIndex = null, groupIndex = 0) => {
// sort by order field
outputArray["sources"].sort((a, b) => (a.order > b.order ? 1 : -1));
}

return outputArray;
};
14 changes: 14 additions & 0 deletions src/modules/prodigy-mx/container/utils/update-inputlabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

const mongoSingle = require("@core/mongo-single");

const testLabels = [
[1666, "Sine Tone 1"],
[1667, "Sine Tone 2"],
[1668, "White Noise 1"],
[1669, "White Noise 2"],
[1670, "Pink Noise 1"],
[1671, "Pink Noise 2"],
];

module.exports = async (deviceData) => {
if (deviceData?.["settings"]?.["input_labels"]) {
let existingInputLabels = await mongoSingle.get("input_labels");
Expand All @@ -11,6 +20,11 @@ module.exports = async (deviceData) => {
for (let eachItem of deviceData?.["settings"]?.["input_labels"]) {
existingInputLabels[eachItem[0]] = eachItem;
}

// add the test sources to the array
existingInputLabels = existingInputLabels.concat(testLabels);

// and save it
return await mongoSingle.set("input_labels", existingInputLabels);
}
return false;
Expand Down
7 changes: 5 additions & 2 deletions src/modules/prodigy-mx/container/utils/update-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ const mongoSingle = require("@core/mongo-single");

const updateItem = (existingItemFromDb, valuesArray) => {
let existingItem = existingItemFromDb ?? [];
for (let eachItem of valuesArray) {
existingItem[eachItem[0]] = eachItem[1];

if (valuesArray) {
for (let eachItem of valuesArray) {
existingItem[eachItem[0]] = eachItem[1];
}
}
return existingItem;
};
Expand Down
2 changes: 1 addition & 1 deletion src/modules/prodigy-mx/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Control of the Prodigy MX audio router",
"capabilities": [],
"notes": "",
"version": "1.0.2",
"version": "1.0.3",
"icon": "Grid4x4",
"author": "Geoff House",
"license": "Apache-2.0",
Expand Down

0 comments on commit c121863

Please sign in to comment.