diff --git a/Source/Probes/OneBoxADC.cpp b/Source/Probes/OneBoxADC.cpp
index 051f6b5..e98d6cf 100644
--- a/Source/Probes/OneBoxADC.cpp
+++ b/Source/Probes/OneBoxADC.cpp
@@ -96,6 +96,9 @@ void OneBoxADC::initialize(bool signalChainIsLoading)
void OneBoxADC::enableInput(int chan)
{
+
+ LOGC("Enabling ADC ", chan);
+
if (ui != nullptr)
{
ui->enableInput(chan);
@@ -104,6 +107,9 @@ void OneBoxADC::enableInput(int chan)
void OneBoxADC::disableInput(int chan)
{
+
+ LOGC("Disabling ADC ", chan);
+
if (ui != nullptr)
{
ui->disableInput(chan);
diff --git a/Source/Probes/OneBoxDAC.cpp b/Source/Probes/OneBoxDAC.cpp
index 0d45e0f..f8e93b4 100644
--- a/Source/Probes/OneBoxDAC.cpp
+++ b/Source/Probes/OneBoxDAC.cpp
@@ -146,6 +146,8 @@ void OneBoxDAC::disableOutput(int chan)
{
errorCode = Neuropixels::DAC_enableOutput(bs->slot, chan, false);
+ LOGC("Disabling DAC ", chan);
+
adc->enableInput(chan);
}
@@ -153,6 +155,8 @@ void OneBoxDAC::enableOutput(int chan)
{
errorCode = Neuropixels::DAC_enableOutput(bs->slot, chan, true);
+ LOGC("Enabling DAC ", chan);
+
adc->disableInput(chan);
}
diff --git a/Source/UI/DataPlayer.cpp b/Source/UI/DataPlayer.cpp
index fd11fc5..101de3c 100644
--- a/Source/UI/DataPlayer.cpp
+++ b/Source/UI/DataPlayer.cpp
@@ -24,6 +24,7 @@ along with this program. If not, see .
#include "DataPlayer.h"
#include "../Probes/OneBoxDAC.h"
+#include "OneBoxInterface.h"
#include "../NeuropixComponents.h"
@@ -55,8 +56,8 @@ void DataPlayerBackground::paint(Graphics& g)
}
-DataPlayer::DataPlayer(OneBoxDAC* dac_)
- : dac(dac_)
+DataPlayer::DataPlayer(OneBoxDAC* dac_, OneBoxInterface* onebox_)
+ : dac(dac_), onebox(onebox_)
{
inputChan = 0;
outputChan = -1;
@@ -88,8 +89,7 @@ DataPlayer::DataPlayer(OneBoxDAC* dac_)
if (i == 0)
selectedProbe = currentProbe;
- probeSelector->addItem("Probe " +
- String(currentProbe->dock), i + 1);
+ probeSelector->addItem(currentProbe->getName(), i + 1);
}
probeSelector->setSelectedId(1, dontSendNotification);
@@ -154,16 +154,38 @@ void DataPlayer::comboBoxChanged(ComboBox* comboBox)
else if (comboBox == outputSelector)
{
- if (comboBox->getSelectedId() == 1 && outputChan != -1)
+ if (comboBox->getSelectedId() == 1) // deselect output
{
- dac->disableOutput(outputChan);
+ std::cout << "Selected: " << comboBox->getSelectedId() << std::endl;
+ std::cout << "Current output: " << outputChan << std::endl;
+
+ if (outputChan > -1)
+ {
+ dac->disableOutput(outputChan);
+ onebox->enableInput(outputChan);
+ }
+
outputChan = -1;
- return;
+
+ std::cout << "New output: " << outputChan << std::endl;
}
else if (comboBox->getSelectedId() > 1)
{
+
+ std::cout << "Selected: " << comboBox->getSelectedId() << std::endl;
+ std::cout << "Current output: " << outputChan << std::endl;
+
+ if (outputChan > -1)
+ {
+ dac->disableOutput(outputChan);
+ onebox->enableInput(outputChan);
+ }
+
outputChan = comboBox->getSelectedId() - 2;
dac->enableOutput(outputChan);
+ onebox->disableInput(outputChan);
+
+ std::cout << "New output: " << outputChan << std::endl;
}
}
@@ -177,6 +199,17 @@ void DataPlayer::comboBoxChanged(ComboBox* comboBox)
}
+void DataPlayer::setAvailableChans(ComboBox* comboBox)
+{
+
+ outputSelector->clear();
+
+ for (int i = 0; i < comboBox->getNumItems(); i++)
+ {
+ outputSelector->addItem(comboBox->getItemText(i), comboBox->getItemId(i));
+ }
+}
+
void DataPlayer::saveCustomParameters(XmlElement* xml)
{
diff --git a/Source/UI/DataPlayer.h b/Source/UI/DataPlayer.h
index 6d01f1c..1e8f202 100644
--- a/Source/UI/DataPlayer.h
+++ b/Source/UI/DataPlayer.h
@@ -30,6 +30,8 @@ along with this program. If not, see .
class Probe;
+class OneBoxInterface;
+
class UtilityButton;
/**
@@ -62,7 +64,7 @@ class DataPlayer : public Component,
public ComboBox::Listener
{
public:
- DataPlayer(OneBoxDAC*);
+ DataPlayer(OneBoxDAC*, OneBoxInterface*);
virtual ~DataPlayer();
void comboBoxChanged(ComboBox*);
@@ -70,6 +72,8 @@ class DataPlayer : public Component,
void saveCustomParameters(XmlElement*);
void loadCustomParameters(XmlElement*);
+ void setAvailableChans(ComboBox* comboBox);
+
void resized();
private:
@@ -84,6 +88,7 @@ class DataPlayer : public Component,
ScopedPointer background;
OneBoxDAC* dac;
+ OneBoxInterface* onebox;
Probe* selectedProbe;
int inputChan;
diff --git a/Source/UI/OneBoxInterface.cpp b/Source/UI/OneBoxInterface.cpp
index 9d6a2cf..5fb1520 100644
--- a/Source/UI/OneBoxInterface.cpp
+++ b/Source/UI/OneBoxInterface.cpp
@@ -151,16 +151,15 @@ OneBoxInterface::OneBoxInterface(DataSource* dataSource_, NeuropixThread* thread
mappingSelector->addListener(this);
addAndMakeVisible(mappingSelector);
- updateMappingSelector();
-
wavePlayer = new WavePlayer(dac);
wavePlayer->setBounds(500, 100, 320, 180);
addAndMakeVisible(wavePlayer);
- dataPlayer = new DataPlayer(dac);
+ dataPlayer = new DataPlayer(dac, this);
dataPlayer->setBounds(500, 340, 320, 180);
addAndMakeVisible(dataPlayer);
-
+
+ updateMappingSelector();
}
@@ -176,15 +175,23 @@ void OneBoxInterface::stopAcquisition()
}
-void OneBoxInterface::enableInput(int chan)
+void OneBoxInterface::enableInput(int chan, bool remap)
{
channels[chan]->setStatus(AdcChannelStatus::AVAILABLE);
+
+ if (remap)
+ channels[chan]->mapToOutput = 999;
+
repaint();
}
-void OneBoxInterface::disableInput(int chan)
+void OneBoxInterface::disableInput(int chan, bool remap)
{
channels[chan]->setStatus(AdcChannelStatus::IN_USE);
+
+ if (remap)
+ channels[chan]->mapToOutput = -1;
+
repaint();
}
@@ -285,6 +292,8 @@ void OneBoxInterface::updateMappingSelector()
}
mappingSelector->setSelectedId(selectedChannel->mapToOutput, dontSendNotification);
+
+ dataPlayer->setAvailableChans(mappingSelector);
}
diff --git a/Source/UI/OneBoxInterface.h b/Source/UI/OneBoxInterface.h
index 9862696..46cdcca 100644
--- a/Source/UI/OneBoxInterface.h
+++ b/Source/UI/OneBoxInterface.h
@@ -132,8 +132,8 @@ class OneBoxInterface : public SettingsInterface,
void paint(Graphics& g);
- void enableInput(int chan);
- void disableInput(int chan);
+ void enableInput(int chan, bool remap = false);
+ void disableInput(int chan, bool remap = false);
void comboBoxChanged(ComboBox*);
void buttonClicked(Button*);