Skip to content

Commit

Permalink
ADC-related changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiegle committed Nov 8, 2023
1 parent e0a8a99 commit 0094846
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 16 deletions.
6 changes: 6 additions & 0 deletions Source/Probes/OneBoxADC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ void OneBoxADC::initialize(bool signalChainIsLoading)

void OneBoxADC::enableInput(int chan)
{

LOGC("Enabling ADC ", chan);

if (ui != nullptr)
{
ui->enableInput(chan);
Expand All @@ -104,6 +107,9 @@ void OneBoxADC::enableInput(int chan)

void OneBoxADC::disableInput(int chan)
{

LOGC("Disabling ADC ", chan);

if (ui != nullptr)
{
ui->disableInput(chan);
Expand Down
4 changes: 4 additions & 0 deletions Source/Probes/OneBoxDAC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,17 @@ void OneBoxDAC::disableOutput(int chan)
{
errorCode = Neuropixels::DAC_enableOutput(bs->slot, chan, false);

LOGC("Disabling DAC ", chan);

adc->enableInput(chan);
}

void OneBoxDAC::enableOutput(int chan)
{
errorCode = Neuropixels::DAC_enableOutput(bs->slot, chan, true);

LOGC("Enabling DAC ", chan);

adc->disableInput(chan);
}

Expand Down
47 changes: 40 additions & 7 deletions Source/UI/DataPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "DataPlayer.h"

#include "../Probes/OneBoxDAC.h"
#include "OneBoxInterface.h"

#include "../NeuropixComponents.h"

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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)
{
Expand Down
7 changes: 6 additions & 1 deletion Source/UI/DataPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

class Probe;

class OneBoxInterface;

class UtilityButton;

/**
Expand Down Expand Up @@ -62,14 +64,16 @@ class DataPlayer : public Component,
public ComboBox::Listener
{
public:
DataPlayer(OneBoxDAC*);
DataPlayer(OneBoxDAC*, OneBoxInterface*);
virtual ~DataPlayer();

void comboBoxChanged(ComboBox*);

void saveCustomParameters(XmlElement*);
void loadCustomParameters(XmlElement*);

void setAvailableChans(ComboBox* comboBox);

void resized();

private:
Expand All @@ -84,6 +88,7 @@ class DataPlayer : public Component,
ScopedPointer<DataPlayerBackground> background;

OneBoxDAC* dac;
OneBoxInterface* onebox;

Probe* selectedProbe;
int inputChan;
Expand Down
21 changes: 15 additions & 6 deletions Source/UI/OneBoxInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}

Expand All @@ -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();
}

Expand Down Expand Up @@ -285,6 +292,8 @@ void OneBoxInterface::updateMappingSelector()
}

mappingSelector->setSelectedId(selectedChannel->mapToOutput, dontSendNotification);

dataPlayer->setAvailableChans(mappingSelector);
}


Expand Down
4 changes: 2 additions & 2 deletions Source/UI/OneBoxInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand Down

0 comments on commit 0094846

Please sign in to comment.