Skip to content

Commit e1844ff

Browse files
committed
Updated editor
- Shows options for both ports - Added combo box for available headstages - Removed the voltage value from automatically appearing, added a tooltip indicating that it is a voltage override
1 parent a0d200e commit e1844ff

File tree

6 files changed

+116
-72
lines changed

6 files changed

+116
-72
lines changed

Source/Devices/Neuropixels_1.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void BackgroundUpdaterWithProgressWindow::run()
122122
result = 0;
123123
}
124124

125-
Neuropixels_1::Neuropixels_1(String name, float portVoltage, OnixSource* s, const oni_dev_idx_t deviceIdx_, const oni_ctx ctx_) :
125+
Neuropixels_1::Neuropixels_1(String name, OnixSource* s, const oni_dev_idx_t deviceIdx_, const oni_ctx ctx_) :
126126
OnixDevice(name, OnixDeviceType::NEUROPIXELS_1, deviceIdx_, ctx_),
127127
I2CRegisterContext(ProbeI2CAddress, deviceIdx_, ctx_),
128128
source(s)
@@ -149,9 +149,6 @@ Neuropixels_1::Neuropixels_1(String name, float portVoltage, OnixSource* s, cons
149149
lfpStream.channelType = ContinuousChannel::Type::ELECTRODE;
150150
streams.add(lfpStream);
151151

152-
if (portVoltage >= minVoltage && portVoltage <= maxVoltage)
153-
portVoltage_ = portVoltage;
154-
155152
defineMetadata(settings);
156153

157154
// Set parameters

Source/Devices/Neuropixels_1.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class Neuropixels_1 : public OnixDevice,
157157
{
158158
public:
159159
/** Constructor */
160-
Neuropixels_1(String name, float portVoltage, OnixSource* s, const oni_dev_idx_t, const oni_ctx);
160+
Neuropixels_1(String name, OnixSource* s, const oni_dev_idx_t, const oni_ctx);
161161

162162
/** Destructor */
163163
~Neuropixels_1();
@@ -253,11 +253,6 @@ class Neuropixels_1 : public OnixDevice,
253253
int apSampleNumber = 0;
254254
int lfpSampleNumber = 0;
255255

256-
float portVoltage_ = 5.0;
257-
258-
const float minVoltage = 4.5;
259-
const float maxVoltage = 6.5;
260-
261256
OnixSource* source;
262257
};
263258

Source/OnixSource.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ OnixSource::OnixSource(SourceNode* sn) :
3030
devicesFound(false),
3131
editor(NULL)
3232
{
33-
addBooleanParameter(Parameter::PROCESSOR_SCOPE, "is_passthrough_A", "Passthrough Mode", "Enables passthrough mode for e-variant headstages", false, true);
33+
addBooleanParameter(Parameter::PROCESSOR_SCOPE, "passthroughA", "Passthrough", "Enables passthrough mode for e-variant headstages on Port A", false, true);
34+
addBooleanParameter(Parameter::PROCESSOR_SCOPE, "passthroughB", "Passthrough", "Enables passthrough mode for e-variant headstages on Port B", false, true);
3435

3536
addBooleanParameter(Parameter::PROCESSOR_SCOPE, "connected", "Connect", "Connect to Onix hardware", false, true);
3637

@@ -172,7 +173,7 @@ void OnixSource::initializeDevices(bool updateStreamInfo)
172173
{
173174
if (devices[dev_idx].id == ONIX_NEUROPIX1R0)
174175
{
175-
auto np1 = std::make_unique<Neuropixels_1>("Probe-" + String::charToString(probeLetters[npxProbeIdx]), editor->portVoltage, this, devices[dev_idx].idx, ctx);
176+
auto np1 = std::make_unique<Neuropixels_1>("Probe-" + String::charToString(probeLetters[npxProbeIdx]), this, devices[dev_idx].idx, ctx);
176177

177178
int res = np1->enableDevice();
178179

Source/OnixSourceEditor.cpp

Lines changed: 94 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -25,67 +25,88 @@
2525
#include "OnixSource.h"
2626

2727
OnixSourceEditor::OnixSourceEditor(GenericProcessor* parentNode, OnixSource* onixSource)
28-
: VisualizerEditor(parentNode, "Onix Source"), thread(onixSource)
28+
: VisualizerEditor(parentNode, "Onix Source", 200), thread(onixSource)
2929
{
3030
canvas = nullptr;
3131

32-
desiredWidth = 200;
33-
34-
portVoltageLabel = std::make_unique<Label>("Voltage", "PORT VOLTAGE [V]");
35-
portVoltageLabel->setBounds(5, 20, 85, 20);
36-
portVoltageLabel->setFont(FontOptions("Fira Code", "Regular", 11.0f));
37-
portVoltageLabel->setColour(Label::textColourId, Colours::black);
38-
addAndMakeVisible(portVoltageLabel.get());
39-
40-
portVoltage = 5.0f;
41-
portVoltageValue = std::make_unique<Label>("VoltageValue", String(portVoltage));
42-
portVoltageValue->setBounds(10, 38, 30, 13);
43-
portVoltageValue->setFont(FontOptions("Fira Code", "Regular", 11.0f));
44-
portVoltageValue->setEditable(true);
45-
portVoltageValue->setColour(Label::textColourId, Colours::black);
46-
portVoltageValue->setColour(Label::backgroundColourId, Colours::lightgrey);
47-
portVoltageValue->addListener(this);
48-
addAndMakeVisible(portVoltageValue.get());
49-
50-
connectButton = std::make_unique<UtilityButton>("Connect");
51-
connectButton->setFont(FontOptions("Fira Code", "Regular", 11.0f));
52-
connectButton->setBounds(10, 95, 65, 20);
32+
FontOptions fontOptionSmall = FontOptions("Fira Code", "Regular", 12.0f);
33+
FontOptions fontOptionTitle = FontOptions("Fira Code", "Bold", 15.0f);
34+
35+
portLabelA = std::make_unique<Label>("portLabelA", "Port A:");
36+
portLabelA->setBounds(4, 25, 60, 16);
37+
portLabelA->setFont(fontOptionTitle);
38+
addAndMakeVisible(portLabelA.get());
39+
40+
headstageComboBoxA = std::make_unique<ComboBox>("headstageComboBoxA");
41+
headstageComboBoxA->setBounds(portLabelA->getRight() + 2, portLabelA->getY(), 120, portLabelA->getHeight());
42+
headstageComboBoxA->addListener(this);
43+
headstageComboBoxA->setTooltip("Select the headstage connected to port A.");
44+
headstageComboBoxA->addItem("Select headstage...", 1);
45+
headstageComboBoxA->setItemEnabled(1, false);
46+
headstageComboBoxA->addSeparator();
47+
// TODO: Add list of available devices here
48+
addAndMakeVisible(headstageComboBoxA.get());
49+
50+
passthroughEditorA = std::make_unique<ToggleParameterEditor>(onixSource->getParameter("passthroughA"));
51+
passthroughEditorA->setLayout(ParameterEditor::nameHidden);
52+
passthroughEditorA->setBounds(headstageComboBoxA->getX(), headstageComboBoxA->getBottom() + 4, 60, headstageComboBoxA->getHeight());
53+
addAndMakeVisible(passthroughEditorA.get());
54+
55+
portVoltageValueA = std::make_unique<Label>("voltageValueA", "");
56+
portVoltageValueA->setBounds(passthroughEditorA->getRight() + 10, passthroughEditorA->getY(), 35, passthroughEditorA->getHeight());
57+
portVoltageValueA->setFont(fontOptionSmall);
58+
portVoltageValueA->setEditable(true);
59+
portVoltageValueA->setColour(Label::textColourId, Colours::black);
60+
portVoltageValueA->setColour(Label::backgroundColourId, Colours::lightgrey);
61+
portVoltageValueA->setTooltip("Voltage override. If set, overrides the automated voltage discovery algorithm.");
62+
portVoltageValueA->addListener(this);
63+
addAndMakeVisible(portVoltageValueA.get());
64+
65+
portLabelB = std::make_unique<Label>("portLabelB", "Port B:");
66+
portLabelB->setBounds(portLabelA->getX(), passthroughEditorA->getBottom() + 5, portLabelA->getWidth(), portLabelA->getHeight());
67+
portLabelB->setFont(fontOptionTitle);
68+
addAndMakeVisible(portLabelB.get());
69+
70+
headstageComboBoxB = std::make_unique<ComboBox>("headstageComboBoxB");
71+
headstageComboBoxB->setBounds(portLabelB->getRight(), portLabelB->getY(), headstageComboBoxA->getWidth(), portLabelB->getHeight());
72+
headstageComboBoxB->addListener(this);
73+
headstageComboBoxB->setTooltip("Select the headstage connected to port B.");
74+
headstageComboBoxB->addItem("Select headstage...", 1);
75+
headstageComboBoxB->setItemEnabled(1, false);
76+
headstageComboBoxB->addSeparator();
77+
// TODO: Add list of available devices here
78+
addAndMakeVisible(headstageComboBoxB.get());
79+
80+
passthroughEditorB = std::make_unique<ToggleParameterEditor>(onixSource->getParameter("passthroughB"));
81+
passthroughEditorB->setLayout(ParameterEditor::nameHidden);
82+
passthroughEditorB->setBounds(headstageComboBoxB->getX(), headstageComboBoxB->getBottom() + 4, passthroughEditorA->getWidth(), passthroughEditorA->getHeight());
83+
addAndMakeVisible(passthroughEditorB.get());
84+
85+
portVoltageValueB = std::make_unique<Label>("voltageValueB", "");
86+
portVoltageValueB->setBounds(passthroughEditorB->getRight() + 10, passthroughEditorB->getY(), portVoltageValueA->getWidth(), passthroughEditorB->getHeight());
87+
portVoltageValueB->setFont(fontOptionSmall);
88+
portVoltageValueB->setEditable(true);
89+
portVoltageValueB->setColour(Label::textColourId, Colours::black);
90+
portVoltageValueB->setColour(Label::backgroundColourId, Colours::lightgrey);
91+
portVoltageValueB->setTooltip("Voltage override. If set, overrides the automated voltage discovery algorithm.");
92+
portVoltageValueB->addListener(this);
93+
addAndMakeVisible(portVoltageValueB.get());
94+
95+
connectButton = std::make_unique<UtilityButton>("CONNECT");
96+
connectButton->setFont(fontOptionSmall);
97+
connectButton->setBounds(portLabelB->getX() + 5, portLabelB->getBottom() + 25, 70, 18);
5398
connectButton->setRadius(3.0f);
5499
connectButton->setClickingTogglesState(true);
55100
connectButton->setToggleState(false, dontSendNotification);
56101
connectButton->setTooltip("Press to connect or disconnect from Onix hardware");
57102
connectButton->addListener(this);
58103
addAndMakeVisible(connectButton.get());
59-
60-
passthroughEditor = std::make_unique<ToggleParameterEditor>(onixSource->getParameter("is_passthrough_A"), 20, 95);
61-
passthroughEditor->setLayout(ParameterEditor::nameOnTop);
62-
passthroughEditor->setBounds(80, 90, 100, 36);
63-
addAndMakeVisible(passthroughEditor.get());
64104
}
65105

66106
void OnixSourceEditor::labelTextChanged(Label* l)
67107
{
68-
if (l == portVoltageValue.get())
108+
if (l == portVoltageValueA.get())
69109
{
70-
const float minVoltage = 4.5;
71-
const float maxVoltage = 6.5;
72-
73-
float voltage = portVoltageValue->getText().getFloatValue();
74-
75-
if (voltage >= minVoltage && voltage <= maxVoltage)
76-
{
77-
portVoltage = voltage;
78-
}
79-
else if (voltage < minVoltage)
80-
{
81-
portVoltage = minVoltage;
82-
portVoltageValue->setText(String(portVoltage), NotificationType::dontSendNotification);
83-
}
84-
else if (voltage > maxVoltage)
85-
{
86-
portVoltage = maxVoltage;
87-
portVoltageValue->setText(String(portVoltage), NotificationType::dontSendNotification);
88-
}
89110
}
90111
}
91112

@@ -95,20 +116,20 @@ void OnixSourceEditor::buttonClicked(Button* b)
95116
{
96117
if (connectButton->getToggleState() == true)
97118
{
98-
int result = thread->setPortVoltage((oni_dev_idx_t)PortName::PortA, (int)(portVoltage * 10));
119+
int result = thread->setPortVoltage((oni_dev_idx_t)PortName::PortA, (int)(portVoltageValueA->getText().getFloatValue() * 10));
99120

100-
if (result != 0) { CoreServices::sendStatusMessage("Unable to set port voltage to " + String(portVoltage) + " for Port A."); return; }
121+
if (result != 0) { CoreServices::sendStatusMessage("Unable to set port voltage to " + portVoltageValueA->getText() + " for Port A."); return; }
101122

102123
thread->initializeDevices(true);
103124
canvas->refreshTabs();
104125

105-
connectButton->setLabel("Disconnect");
126+
connectButton->setLabel("DISCONNECT");
106127

107128
if (!thread->foundInputSource())
108129
{
109130
CoreServices::sendStatusMessage("No Onix hardware found.");
110131
connectButton->setToggleState(false, NotificationType::dontSendNotification);
111-
connectButton->setLabel("Connect");
132+
connectButton->setLabel("CONNECT");
112133
}
113134
}
114135
else
@@ -119,11 +140,19 @@ void OnixSourceEditor::buttonClicked(Button* b)
119140

120141
canvas->removeTabs();
121142
thread->disconnectDevices(true);
122-
connectButton->setLabel("Connect");
143+
connectButton->setLabel("CONNECT");
123144
}
124145
}
125146
}
126147

148+
void OnixSourceEditor::comboBoxChanged(ComboBox* cb)
149+
{
150+
if (cb == headstageComboBoxA.get())
151+
{
152+
// TODO: Call canvas to remove / add tabs as needed depending on what is chosen
153+
}
154+
}
155+
127156
void OnixSourceEditor::updateSettings()
128157
{
129158
if (canvas != nullptr)
@@ -173,3 +202,16 @@ void OnixSourceEditor::resetCanvas()
173202
}
174203
}
175204
}
205+
206+
float OnixSourceEditor::getPortVoltage(PortName port)
207+
{
208+
switch (port)
209+
{
210+
case PortName::PortA:
211+
return 0.0f;
212+
case PortName::PortB:
213+
return 0.0f;
214+
default:
215+
return 0.0f;
216+
}
217+
}

Source/OnixSourceEditor.h

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class OnixSource;
4040
class OnixSourceEditor : public VisualizerEditor,
4141
public Label::Listener,
4242
public Button::Listener,
43-
public TextEditor::Listener
43+
public TextEditor::Listener,
44+
public ComboBox::Listener
4445
{
4546
public:
4647

@@ -51,9 +52,11 @@ class OnixSourceEditor : public VisualizerEditor,
5152
virtual ~OnixSourceEditor() { }
5253

5354
/** Listener methods */
54-
void labelTextChanged(Label* l);
55+
void labelTextChanged(Label* l) override;
5556

56-
void buttonClicked(Button* b);
57+
void buttonClicked(Button* b) override;
58+
59+
void comboBoxChanged(ComboBox* cb) override;
5760

5861
/** Called when settings are changed */
5962
void updateSettings() override;
@@ -71,20 +74,27 @@ class OnixSourceEditor : public VisualizerEditor,
7174

7275
void resetCanvas();
7376

74-
float portVoltage;
77+
float getPortVoltage(PortName port);
7578

7679
OnixSourceCanvas* canvas;
7780

7881
private:
7982

8083
OnixSource* thread;
8184

82-
std::unique_ptr<Label> portVoltageLabel;
83-
std::unique_ptr<Label> portVoltageValue;
85+
std::unique_ptr<Label> portLabelA;
86+
std::unique_ptr<Label> portLabelB;
87+
88+
std::unique_ptr<ComboBox> headstageComboBoxA;
89+
std::unique_ptr<ComboBox> headstageComboBoxB;
90+
91+
std::unique_ptr<Label> portVoltageValueA;
92+
std::unique_ptr<Label> portVoltageValueB;
8493

8594
std::unique_ptr<UtilityButton> connectButton;
8695

87-
std::unique_ptr<ToggleParameterEditor> passthroughEditor;
96+
std::unique_ptr<ToggleParameterEditor> passthroughEditorA;
97+
std::unique_ptr<ToggleParameterEditor> passthroughEditorB;
8898

8999
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OnixSourceEditor);
90100
};

Source/UI/NeuropixV1Interface.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ NeuropixV1Interface::NeuropixV1Interface(OnixDevice* d, OnixSourceEditor* e, Oni
9090
electrodeConfigurationComboBox->setBounds(450, currentHeight, 135, 22);
9191
electrodeConfigurationComboBox->addListener(this);
9292
electrodeConfigurationComboBox->setTooltip("Enable a pre-configured set of electrodes");
93-
9493
electrodeConfigurationComboBox->addItem("Select a preset...", 1);
9594
electrodeConfigurationComboBox->setItemEnabled(1, false);
9695
electrodeConfigurationComboBox->addSeparator();

0 commit comments

Comments
 (0)