Skip to content

Commit

Permalink
Optimize source name propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveBenham committed Oct 7, 2024
1 parent 3479425 commit 87a2204
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
- Square Full PWM shape option color changed from blue to orange to match new VCO Unit module

### Bug Fix
- Bay Modules
- Fix crash on some platforms when a linked Bay Input is deleted.
- Benjolin Gates Expander
- Fix LED gate indicators broken in v2.9.1
- Bypass
Expand Down
32 changes: 22 additions & 10 deletions src/BayModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct BayModule : VenomModule {

static std::map<int64_t, BayInput*> sources;
std::string modName;
std::string defaultPortName[8]{"Port 1","Port 2","Port 3","Port 4","Port 5","Port 6","Port 7","Port 8"};
std::string defaultNormalName[8]{"Port 1 normal","Port 2 normal","Port 3 normal","Port 4 normal","Port 5 normal","Port 6 normal","Port 7 normal","Port 8 normal"};

};

Expand All @@ -35,7 +37,7 @@ struct BayInput : BayModule {
BayInput() {
venomConfig(PARAMS_LEN, INPUTS_LEN, 0, LIGHTS_LEN);
for (int i=0; i < INPUTS_LEN; i++) {
configInput(POLY_INPUT+i, string::f("Port %d", i + 1));
configInput(POLY_INPUT+i, defaultPortName[i]);
}
modName = "Bay Input";
}
Expand Down Expand Up @@ -197,19 +199,29 @@ struct BayOutputModule : BayModule {
PortInfo* oi = outputInfos[i];
PortExtension* oe = &outputExtensions[i];
bool propagate = (oi->name == oe->factoryName);
if (srcMod)
oe->factoryName = srcMod->inputInfos[i]->name;
else
oe->factoryName = string::f("Port %d", i+1);
if (propagate)
oi->name = oe->factoryName;
if (srcMod) {
if (oe->factoryName != srcMod->inputInfos[i]->name) {
oe->factoryName = srcMod->inputInfos[i]->name;
if (propagate)
oi->name = oe->factoryName;
}
}
else {
if (oe->factoryName != defaultPortName[i]) {
oe->factoryName = defaultPortName[i];
if (propagate)
oi->name = oe->factoryName;
}
}
if (bayOutputType) {
PortInfo* ii = inputInfos[i];
PortExtension* ie = &inputExtensions[i];
propagate = (ii->name == ie->factoryName);
ie->factoryName = oi->name + " normal";
if (propagate)
ii->name = ie->factoryName;
if (ie->factoryName != oi->name + "normal") {
ie->factoryName = oi->name + " normal";
if (propagate)
ii->name = ie->factoryName;
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/BayNorm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include "BayModule.hpp"

struct BayNorm : BayOutputModule {

BayNorm() {
venomConfig(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN);
for (int i=0; i < OUTPUTS_LEN; i++) {
configInput(POLY_INPUT+i, string::f("Port %d normal", i + 1));
configOutput(POLY_OUTPUT+i, string::f("Port %d", i + 1));
configInput(POLY_INPUT+i, defaultPortName[i]);
configOutput(POLY_OUTPUT+i, defaultNormalName[i]);
modName = "Bay Norm";
}
clockDivider.setDivision(32);
Expand Down
4 changes: 2 additions & 2 deletions src/BayOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#include "BayModule.hpp"

struct BayOutput : BayOutputModule {

BayOutput() {
venomConfig(PARAMS_LEN, 0, OUTPUTS_LEN, LIGHTS_LEN);
for (int i=0; i < OUTPUTS_LEN; i++) {
configOutput(POLY_OUTPUT+i, string::f("Port %d", i + 1));
configOutput(POLY_OUTPUT+i, defaultPortName[i]);
modName = "Bay Output";
}
clockDivider.setDivision(32);
Expand Down

0 comments on commit 87a2204

Please sign in to comment.