Skip to content
Snippets Groups Projects
Commit c439350c authored by Josh Siegle's avatar Josh Siegle
Browse files

Merge branch 'master' of https://github.com/open-ephys/GUI

parents 92cca0f8 33abc099
No related branches found
No related tags found
No related merge requests found
Showing
with 841 additions and 301 deletions
No preview for this file type
File added
...@@ -61,6 +61,11 @@ String Channel::getName() ...@@ -61,6 +61,11 @@ String Channel::getName()
} }
void Channel::setName(String name_)
{
name = name_;
}
void Channel::reset() void Channel::reset()
{ {
createDefaultName(); createDefaultName();
......
...@@ -61,6 +61,9 @@ public: ...@@ -61,6 +61,9 @@ public:
/** Returns the name of a given channel. */ /** Returns the name of a given channel. */
String getName(); String getName();
/** Sets the name of a given channel. */
void setName(String);
/** Restores the default settings for a given channel. */ /** Restores the default settings for a given channel. */
void reset(); void reset();
......
...@@ -93,6 +93,9 @@ public: ...@@ -93,6 +93,9 @@ public:
return 0; return 0;
} }
/** Changes the names of channels, if the thread needs custom names. */
virtual void updateChannelNames() { }
SourceNode* sn; SourceNode* sn;
int16 eventCode; int16 eventCode;
......
This diff is collapsed.
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "DataThread.h" #include "DataThread.h"
#define MAX_NUM_DATA_STREAMS 8
class SourceNode; class SourceNode;
...@@ -67,22 +68,30 @@ public: ...@@ -67,22 +68,30 @@ public:
void setCableLength(int hsNum, float length); void setCableLength(int hsNum, float length);
void setNumChannels(int hsNum, int nChannels); void setNumChannels(int hsNum, int nChannels);
void setSampleRate(int sampleRateIndex); void setSampleRate(int index, bool temporary = false);
double setUpperBandwidth(double desiredUpperBandwidth); // set desired BW, returns actual BW double setUpperBandwidth(double upper); // set desired BW, returns actual BW
double setLowerBandwidth(double desiredLowerBandwidth); double setLowerBandwidth(double lower);
void scanPorts();
int getNumEventChannels(); int getNumEventChannels();
void assignAudioOut(int dacChannel, int dataChannel);
void enableAdcs(bool);
bool isAcquisitionActive(); bool isAcquisitionActive();
void updateChannelNames();
private: private:
ScopedPointer<Rhd2000EvalBoard> evalBoard; ScopedPointer<Rhd2000EvalBoard> evalBoard;
ScopedPointer<Rhd2000Registers> chipRegisters; Rhd2000Registers chipRegisters;
Rhd2000DataBlock* dataBlock; Rhd2000DataBlock* dataBlock;
int audioOutputL, audioOutputR;
Array<int> numChannelsPerDataStream; Array<int> numChannelsPerDataStream;
int numChannels; int numChannels;
...@@ -95,13 +104,26 @@ private: ...@@ -95,13 +104,26 @@ private:
bool isTransmitting; bool isTransmitting;
bool dacOutputShouldChange;
bool acquireAdcChannels;
bool acquireAuxChannels;
bool fastSettleEnabled; bool fastSettleEnabled;
bool dspEnabled;
double actualDspCutoffFreq, desiredDspCutoffFreq;
double actualUpperBandwidth, desiredUpperBandwidth;
double actualLowerBandwidth, desiredLowerBandwidth;
double boardSampleRate;
int savedSampleRateIndex;
bool startAcquisition(); bool startAcquisition();
bool stopAcquisition(); bool stopAcquisition();
void initializeBoard(); void initializeBoard();
void scanPorts();
void updateRegisters();
int deviceId(Rhd2000DataBlock* dataBlock, int stream); int deviceId(Rhd2000DataBlock* dataBlock, int stream);
bool updateBuffer(); bool updateBuffer();
......
...@@ -148,7 +148,7 @@ void Rhd2000DataBlock::fillFromUsbBuffer(unsigned char usbBuffer[], int blockInd ...@@ -148,7 +148,7 @@ void Rhd2000DataBlock::fillFromUsbBuffer(unsigned char usbBuffer[], int blockInd
{ {
if (!checkUsbHeader(usbBuffer, index)) if (!checkUsbHeader(usbBuffer, index))
{ {
cerr << "Error in Rhd2000EvalBoard::readDataBlock: Incorrect header." << endl; //cerr << "Error in Rhd2000EvalBoard::readDataBlock: Incorrect header." << endl;
} }
index += 8; index += 8;
timeStamp[t] = convertUsbTimeStamp(usbBuffer, index); timeStamp[t] = convertUsbTimeStamp(usbBuffer, index);
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "../../../JuceLibraryCode/JuceHeader.h" #include "../../../JuceLibraryCode/JuceHeader.h"
#include "GenericEditor.h" #include "GenericEditor.h"
#include "SpikeDetectorEditor.h" #include "SpikeDetectorEditor.h" // for ElectrodeButton and ElectrodeEditorButton
/** /**
......
...@@ -352,22 +352,29 @@ void ChannelSelector::stopAcquisition() ...@@ -352,22 +352,29 @@ void ChannelSelector::stopAcquisition()
void ChannelSelector::setRadioStatus(bool radioOn) void ChannelSelector::setRadioStatus(bool radioOn)
{ {
radioStatus = radioOn; if (radioStatus != radioOn)
for (int i = 0; i < parameterButtons.size(); i++)
{ {
if (radioOn)
{ radioStatus = radioOn;
parameterButtons[i]->setToggleState(false, false);
parameterButtons[i]->setRadioGroupId(999); for (int i = 0; i < parameterButtons.size(); i++)
}
else
{ {
parameterButtons[i]->setToggleState(false, false); if (radioOn)
parameterButtons[i]->setRadioGroupId(0); {
parameterButtons[i]->setToggleState(false, false);
parameterButtons[i]->setRadioGroupId(999);
}
else
{
parameterButtons[i]->setToggleState(false, false);
parameterButtons[i]->setRadioGroupId(0);
}
} }
} }
} }
bool ChannelSelector::getParamStatus(int chan) bool ChannelSelector::getParamStatus(int chan)
...@@ -525,6 +532,13 @@ void ChannelSelector::buttonClicked(Button* button) ...@@ -525,6 +532,13 @@ void ChannelSelector::buttonClicked(Button* button)
audioButtons[i]->setToggleState(false, true); audioButtons[i]->setToggleState(false, true);
} }
} }
if (radioStatus) // if radio buttons are active
{
// send a message to parent
GenericEditor* editor = (GenericEditor*) getParentComponent();
editor->channelChanged(-1);
}
} }
else else
{ {
......
...@@ -555,7 +555,7 @@ void DrawerButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown) ...@@ -555,7 +555,7 @@ void DrawerButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown)
} }
UtilityButton::UtilityButton(const String& label_, Font font_) : UtilityButton::UtilityButton(String label_, Font font_) :
Button(label_), label(label_), font(font_) Button(label_), label(label_), font(font_)
{ {
...@@ -659,7 +659,7 @@ void UtilityButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown ...@@ -659,7 +659,7 @@ void UtilityButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown
g.setFont(font); g.setFont(font);
g.setColour(fontColor); g.setColour(fontColor);
g.drawText(getName(),0,0,getWidth(),getHeight(),Justification::centred,true); g.drawText(label,0,0,getWidth(),getHeight(),Justification::centred,true);
//g.drawSingleLineText(getName(), getWidth()/2 - stringWidth/2, 12); //g.drawSingleLineText(getName(), getWidth()/2 - stringWidth/2, 12);
...@@ -753,6 +753,12 @@ void UtilityButton::resized() ...@@ -753,6 +753,12 @@ void UtilityButton::resized()
} }
void UtilityButton::setLabel(String label_)
{
label = label_;
repaint();
}
void TriangleButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown) void TriangleButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown)
{ {
...@@ -803,10 +809,10 @@ void TriangleButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDow ...@@ -803,10 +809,10 @@ void TriangleButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDow
void GenericEditor::updateParameterButtons(int parameterIndex) void GenericEditor::updateParameterButtons(int parameterIndex)
{ {
if (parameterEditors.size()==0) if (parameterEditors.size() == 0)
{ {
//Checks if there is a parameter editor, and stops a bug if there isn't. //Checks if there is a parameter editor, and stops a bug if there isn't.
std::cout << "No parameterEditors" << std::endl; //std::cout << "No parameterEditors" << std::endl;
} }
else else
{ {
...@@ -821,6 +827,6 @@ void GenericEditor::updateParameterButtons(int parameterIndex) ...@@ -821,6 +827,6 @@ void GenericEditor::updateParameterButtons(int parameterIndex)
{ {
parameterEditors[parameterIndex]->channelSelectionUI(); parameterEditors[parameterIndex]->channelSelectionUI();
} }
std::cout << "updateParameterButtons" << std::endl; //std::cout << "updateParameterButtons" << std::endl;
} }
} }
...@@ -106,10 +106,10 @@ public: ...@@ -106,10 +106,10 @@ public:
void setEnabledState(bool); void setEnabledState(bool);
/** Called just prior to the start of acquisition, to allow the editor to prepare.*/ /** Called just prior to the start of acquisition, to allow the editor to prepare.*/
void startAcquisition(); virtual void startAcquisition();
/** Called after the end of acquisition.*/ /** Called after the end of acquisition.*/
void stopAcquisition(); virtual void stopAcquisition();
/** Returns the name of the editor.*/ /** Returns the name of the editor.*/
String getName() String getName()
...@@ -344,7 +344,7 @@ private: ...@@ -344,7 +344,7 @@ private:
class UtilityButton : public Button class UtilityButton : public Button
{ {
public: public:
UtilityButton(const String& label_, Font font_); UtilityButton(String label_, Font font_);
~UtilityButton() {} ~UtilityButton() {}
void setCorners(bool UL, bool UR, bool LL, bool LR); void setCorners(bool UL, bool UR, bool LL, bool LR);
...@@ -356,10 +356,12 @@ public: ...@@ -356,10 +356,12 @@ public:
return isEnabled; return isEnabled;
} }
void setLabel(String label);
private: private:
void paintButton(Graphics& g, bool isMouseOver, bool isButtonDown); void paintButton(Graphics& g, bool isMouseOver, bool isButtonDown);
const String label; String label;
Font font; Font font;
bool roundUL, roundUR, roundLL, roundLR; bool roundUL, roundUR, roundLL, roundLR;
float radius; float radius;
......
...@@ -24,16 +24,17 @@ ...@@ -24,16 +24,17 @@
#include "RHD2000Editor.h" #include "RHD2000Editor.h"
#include "../../UI/EditorViewport.h" #include "../../UI/EditorViewport.h"
#include "ChannelSelector.h"
#include "../DataThreads/RHD2000Thread.h" #include "../DataThreads/RHD2000Thread.h"
RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode,
RHD2000Thread* board_, RHD2000Thread* board_,
bool useDefaultParameterEditors=true bool useDefaultParameterEditors
) )
: GenericEditor(parentNode, useDefaultParameterEditors), board(board_) : GenericEditor(parentNode, useDefaultParameterEditors), board(board_)
{ {
desiredWidth = 400; desiredWidth = 260;
// add headstage-specific controls (currently just an enable/disable button) // add headstage-specific controls (currently just an enable/disable button)
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
...@@ -41,23 +42,128 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, ...@@ -41,23 +42,128 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode,
HeadstageOptionsInterface* hsOptions = new HeadstageOptionsInterface(board, this, i); HeadstageOptionsInterface* hsOptions = new HeadstageOptionsInterface(board, this, i);
headstageOptionsInterfaces.add(hsOptions); headstageOptionsInterfaces.add(hsOptions);
addAndMakeVisible(hsOptions); addAndMakeVisible(hsOptions);
hsOptions->setBounds(80,25+i*23, 60, 22); hsOptions->setBounds(3, 28+i*20, 70, 18);
} }
// add sample rate selection // add sample rate selection
SampleRateInterface* rateOptions = new SampleRateInterface(board, this); sampleRateInterface = new SampleRateInterface(board, this);
addAndMakeVisible(rateOptions); addAndMakeVisible(sampleRateInterface);
rateOptions->setBounds(150,25,160, 50); sampleRateInterface->setBounds(80, 25, 100, 50);
// add Bandwidth selection // add Bandwidth selection
BandwidthInterface* bandwidthOptions = new BandwidthInterface(board, this); bandwidthInterface = new BandwidthInterface(board, this);
addAndMakeVisible(bandwidthOptions); addAndMakeVisible(bandwidthInterface);
bandwidthOptions->setBounds(150,65,160, 50); bandwidthInterface->setBounds(80, 65, 100, 50);
// add rescan button
rescanButton = new UtilityButton("RESCAN", Font("Small Text", 13, Font::plain));
rescanButton->setRadius(3.0f);
rescanButton->setBounds(6, 108,65,18);
rescanButton->addListener(this);
addAndMakeVisible(rescanButton);
for (int i = 0; i < 2; i++)
{
ElectrodeButton* button = new ElectrodeButton(-1);
electrodeButtons.add(button);
button->setBounds(190+i*25, 40, 25, 15);
button->setChannelNum(-1);
button->setToggleState(false,false);
button->setRadioGroupId(999);
addAndMakeVisible(button);
button->addListener(this);
}
audioLabel = new Label("audio label", "Audio out");
audioLabel->setBounds(180,25,180,15);
audioLabel->setFont(Font("Small Text", 10, Font::plain));
audioLabel->setColour(Label::textColourId, Colours::darkgrey);
addAndMakeVisible(audioLabel);
adcButton = new UtilityButton("ADC 1-8", Font("Small Text", 13, Font::plain));
adcButton->setRadius(3.0f);
adcButton->setBounds(180, 70,65,18);
adcButton->addListener(this);
adcButton->setClickingTogglesState(true);
addAndMakeVisible(adcButton);
} }
RHD2000Editor::~RHD2000Editor() RHD2000Editor::~RHD2000Editor()
{ {
}
void RHD2000Editor::scanPorts()
{
rescanButton->triggerClick();
}
void RHD2000Editor::buttonEvent(Button* button)
{
if (button == rescanButton)
{
board->scanPorts();
for (int i = 0; i < 4; i++)
{
headstageOptionsInterfaces[i]->checkEnabledState();
}
} else if (button == electrodeButtons[0])
{
channelSelector->setRadioStatus(true);
} else if (button == electrodeButtons[1])
{
channelSelector->setRadioStatus(true);
} else if (button == adcButton)
{
board->enableAdcs(button->getToggleState());
getEditorViewport()->makeEditorVisible(this, false, true);
}
}
void RHD2000Editor::channelChanged(int chan)
{
for (int i = 0; i < 2; i++)
{
if (electrodeButtons[i]->getToggleState())
{
electrodeButtons[i]->setChannelNum(chan);
electrodeButtons[i]->repaint();
board->assignAudioOut(i, chan);
}
}
}
void RHD2000Editor::startAcquisition()
{
channelSelector->startAcquisition();
rescanButton->setEnabledState(false);
adcButton->setEnabledState(false);
acquisitionIsActive = true;
}
void RHD2000Editor::stopAcquisition()
{
channelSelector->stopAcquisition();
rescanButton->setEnabledState(true);
adcButton->setEnabledState(true);
acquisitionIsActive = false;
} }
// Bandwidth Options -------------------------------------------------------------------- // Bandwidth Options --------------------------------------------------------------------
...@@ -67,20 +173,25 @@ BandwidthInterface::BandwidthInterface(RHD2000Thread* board_, ...@@ -67,20 +173,25 @@ BandwidthInterface::BandwidthInterface(RHD2000Thread* board_,
board(board_), editor(editor_) board(board_), editor(editor_)
{ {
name="Bandwidth"; name = "Bandwidth";
lastHighCutString = "7500";
lastLowCutString = "1";
UpperBandwidthSelection = new Label("UpperBandwidth","7500 Hz"); // this is currently set in RHD2000Thread, the cleaner would be to set it here again UpperBandwidthSelection = new Label("UpperBandwidth",lastHighCutString); // this is currently set in RHD2000Thread, the cleaner would be to set it here again
UpperBandwidthSelection->setEditable(true,false,false); UpperBandwidthSelection->setEditable(true,false,false);
UpperBandwidthSelection->addListener(this); UpperBandwidthSelection->addListener(this);
UpperBandwidthSelection->setBounds(0,10,300,30); UpperBandwidthSelection->setBounds(30,30,60,20);
UpperBandwidthSelection->setColour(Label::textColourId, Colours::darkgrey);
addAndMakeVisible(UpperBandwidthSelection); addAndMakeVisible(UpperBandwidthSelection);
LowerBandwidthSelection = new Label("LowerBandwidth","1 Hz"); LowerBandwidthSelection = new Label("LowerBandwidth",lastLowCutString);
LowerBandwidthSelection->setEditable(true,false,false); LowerBandwidthSelection->setEditable(true,false,false);
LowerBandwidthSelection->addListener(this); LowerBandwidthSelection->addListener(this);
LowerBandwidthSelection->setBounds(0,30,300,30); LowerBandwidthSelection->setBounds(25,10,60,20);
LowerBandwidthSelection->setColour(Label::textColourId, Colours::darkgrey);
addAndMakeVisible(LowerBandwidthSelection); addAndMakeVisible(LowerBandwidthSelection);
...@@ -93,29 +204,51 @@ BandwidthInterface::~BandwidthInterface() ...@@ -93,29 +204,51 @@ BandwidthInterface::~BandwidthInterface()
} }
void BandwidthInterface::labelTextChanged(Label* te) void BandwidthInterface::labelTextChanged(Label* label)
{ {
if (!(editor->acquisitionIsActive) && board->foundInputSource()) if (!(editor->acquisitionIsActive) && board->foundInputSource())
{ {
if (te == UpperBandwidthSelection) if (label == UpperBandwidthSelection)
{ {
double actualUpperBandwidth = board->setUpperBandwidth(te->getText().getDoubleValue());
// cb->setText(cb->getItemText(te->getSelectedId()),true);
std::cout << "Setting Upper Bandwidth to " << te->getText().getDoubleValue() << std::endl;
std::cout << "Actual Upper Bandwidth: " << actualUpperBandwidth << std::endl;
te->setText(String(actualUpperBandwidth)+" Hz",false);
Value val = label->getTextValue();
double requestedValue = double(val.getValue());
if (requestedValue < 100.0 || requestedValue > 20000.0 || requestedValue < lastLowCutString.getFloatValue())
{
editor->sendActionMessage("Value out of range.");
label->setText(lastHighCutString, dontSendNotification);
return;
}
double actualUpperBandwidth = board->setUpperBandwidth(requestedValue);
std::cout << "Setting Upper Bandwidth to " << requestedValue << std::endl;
std::cout << "Actual Upper Bandwidth: " << actualUpperBandwidth << std::endl;
label->setText(String((roundFloatToInt)(actualUpperBandwidth)), false);
repaint();
} else { } else {
double actualLowerBandwidth = board->setLowerBandwidth(te->getText().getDoubleValue());
// cb->setText(cb->getItemText(te->getSelectedId()),true);
std::cout << "Setting Lower Bandwidth to " << te->getText().getDoubleValue() << std::endl;
std::cout << "Actual Lower Bandwidth: " << actualLowerBandwidth << std::endl;
te->setText(String(actualLowerBandwidth)+" Hz",false);
repaint(); Value val = label->getTextValue();
double requestedValue = double(val.getValue());
if (requestedValue < 0.1 || requestedValue > 500.0 || requestedValue > lastHighCutString.getFloatValue())
{
editor->sendActionMessage("Value out of range.");
label->setText(lastLowCutString, dontSendNotification);
return;
}
double actualLowerBandwidth = board->setLowerBandwidth(requestedValue);
std::cout << "Setting Upper Bandwidth to " << requestedValue << std::endl;
std::cout << "Actual Upper Bandwidth: " << actualLowerBandwidth << std::endl;
label->setText(String(roundFloatToInt(actualLowerBandwidth)), false);
} }
} }
} }
...@@ -125,16 +258,17 @@ void BandwidthInterface::labelTextChanged(Label* te) ...@@ -125,16 +258,17 @@ void BandwidthInterface::labelTextChanged(Label* te)
void BandwidthInterface::paint(Graphics& g) void BandwidthInterface::paint(Graphics& g)
{ {
//g.setColour(Colours::lightgrey);
//g.fillRoundedRectangle(5,0,getWidth()-10,getHeight(),4.0f); g.setColour(Colours::darkgrey);
// g.setColour(Colours::grey);
g.setFont(Font("Small Text",15,Font::plain)); g.setFont(Font("Small Text",10,Font::plain));
g.drawText(name, 0, 0, 200, 15, Justification::left, false); g.drawText(name, 0, 0, 200, 15, Justification::left, false);
g.drawText("Low: ", 0, 10, 200, 20, Justification::left, false);
g.drawText("High: ", 0, 30, 200, 20, Justification::left, false);
} }
// Sample rate Options -------------------------------------------------------------------- // Sample rate Options --------------------------------------------------------------------
...@@ -144,7 +278,7 @@ SampleRateInterface::SampleRateInterface(RHD2000Thread* board_, ...@@ -144,7 +278,7 @@ SampleRateInterface::SampleRateInterface(RHD2000Thread* board_,
board(board_), editor(editor_) board(board_), editor(editor_)
{ {
name="SampleRate"; name="Sample Rate";
sampleRateOptions.add("1.00 kS/s"); sampleRateOptions.add("1.00 kS/s");
sampleRateOptions.add("1.25 kS/s"); sampleRateOptions.add("1.25 kS/s");
...@@ -187,12 +321,11 @@ void SampleRateInterface::comboBoxChanged(ComboBox* cb) ...@@ -187,12 +321,11 @@ void SampleRateInterface::comboBoxChanged(ComboBox* cb)
{ {
if (cb == rateSelection) if (cb == rateSelection)
{ {
board->setSampleRate(cb->getSelectedId()); board->setSampleRate(cb->getSelectedId()-1);
//cb->setText(cb->getItemText(cb->getSelectedId()),true);
std::cout << "Setting sample rate to index " << cb->getSelectedId() << std::endl; std::cout << "Setting sample rate to index " << cb->getSelectedId()-1 << std::endl;
editor->getEditorViewport()->makeEditorVisible(editor, false, true); editor->getEditorViewport()->makeEditorVisible(editor, false, true);
//repaint();
} }
} }
} }
...@@ -202,13 +335,10 @@ void SampleRateInterface::comboBoxChanged(ComboBox* cb) ...@@ -202,13 +335,10 @@ void SampleRateInterface::comboBoxChanged(ComboBox* cb)
void SampleRateInterface::paint(Graphics& g) void SampleRateInterface::paint(Graphics& g)
{ {
//g.setColour(Colours::lightgrey);
//g.fillRoundedRectangle(5,0,getWidth()-10,getHeight(),4.0f); g.setColour(Colours::darkgrey);
// g.setColour(Colours::grey);
g.setFont(Font("Small Text",15,Font::plain)); g.setFont(Font("Small Text",10,Font::plain));
g.drawText(name, 0, 0, 200, 15, Justification::left, false); g.drawText(name, 0, 0, 200, 15, Justification::left, false);
...@@ -220,10 +350,10 @@ void SampleRateInterface::paint(Graphics& g) ...@@ -220,10 +350,10 @@ void SampleRateInterface::paint(Graphics& g)
HeadstageOptionsInterface::HeadstageOptionsInterface(RHD2000Thread* board_, HeadstageOptionsInterface::HeadstageOptionsInterface(RHD2000Thread* board_,
RHD2000Editor* editor_, RHD2000Editor* editor_,
int hsNum) : int hsNum) :
hsNumber(hsNum), isEnabled(false), board(board_), editor(editor_) isEnabled(false), board(board_), editor(editor_)
{ {
switch (hsNumber) switch (hsNum)
{ {
case 0 : case 0 :
name = "A"; name = "A";
...@@ -241,16 +371,31 @@ HeadstageOptionsInterface::HeadstageOptionsInterface(RHD2000Thread* board_, ...@@ -241,16 +371,31 @@ HeadstageOptionsInterface::HeadstageOptionsInterface(RHD2000Thread* board_,
name = "X"; name = "X";
} }
isEnabled = board->isHeadstageEnabled(hsNumber); hsNumber1 = hsNum*2; // data stream 1
hsNumber2 = hsNumber1+1; // data stream 2
enabledButton = new UtilityButton("on", Font("Small Text", 13, Font::plain));
enabledButton->addListener(this);
enabledButton->setRadius(3.0f);
enabledButton->setBounds(25,2,20,19);
addAndMakeVisible(enabledButton);
channelsOnHs1 = 0;
channelsOnHs2 = 0;
hsButton1 = new UtilityButton(" ", Font("Small Text", 13, Font::plain));
hsButton1->setRadius(3.0f);
hsButton1->setBounds(23,1,20,17);
hsButton1->setEnabledState(false);
hsButton1->setCorners(true, false, true, false);
hsButton1->addListener(this);
addAndMakeVisible(hsButton1);
hsButton2 = new UtilityButton(" ", Font("Small Text", 13, Font::plain));
hsButton2->setRadius(3.0f);
hsButton2->setBounds(43,1,20,17);
hsButton2->setEnabledState(false);
hsButton2->setCorners(false, true, false, true);
hsButton2->addListener(this);
addAndMakeVisible(hsButton2);
checkEnabledState();
} }
HeadstageOptionsInterface::~HeadstageOptionsInterface() HeadstageOptionsInterface::~HeadstageOptionsInterface()
...@@ -258,6 +403,37 @@ HeadstageOptionsInterface::~HeadstageOptionsInterface() ...@@ -258,6 +403,37 @@ HeadstageOptionsInterface::~HeadstageOptionsInterface()
} }
void HeadstageOptionsInterface::checkEnabledState()
{
isEnabled = (board->isHeadstageEnabled(hsNumber1) ||
board->isHeadstageEnabled(hsNumber2));
if (board->isHeadstageEnabled(hsNumber1))
{
channelsOnHs1 = 32;
hsButton1->setLabel(String(channelsOnHs1));
hsButton1->setEnabledState(true);
} else {
channelsOnHs1 = 0;
hsButton1->setLabel(" ");
hsButton1->setEnabledState(false);
}
if (board->isHeadstageEnabled(hsNumber2))
{
channelsOnHs2 = 32;
hsButton2->setLabel(String(channelsOnHs2));
hsButton2->setEnabledState(true);
} else {
channelsOnHs2 = 0;
hsButton2->setLabel(" ");
hsButton2->setEnabledState(false);
}
repaint();
}
void HeadstageOptionsInterface::buttonClicked(Button* button) void HeadstageOptionsInterface::buttonClicked(Button* button)
{ {
...@@ -265,35 +441,35 @@ void HeadstageOptionsInterface::buttonClicked(Button* button) ...@@ -265,35 +441,35 @@ void HeadstageOptionsInterface::buttonClicked(Button* button)
{ {
//std::cout << "Acquisition is not active" << std::endl; //std::cout << "Acquisition is not active" << std::endl;
if (isEnabled) if (button == hsButton1)
{ {
isEnabled = false; if (channelsOnHs1 == 32)
} channelsOnHs1 = 16;
else else
channelsOnHs1 = 32;
//std::cout << "HS1 has " << channelsOnHs1 << " channels." << std::endl;
hsButton1->setLabel(String(channelsOnHs1));
board->setNumChannels(hsNumber1, channelsOnHs1);
} else if (button == hsButton2)
{ {
isEnabled = true; if (channelsOnHs2 == 32)
} channelsOnHs2 = 16;
else
channelsOnHs2 = 32;
board->enableHeadstage(hsNumber, isEnabled); hsButton2->setLabel(String(channelsOnHs2));
board->setNumChannels(hsNumber2, channelsOnHs2);
}
repaint();
editor->getEditorViewport()->makeEditorVisible(editor, false, true); editor->getEditorViewport()->makeEditorVisible(editor, false, true);
} }
} }
// void HeadstageOptionsInterface::mouseUp(const MouseEvent& event)
// {
// ///>>>> ???? WHY ISN"T THIS WORKING?
// if (event.eventComponent == this)
// {
// }
// }
void HeadstageOptionsInterface::paint(Graphics& g) void HeadstageOptionsInterface::paint(Graphics& g)
{ {
...@@ -306,8 +482,8 @@ void HeadstageOptionsInterface::paint(Graphics& g) ...@@ -306,8 +482,8 @@ void HeadstageOptionsInterface::paint(Graphics& g)
else else
g.setColour(Colours::grey); g.setColour(Colours::grey);
g.setFont(Font("Small Text",20,Font::plain)); g.setFont(Font("Small Text",15,Font::plain));
g.drawText(name, 8, 5, 200, 15, Justification::left, false); g.drawText(name, 8, 2, 200, 15, Justification::left, false);
} }
\ No newline at end of file
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "../../../JuceLibraryCode/JuceHeader.h" #include "../../../JuceLibraryCode/JuceHeader.h"
#include "GenericEditor.h" #include "GenericEditor.h"
#include "SpikeDetectorEditor.h" // for ElectrodeButton
class HeadstageOptionsInterface; class HeadstageOptionsInterface;
class SampleRateInterface; class SampleRateInterface;
class BandwidthInterface; class BandwidthInterface;
...@@ -50,10 +52,27 @@ public: ...@@ -50,10 +52,27 @@ public:
RHD2000Editor(GenericProcessor* parentNode, RHD2000Thread*, bool useDefaultParameterEditors); RHD2000Editor(GenericProcessor* parentNode, RHD2000Thread*, bool useDefaultParameterEditors);
~RHD2000Editor(); ~RHD2000Editor();
void buttonEvent(Button* button);
void scanPorts();
void startAcquisition();
void stopAcquisition();
void channelChanged(int chan);
private: private:
OwnedArray<HeadstageOptionsInterface> headstageOptionsInterfaces; OwnedArray<HeadstageOptionsInterface> headstageOptionsInterfaces;
ScopedPointer<SampleRateInterface> RateInterface; OwnedArray<ElectrodeButton> electrodeButtons;
ScopedPointer<SampleRateInterface> sampleRateInterface;
ScopedPointer<BandwidthInterface> bandwidthInterface;
ScopedPointer<UtilityButton> rescanButton;
ScopedPointer<UtilityButton> adcButton;
ScopedPointer<Label> audioLabel;
RHD2000Thread* board; RHD2000Thread* board;
...@@ -73,9 +92,12 @@ public: ...@@ -73,9 +92,12 @@ public:
void buttonClicked(Button* button); void buttonClicked(Button* button);
void checkEnabledState();
private: private:
int hsNumber; int hsNumber1, hsNumber2;
int channelsOnHs1, channelsOnHs2;
String name; String name;
bool isEnabled; bool isEnabled;
...@@ -83,7 +105,8 @@ private: ...@@ -83,7 +105,8 @@ private:
RHD2000Thread* board; RHD2000Thread* board;
RHD2000Editor* editor; RHD2000Editor* editor;
ScopedPointer<UtilityButton> enabledButton; ScopedPointer<UtilityButton> hsButton1;
ScopedPointer<UtilityButton> hsButton2;
}; };
...@@ -102,6 +125,8 @@ private: ...@@ -102,6 +125,8 @@ private:
String name; String name;
String lastLowCutString, lastHighCutString;
RHD2000Thread* board; RHD2000Thread* board;
RHD2000Editor* editor; RHD2000Editor* editor;
......
...@@ -42,8 +42,8 @@ public: ...@@ -42,8 +42,8 @@ public:
ResamplingNodeEditor(GenericProcessor* parentNode, bool useDefaultParameterEditors); ResamplingNodeEditor(GenericProcessor* parentNode, bool useDefaultParameterEditors);
virtual ~ResamplingNodeEditor(); virtual ~ResamplingNodeEditor();
void startAcquisition(); // void startAcquisition();
void stopAcquisition(); //void stopAcquisition();
private: private:
......
...@@ -175,12 +175,11 @@ void SpikeDetectorEditor::sliderEvent(Slider* slider) ...@@ -175,12 +175,11 @@ void SpikeDetectorEditor::sliderEvent(Slider* slider)
void SpikeDetectorEditor::buttonEvent(Button* button) void SpikeDetectorEditor::buttonEvent(Button* button)
{ {
if (electrodeEditorButtons[0]->getToggleState()) // EDIT is active
{
std::cout << "Editing active." << std::endl; if (electrodeButtons.contains((ElectrodeButton*) button))
{
if (electrodeButtons.contains((ElectrodeButton*) button)) if (electrodeEditorButtons[0]->getToggleState()) // EDIT is active
{ {
ElectrodeButton* eb = (ElectrodeButton*) button; ElectrodeButton* eb = (ElectrodeButton*) button;
int electrodeNum = eb->getChannelNum()-1; int electrodeNum = eb->getChannelNum()-1;
...@@ -195,9 +194,27 @@ void SpikeDetectorEditor::buttonEvent(Button* button) ...@@ -195,9 +194,27 @@ void SpikeDetectorEditor::buttonEvent(Button* button)
thresholdSlider->setActive(true); thresholdSlider->setActive(true);
thresholdSlider->setValue(processor->getChannelThreshold(electrodeList->getSelectedItemIndex(), thresholdSlider->setValue(processor->getChannelThreshold(electrodeList->getSelectedItemIndex(),
electrodeButtons.indexOf((ElectrodeButton*) button))); electrodeButtons.indexOf((ElectrodeButton*) button)));
} else {
SpikeDetector* processor = (SpikeDetector*) getProcessor();
ElectrodeButton* eb = (ElectrodeButton*) button;
int electrodeNum = electrodeList->getSelectedItemIndex();
int channelNum = electrodeButtons.indexOf(eb);
processor->setChannelActive(electrodeNum,
channelNum,
button->getToggleState());
std::cout << "Disabling channel " << channelNum <<
" of electrode " << electrodeNum << std::endl;
} }
} }
int num = numElectrodes->getText().getIntValue(); int num = numElectrodes->getText().getIntValue();
if (button == upButton) if (button == upButton)
...@@ -530,7 +547,8 @@ void ElectrodeButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDo ...@@ -530,7 +547,8 @@ void ElectrodeButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDo
g.drawRect(0,0,getWidth(),getHeight(),1.0); g.drawRect(0,0,getWidth(),getHeight(),1.0);
g.drawText(String(chan),0,0,getWidth(),getHeight(),Justification::centred,true); if (chan >= 0)
g.drawText(String(chan),0,0,getWidth(),getHeight(),Justification::centred,true);
} }
......
...@@ -143,7 +143,7 @@ void SpikeDisplayEditor::initializeButtons() ...@@ -143,7 +143,7 @@ void SpikeDisplayEditor::initializeButtons()
allSubChansBtn->setToggleState(true, false); allSubChansBtn->setToggleState(true, false);
x += (w+xPad) * 2; x += (w+xPad) * 2;
for (int i=0; i<nSubChannels; i++) for (int i = 0; i < nSubChannels; i++)
{ {
String s = ""; String s = "";
s += i; s += i;
......
...@@ -170,6 +170,7 @@ void VisualizerEditor::buttonEvent(Button* button) ...@@ -170,6 +170,7 @@ void VisualizerEditor::buttonEvent(Button* button)
{ {
canvas = createNewCanvas(); canvas = createNewCanvas();
canvas->update();
if (isPlaying) if (isPlaying)
canvas->beginAnimation(); canvas->beginAnimation();
......
...@@ -50,6 +50,17 @@ AudioProcessorEditor* FileReader::createEditor() ...@@ -50,6 +50,17 @@ AudioProcessorEditor* FileReader::createEditor()
} }
bool FileReader::isReady()
{
if (input == 0)
{
sendActionMessage("No file selected in File Reader.");
return false;
} else {
return true;
}
}
float FileReader::getDefaultSampleRate() float FileReader::getDefaultSampleRate()
{ {
......
...@@ -60,6 +60,8 @@ public: ...@@ -60,6 +60,8 @@ public:
void updateSettings(); void updateSettings();
bool isReady();
bool isSource() bool isSource()
{ {
return true; return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment