Skip to content

Commit 50ec494

Browse files
committed
Only allow Arduinos to be selected in ArduinoOutput plugin
1 parent d9fc3cc commit 50ec494

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

Plugins/ArduinoOutput/ArduinoOutput.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
ArduinoOutput::ArduinoOutput()
3030
: GenericProcessor ("Arduino Output"), gateIsOpen (true), deviceSelected (false)
3131
{
32+
devices = getDevices();
3233
}
3334

3435
ArduinoOutput::~ArduinoOutput()
@@ -39,10 +40,12 @@ ArduinoOutput::~ArduinoOutput()
3940

4041
void ArduinoOutput::registerParameters()
4142
{
42-
addCategoricalParameter (Parameter::PROCESSOR_SCOPE, "device", "Device", "The Arduino device to use", getDevices(), 0, true);
43+
addCategoricalParameter (Parameter::PROCESSOR_SCOPE, "device", "Device", "The Arduino device to use", devices, 0, true);
4344
addIntParameter (Parameter::PROCESSOR_SCOPE, "output_pin", "Output pin", "The Arduino pin to use", 13, 0, 13);
4445
addIntParameter (Parameter::STREAM_SCOPE, "input_line", "Input line", "The TTL line for triggering output", 1, 1, 16);
4546
addIntParameter (Parameter::STREAM_SCOPE, "gate_line", "Gate line", "The TTL line for gating the output", 0, 0, 16);
47+
48+
setDevice (devices[0], true);
4649
}
4750

4851
AudioProcessorEditor* ArduinoOutput::createEditor()
@@ -59,13 +62,17 @@ Array<String> ArduinoOutput::getDevices()
5962

6063
for (int i = 0; i < devices.size(); i++)
6164
{
62-
out.add (devices[i].getDevicePath());
65+
if (devices[i].getDeviceName().compare(0, 7, "Arduino") == 0)
66+
{
67+
out.add (devices[i].getDevicePath());
68+
}
69+
6370
}
6471

6572
return out;
6673
}
6774

68-
void ArduinoOutput::setDevice (String devName)
75+
void ArduinoOutput::setDevice (String devName, bool initializing)
6976
{
7077
LOGC ("Selecting device ", devName);
7178

@@ -122,7 +129,12 @@ void ArduinoOutput::setDevice (String devName)
122129
CoreServices::sendStatusMessage (("Arduino could not be initialized at " + devName));
123130
deviceSelected = false;
124131
}
125-
CoreServices::updateSignalChain (this);
132+
133+
if (!initializing)
134+
{
135+
CoreServices::updateSignalChain (this);
136+
}
137+
126138
}
127139

128140
void ArduinoOutput::updateSettings()

Plugins/ArduinoOutput/ArduinoOutput.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class ArduinoOutput : public GenericProcessor
7171
Array<String> getDevices();
7272

7373
/** Tries to connect to an Arduino on a given port*/
74-
void setDevice (String deviceString);
74+
void setDevice (String deviceString, bool initializing = false);
7575

7676
private:
7777
/** Opens the serial connection to the Arduino. */
@@ -84,6 +84,7 @@ class ArduinoOutput : public GenericProcessor
8484
bool deviceSelected;
8585

8686
String deviceString;
87+
Array<String> devices;
8788

8889
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ArduinoOutput);
8990
};

0 commit comments

Comments
 (0)