diff --git a/Source/Processors/DataThreads/RHD2000Editor.cpp b/Source/Processors/DataThreads/RHD2000Editor.cpp index 4c9619a5b4d6574ba42188d0cad83c4c4d93dd8a..eb349c85786ad077b77687f43f15f07984c81f73 100644 --- a/Source/Processors/DataThreads/RHD2000Editor.cpp +++ b/Source/Processors/DataThreads/RHD2000Editor.cpp @@ -1,4 +1,4 @@ -/* +/* ------------------------------------------------------------------ This file is part of the Open Ephys GUI @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ +*/ #include "RHD2000Editor.h" #include "../../UI/EditorViewport.h" @@ -31,11 +31,14 @@ #ifdef WIN32 #if (_MSC_VER < 1800) //round doesn't exist on MSVC prior to 2013 version -inline double round(double x) { return floor(x+0.5);} +inline double round(double x) +{ + return floor(x+0.5); +} #endif #endif -FPGAchannelList::FPGAchannelList(GenericProcessor* proc_, Viewport *p, FPGAcanvas*c) : proc(proc_), viewport(p), canvas(c) +FPGAchannelList::FPGAchannelList(GenericProcessor* proc_, Viewport* p, FPGAcanvas* c) : proc(proc_), viewport(p), canvas(c) { channelComponents.clear(); @@ -59,19 +62,19 @@ FPGAchannelList::FPGAchannelList(GenericProcessor* proc_, Viewport *p, FPGAcanva impedanceButton->addListener(this); addAndMakeVisible(impedanceButton); - + gains.clear(); - gains.add( 0.01); - gains.add( 0.1); - gains.add( 1); - gains.add( 2); - gains.add( 5); - gains.add( 10); - gains.add( 20); - gains.add( 50); - gains.add( 100); - gains.add( 500); - gains.add( 1000); + gains.add(0.01); + gains.add(0.1); + gains.add(1); + gains.add(2); + gains.add(5); + gains.add(10); + gains.add(20); + gains.add(50); + gains.add(100); + gains.add(500); + gains.add(1000); update(); @@ -79,18 +82,18 @@ FPGAchannelList::FPGAchannelList(GenericProcessor* proc_, Viewport *p, FPGAcanva FPGAchannelList::~FPGAchannelList() { - + } void FPGAchannelList::paint(Graphics& g) { } -void FPGAchannelList::buttonClicked(Button *btn) +void FPGAchannelList::buttonClicked(Button* btn) { if (btn == impedanceButton) { - RHD2000Editor *p = (RHD2000Editor*)proc->getEditor(); + RHD2000Editor* p = (RHD2000Editor*)proc->getEditor(); p->measureImpedance(); } } @@ -112,14 +115,15 @@ void FPGAchannelList::update() int streamColumn[MAX_NUM_DATA_STREAMS+1]; int numChannelsPerStream[MAX_NUM_DATA_STREAMS+1]; - for (int k=0;k<MAX_NUM_DATA_STREAMS+1;k++) { + for (int k=0; k<MAX_NUM_DATA_STREAMS+1; k++) + { numChannelsPerStream[k] = 0; streamActive[k] = false; streamColumn[k] = 0; } int columnWidth =330; - for (int k=0;k<numChannels;k++) + for (int k=0; k<numChannels; k++) { if (streamActive[stream[k]] == false) { @@ -139,12 +143,12 @@ void FPGAchannelList::update() streamNames.add("Port D1"); streamNames.add("Port D2"); streamNames.add("ADC"); - - for (int k=0;k<MAX_NUM_DATA_STREAMS+1;k++) + + for (int k=0; k<MAX_NUM_DATA_STREAMS+1; k++) { if (streamActive[k]) { - Label *lbl = new Label(streamNames[k],streamNames[k]); + Label* lbl = new Label(streamNames[k],streamNames[k]); lbl->setEditable(false); lbl->setBounds(10+streamColumn[k],40,columnWidth, 25); lbl->setJustificationType(juce::Justification::centred); @@ -157,39 +161,41 @@ void FPGAchannelList::update() } // add buttons for all DATA,AUX,channels - for (int k=0;k<numChannels;k++) + for (int k=0; k<numChannels; k++) + { + int channelGainIndex = 1; + float ch_gain = oldgains[k]/proc->getDefaultBitVolts(); + for (int j=0; j<gains.size(); j++) { - int channelGainIndex = 1; - float ch_gain = oldgains[k]/proc->getDefaultBitVolts(); - for (int j=0;j<gains.size();j++) { - if (fabs(gains[j]-ch_gain) < 1e-3) { - channelGainIndex = j; - break; - } + if (fabs(gains[j]-ch_gain) < 1e-3) + { + channelGainIndex = j; + break; } + } - FPGAchannelComponent* comp = new FPGAchannelComponent(this, stream[k],orig_number[k],types[k],channelGainIndex+1, names[k],gains); - comp->setBounds(10+streamColumn[stream[k]],70+numChannelsPerStream[stream[k]]*22,columnWidth,22); - numChannelsPerStream[stream[k]]++; + FPGAchannelComponent* comp = new FPGAchannelComponent(this, stream[k],orig_number[k],types[k],channelGainIndex+1, names[k],gains); + comp->setBounds(10+streamColumn[stream[k]],70+numChannelsPerStream[stream[k]]*22,columnWidth,22); + numChannelsPerStream[stream[k]]++; - comp->setUserDefinedData(k); - addAndMakeVisible(comp); - channelComponents.add(comp); - } + comp->setUserDefinedData(k); + addAndMakeVisible(comp); + channelComponents.add(comp); + } StringArray ttlNames; proc->getEventChannelNames(ttlNames); // add buttons for TTL channels - for (int k=0;k<ttlNames.size();k++) + for (int k=0; k<ttlNames.size(); k++) { FPGAchannelComponent* comp = new FPGAchannelComponent(this,-1,k, EVENT_CHANNEL,-1, ttlNames[k],gains); - comp->setBounds( 10+numActiveStreams*columnWidth,70+k*22,columnWidth,22); - comp->setUserDefinedData(k); - addAndMakeVisible(comp); - channelComponents.add(comp); + comp->setBounds(10+numActiveStreams*columnWidth,70+k*22,columnWidth,22); + comp->setUserDefinedData(k); + addAndMakeVisible(comp); + channelComponents.add(comp); } - Label *lbl = new Label("TTL Events","TTL Events"); + Label* lbl = new Label("TTL Events","TTL Events"); lbl->setEditable(false); lbl->setBounds(numActiveStreams*columnWidth,40,columnWidth, 25); lbl->setJustificationType(juce::Justification::centred); @@ -202,7 +208,7 @@ void FPGAchannelList::update() void FPGAchannelList::disableAll() { - for (int k=0;k<channelComponents.size();k++) + for (int k=0; k<channelComponents.size(); k++) { channelComponents[k]->disableEdit(); } @@ -210,7 +216,7 @@ void FPGAchannelList::disableAll() void FPGAchannelList::enableAll() { - for (int k=0;k<channelComponents.size();k++) + for (int k=0; k<channelComponents.size(); k++) { channelComponents[k]->enableEdit(); } @@ -237,16 +243,17 @@ int FPGAchannelList::getNumChannels() return 0; } -void FPGAchannelList::comboBoxChanged(ComboBox *b) +void FPGAchannelList::comboBoxChanged(ComboBox* b) { if (b == numberingScheme) { - SourceNode* p = (SourceNode* )proc; + SourceNode* p = (SourceNode*)proc; int scheme = numberingScheme->getSelectedId(); if (scheme == 1) { p->setDefaultNamingScheme(scheme); - } else if (scheme == 2) + } + else if (scheme == 2) { p->setDefaultNamingScheme(scheme); } @@ -257,11 +264,12 @@ void FPGAchannelList::comboBoxChanged(ComboBox *b) void FPGAchannelList::updateImpedance(Array<int> streams, Array<int> channels, Array<float> magnitude, Array<float> phase) { - for (int k=0;k<streams.size();k++) + for (int k=0; k<streams.size(); k++) + { + for (int j=k; j<stream.size(); j++) { - for (int j=k;j<stream.size();j++) + if (stream[j] == streams[k] && types[j] == DATA_CHANNEL && orig_number[j] == channels[k]) { - if (stream[j] == streams[k] && types[j] == DATA_CHANNEL && orig_number[j] == channels[k]) { channelComponents[j]->setImpedanceValues(magnitude[k],phase[k]); break; } @@ -290,13 +298,15 @@ FPGAchannelComponent::FPGAchannelComponent(FPGAchannelList* cl, int stream_, int addAndMakeVisible(editName); if (gainIndex > 0) { - + gainComboBox = new ComboBox("Gains"); - for (int k=0;k<gains.size();k++) + for (int k=0; k<gains.size(); k++) { - if (gains[k] < 1) { + if (gains[k] < 1) + { gainComboBox->addItem("x"+String(gains[k],2),k+1); - } else + } + else { gainComboBox->addItem("x"+String((int)gains[k]),k+1); } @@ -304,7 +314,8 @@ FPGAchannelComponent::FPGAchannelComponent(FPGAchannelList* cl, int stream_, int gainComboBox->setSelectedId(gainIndex, sendNotification); gainComboBox->addListener(this); addAndMakeVisible(gainComboBox); - } else + } + else { gainComboBox = nullptr; } @@ -315,14 +326,15 @@ FPGAchannelComponent::FPGAchannelComponent(FPGAchannelList* cl, int stream_, int impedance->setFont(Font("Default", 13, Font::plain)); impedance->setEditable(false); addAndMakeVisible(impedance); - } else + } + else { impedance = nullptr; } } FPGAchannelComponent::~FPGAchannelComponent() { - + } void FPGAchannelComponent::setImpedanceValues(float mag, float phase) @@ -333,9 +345,10 @@ void FPGAchannelComponent::setImpedanceValues(float mag, float phase) impedance->setText(String(mag/1e6,2)+" mOhm, "+String((int)phase) + " deg",juce::NotificationType::dontSendNotification); else if (mag > 1000) impedance->setText(String(mag/1e3,0)+" kOhm, "+String((int)phase) + " deg" ,juce::NotificationType::dontSendNotification); - else + else impedance->setText(String(mag,0)+" Ohm, "+String((int)phase) + " deg" ,juce::NotificationType::dontSendNotification); - } else + } + else { } @@ -368,7 +381,7 @@ void FPGAchannelComponent::enableEdit() editName->setEnabled(true); } -void FPGAchannelComponent::buttonClicked(Button *btn) +void FPGAchannelComponent::buttonClicked(Button* btn) { } @@ -416,12 +429,12 @@ FPGAcanvas::~FPGAcanvas() { } -void FPGAcanvas::setParameter(int x, float f) +void FPGAcanvas::setParameter(int x, float f) { } -void FPGAcanvas::setParameter(int a, int b, int c, float d) +void FPGAcanvas::setParameter(int a, int b, int c, float d) { } @@ -481,14 +494,14 @@ void FPGAcanvas::updateImpedance(Array<int> streams, Array<int> channels, Array< RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, RHD2000Thread* board_, - bool useDefaultParameterEditors + bool useDefaultParameterEditors ) - : VisualizerEditor(parentNode, useDefaultParameterEditors), board(board_) + : VisualizerEditor(parentNode, useDefaultParameterEditors), board(board_) { canvas = nullptr; desiredWidth = 330; tabText = "FPGA"; - + // add headstage-specific controls (currently just an enable/disable button) for (int i = 0; i < 4; i++) { @@ -497,22 +510,22 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, addAndMakeVisible(hsOptions); hsOptions->setBounds(3, 28+i*20, 70, 18); } - + // add sample rate selection sampleRateInterface = new SampleRateInterface(board, this); addAndMakeVisible(sampleRateInterface); sampleRateInterface->setBounds(80, 25, 100, 50); - + // add Bandwidth selection bandwidthInterface = new BandwidthInterface(board, this); addAndMakeVisible(bandwidthInterface); bandwidthInterface->setBounds(80, 58, 80, 50); - + // add DSP selection dspInterface = new DSPInterface(board, this); addAndMakeVisible(dspInterface); dspInterface->setBounds(80, 58, 80, 50); - + // add rescan button rescanButton = new UtilityButton("RESCAN", Font("Small Text", 13, Font::plain)); rescanButton->setRadius(3.0f); @@ -520,48 +533,50 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, rescanButton->addListener(this); rescanButton->setTooltip("Check for connected headstages"); 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, dontSendNotification); button->setRadioGroupId(999); - + addAndMakeVisible(button); button->addListener(this); - + if (i == 0) { button->setTooltip("Audio monitor left channel"); - } else { + } + else + { button->setTooltip("Audio monitor right channel"); } } - + audioLabel = new Label("audio label", "Audio out"); audioLabel->setBounds(180,25,75,15); audioLabel->setFont(Font("Small Text", 10, Font::plain)); audioLabel->setColour(Label::textColourId, Colours::darkgrey); addAndMakeVisible(audioLabel); - + // add HW audio parameter selection audioInterface = new AudioInterface(board, this); addAndMakeVisible(audioInterface); audioInterface->setBounds(165, 65, 65, 50); - - + + adcButton = new UtilityButton("ADC 1-8", Font("Small Text", 13, Font::plain)); adcButton->setRadius(3.0f); adcButton->setBounds(165,100,65,18); adcButton->addListener(this); adcButton->setClickingTogglesState(true); adcButton->setTooltip("Enable/disable ADC channels"); - addAndMakeVisible(adcButton); - + addAndMakeVisible(adcButton); + // add DSP Offset Button dspoffsetButton = new UtilityButton("DSP", Font("Very Small Text", 13, Font::plain)); dspoffsetButton->setRadius(3.0f); // sets the radius of the button's corners @@ -571,19 +586,19 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, dspoffsetButton->setTooltip("Enable/disable DSP offset removal"); addAndMakeVisible(dspoffsetButton); // makes the button a child component of the editor and makes it visible dspoffsetButton->setToggleState(true, dontSendNotification); - + // add DSP Frequency Selection field dspInterface = new DSPInterface(board, this); addAndMakeVisible(dspInterface); - dspInterface->setBounds(110, 108, 80, 50); + dspInterface->setBounds(110, 108, 80, 50); ttlSettleLabel = new Label("TTL Settle","TTL Settle"); - ttlSettleLabel->setFont( Font("Small Text", 11, Font::plain)); + ttlSettleLabel->setFont(Font("Small Text", 11, Font::plain)); ttlSettleLabel->setBounds(245,80,100,20); ttlSettleLabel->setColour(Label::textColourId, Colours::darkgrey); addAndMakeVisible(ttlSettleLabel); - + ttlSettleCombo = new ComboBox("FastSettleComboBox"); ttlSettleCombo->setBounds(250,100,60,18); ttlSettleCombo->addListener(this); @@ -604,7 +619,7 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, addAndMakeVisible(dacTTLButton); dacHPFlabel = new Label("DAC HPF","DAC HPF"); - dacHPFlabel->setFont( Font("Small Text", 11, Font::plain)); + dacHPFlabel->setFont(Font("Small Text", 11, Font::plain)); dacHPFlabel->setBounds(250,42,100,20); dacHPFlabel->setColour(Label::textColourId, Colours::darkgrey); addAndMakeVisible(dacHPFlabel); @@ -620,12 +635,12 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, } dacHPFcombo->setSelectedId(1, sendNotification); addAndMakeVisible(dacHPFcombo); - + } RHD2000Editor::~RHD2000Editor() { - + } void RHD2000Editor::scanPorts() @@ -651,37 +666,40 @@ void RHD2000Editor::comboBoxChanged(ComboBox* comboBox) if (selectedChannel == 1) { board->setFastTTLSettle(false,0); - } else + } + else { board->setFastTTLSettle(true,selectedChannel-2); } - } else if (comboBox == dacHPFcombo) + } + else if (comboBox == dacHPFcombo) { int selection = dacHPFcombo->getSelectedId(); if (selection == 1) { board->setDAChpf(100,false); - } else + } + else { int HPFvalues[10] = {50,100,200,300,400,500,600,700,800,900}; board->setDAChpf(HPFvalues[selection-2],true); } } } - + void RHD2000Editor::buttonEvent(Button* button) { - VisualizerEditor::buttonEvent(button); + VisualizerEditor::buttonEvent(button); if (button == rescanButton && !acquisitionIsActive) { board->scanPorts(); - + for (int i = 0; i < 4; i++) { headstageOptionsInterfaces[i]->checkEnabledState(); - } - board->updateChannelNames(); + } + board->updateChannelNames(); } else if (button == electrodeButtons[0]) { @@ -696,7 +714,8 @@ void RHD2000Editor::buttonEvent(Button* button) board->enableAdcs(button->getToggleState()); board->updateChannelNames(); getEditorViewport()->makeEditorVisible(this, false, true); - } else if (button == dacTTLButton) + } + else if (button == dacTTLButton) { board->setTTLoutputMode(dacTTLButton->getToggleState()); } @@ -706,7 +725,7 @@ void RHD2000Editor::buttonEvent(Button* button) board->setDSPOffset(button->getToggleState()); getEditorViewport()->makeEditorVisible(this, false, true); } - + } void RHD2000Editor::channelChanged(int chan) @@ -718,62 +737,62 @@ void RHD2000Editor::channelChanged(int chan) electrodeButtons[i]->setChannelNum(chan); electrodeButtons[i]->repaint(); board->assignAudioOut(i, chan); - + } } } void RHD2000Editor::startAcquisition() { - + channelSelector->startAcquisition(); - + rescanButton->setEnabledState(false); - adcButton->setEnabledState(false); + adcButton->setEnabledState(false); dspoffsetButton-> setEnabledState(false); acquisitionIsActive = true; if (canvas !=nullptr) - canvas->channelList->setEnabled(false); + canvas->channelList->setEnabled(false); } void RHD2000Editor::stopAcquisition() { - + channelSelector->stopAcquisition(); - + rescanButton->setEnabledState(true); adcButton->setEnabledState(true); dspoffsetButton-> setEnabledState(true); - + acquisitionIsActive = false; if (canvas != nullptr) canvas->channelList->setEnabled(true); - // canvas->channelList->setEnabled(true); + // canvas->channelList->setEnabled(true); } void RHD2000Editor::saveCustomParameters(XmlElement* xml) { - xml->setAttribute("SampleRate", sampleRateInterface->getSelectedId()); - xml->setAttribute("LowCut", bandwidthInterface->getLowerBandwidth()); - xml->setAttribute("HighCut", bandwidthInterface->getUpperBandwidth()); - xml->setAttribute("ADCsOn", adcButton->getToggleState()); - xml->setAttribute("SampleRate", sampleRateInterface->getSelectedId()); - xml->setAttribute("LowCut", bandwidthInterface->getLowerBandwidth()); - xml->setAttribute("HighCut", bandwidthInterface->getUpperBandwidth()); - xml->setAttribute("ADCsOn", adcButton->getToggleState()); - xml->setAttribute("AudioOutputL", electrodeButtons[0]->getChannelNum()); - xml->setAttribute("AudioOutputR", electrodeButtons[1]->getChannelNum()); - xml->setAttribute("NoiseSlicer", audioInterface->getNoiseSlicerLevel()); - xml->setAttribute("TTLFastSettle", ttlSettleCombo->getSelectedId()); - xml->setAttribute("DAC_TTL", dacTTLButton->getToggleState()); - xml->setAttribute("DAC_HPF", dacHPFcombo->getSelectedId()); - xml->setAttribute("DSPOffset", dspoffsetButton->getToggleState()); - xml->setAttribute("DSPCutoffFreq", dspInterface->getDspCutoffFreq()); + xml->setAttribute("SampleRate", sampleRateInterface->getSelectedId()); + xml->setAttribute("LowCut", bandwidthInterface->getLowerBandwidth()); + xml->setAttribute("HighCut", bandwidthInterface->getUpperBandwidth()); + xml->setAttribute("ADCsOn", adcButton->getToggleState()); + xml->setAttribute("SampleRate", sampleRateInterface->getSelectedId()); + xml->setAttribute("LowCut", bandwidthInterface->getLowerBandwidth()); + xml->setAttribute("HighCut", bandwidthInterface->getUpperBandwidth()); + xml->setAttribute("ADCsOn", adcButton->getToggleState()); + xml->setAttribute("AudioOutputL", electrodeButtons[0]->getChannelNum()); + xml->setAttribute("AudioOutputR", electrodeButtons[1]->getChannelNum()); + xml->setAttribute("NoiseSlicer", audioInterface->getNoiseSlicerLevel()); + xml->setAttribute("TTLFastSettle", ttlSettleCombo->getSelectedId()); + xml->setAttribute("DAC_TTL", dacTTLButton->getToggleState()); + xml->setAttribute("DAC_HPF", dacHPFcombo->getSelectedId()); + xml->setAttribute("DSPOffset", dspoffsetButton->getToggleState()); + xml->setAttribute("DSPCutoffFreq", dspInterface->getDspCutoffFreq()); } void RHD2000Editor::loadCustomParameters(XmlElement* xml) { - + sampleRateInterface->setSelectedId(xml->getIntAttribute("SampleRate")); bandwidthInterface->setLowerBandwidth(xml->getDoubleAttribute("LowCut")); bandwidthInterface->setUpperBandwidth(xml->getDoubleAttribute("HighCut")); @@ -785,7 +804,7 @@ void RHD2000Editor::loadCustomParameters(XmlElement* xml) audioInterface->setNoiseSlicerLevel(xml->getIntAttribute("NoiseSlicer")); ttlSettleCombo->setSelectedId(xml->getIntAttribute("TTLFastSettle")); dacTTLButton->setToggleState(xml->getBoolAttribute("DAC_TTL"), sendNotification); - dacHPFcombo->setSelectedId(xml->getIntAttribute("DAC_HPF")); + dacHPFcombo->setSelectedId(xml->getIntAttribute("DAC_HPF")); dspoffsetButton->setToggleState(xml->getBoolAttribute("DSPOffset"), sendNotification); dspInterface->setDspCutoffFreq(xml->getDoubleAttribute("DSPCutoffFreq")); } @@ -804,90 +823,90 @@ Visualizer* RHD2000Editor::createNewCanvas() BandwidthInterface::BandwidthInterface(RHD2000Thread* board_, RHD2000Editor* editor_) : -board(board_), editor(editor_) + board(board_), editor(editor_) { - + name = "Bandwidth"; - + lastHighCutString = "7500"; lastLowCutString = "1"; - + actualUpperBandwidth = 7500.0f; actualLowerBandwidth = 1.0f; - + 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->addListener(this); upperBandwidthSelection->setBounds(30,30,60,20); upperBandwidthSelection->setColour(Label::textColourId, Colours::darkgrey); addAndMakeVisible(upperBandwidthSelection); - - + + lowerBandwidthSelection = new Label("LowerBandwidth",lastLowCutString); lowerBandwidthSelection->setEditable(true,false,false); lowerBandwidthSelection->addListener(this); lowerBandwidthSelection->setBounds(25,10,60,20); lowerBandwidthSelection->setColour(Label::textColourId, Colours::darkgrey); - + addAndMakeVisible(lowerBandwidthSelection); - - - + + + } BandwidthInterface::~BandwidthInterface() { - + } void BandwidthInterface::labelTextChanged(Label* label) { - + if (!(editor->acquisitionIsActive) && board->foundInputSource()) { if (label == upperBandwidthSelection) { - + 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; } - + actualUpperBandwidth = board->setUpperBandwidth(requestedValue); - + std::cout << "Setting Upper Bandwidth to " << requestedValue << std::endl; std::cout << "Actual Upper Bandwidth: " << actualUpperBandwidth << std::endl; label->setText(String(round(actualUpperBandwidth*10.f)/10.f), dontSendNotification); - + } else { - + 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; } - + actualLowerBandwidth = board->setLowerBandwidth(requestedValue); - + std::cout << "Setting Lower Bandwidth to " << requestedValue << std::endl; std::cout << "Actual Lower Bandwidth: " << actualLowerBandwidth << std::endl; - + label->setText(String(round(actualLowerBandwidth*10.f)/10.f), dontSendNotification); } } @@ -900,7 +919,7 @@ void BandwidthInterface::labelTextChanged(Label* label) label->setText(lastLowCutString, dontSendNotification); return; } - + } void BandwidthInterface::setLowerBandwidth(double value) @@ -928,28 +947,28 @@ double BandwidthInterface::getUpperBandwidth() void BandwidthInterface::paint(Graphics& g) { - + g.setColour(Colours::darkgrey); - + g.setFont(Font("Small Text",10,Font::plain)); - + 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 -------------------------------------------------------------------- SampleRateInterface::SampleRateInterface(RHD2000Thread* board_, RHD2000Editor* editor_) : -board(board_), editor(editor_) + board(board_), editor(editor_) { - + name = "Sample Rate"; - + sampleRateOptions.add("1.00 kS/s"); sampleRateOptions.add("1.25 kS/s"); sampleRateOptions.add("1.50 kS/s"); @@ -967,22 +986,22 @@ board(board_), editor(editor_) sampleRateOptions.add("20.0 kS/s"); sampleRateOptions.add("25.0 kS/s"); sampleRateOptions.add("30.0 kS/s"); - - + + rateSelection = new ComboBox("Sample Rate"); rateSelection->addItemList(sampleRateOptions, 1); rateSelection->setSelectedId(17, dontSendNotification); rateSelection->addListener(this); - + rateSelection->setBounds(0,15,300,20); addAndMakeVisible(rateSelection); - - + + } SampleRateInterface::~SampleRateInterface() { - + } void SampleRateInterface::comboBoxChanged(ComboBox* cb) @@ -992,9 +1011,9 @@ void SampleRateInterface::comboBoxChanged(ComboBox* cb) if (cb == rateSelection) { board->setSampleRate(cb->getSelectedId()-1); - + std::cout << "Setting sample rate to index " << cb->getSelectedId()-1 << std::endl; - + editor->getEditorViewport()->makeEditorVisible(editor, false, true); } } @@ -1013,13 +1032,13 @@ void SampleRateInterface::setSelectedId(int id) void SampleRateInterface::paint(Graphics& g) { - + g.setColour(Colours::darkgrey); - + g.setFont(Font("Small Text",10,Font::plain)); - + g.drawText(name, 0, 0, 200, 15, Justification::left, false); - + } @@ -1028,9 +1047,9 @@ void SampleRateInterface::paint(Graphics& g) HeadstageOptionsInterface::HeadstageOptionsInterface(RHD2000Thread* board_, RHD2000Editor* editor_, int hsNum) : -isEnabled(false), board(board_), editor(editor_) + isEnabled(false), board(board_), editor(editor_) { - + switch (hsNum) { case 0 : @@ -1048,15 +1067,15 @@ isEnabled(false), board(board_), editor(editor_) default: name = "X"; } - + hsNumber1 = hsNum*2; // data stream 1 hsNumber2 = hsNumber1+1; // data stream 2 - + channelsOnHs1 = 0; channelsOnHs2 = 0; - - - + + + hsButton1 = new UtilityButton(" ", Font("Small Text", 13, Font::plain)); hsButton1->setRadius(3.0f); hsButton1->setBounds(23,1,20,17); @@ -1064,7 +1083,7 @@ isEnabled(false), board(board_), editor(editor_) 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); @@ -1072,20 +1091,20 @@ isEnabled(false), board(board_), editor(editor_) hsButton2->setCorners(false, true, false, true); hsButton2->addListener(this); addAndMakeVisible(hsButton2); - + checkEnabledState(); } HeadstageOptionsInterface::~HeadstageOptionsInterface() { - + } void HeadstageOptionsInterface::checkEnabledState() { isEnabled = (board->isHeadstageEnabled(hsNumber1) || board->isHeadstageEnabled(hsNumber2)); - + if (board->isHeadstageEnabled(hsNumber1)) { channelsOnHs1 = 32; @@ -1098,7 +1117,7 @@ void HeadstageOptionsInterface::checkEnabledState() hsButton1->setLabel(" "); hsButton1->setEnabledState(false); } - + if (board->isHeadstageEnabled(hsNumber2)) { channelsOnHs2 = 32; @@ -1111,17 +1130,17 @@ void HeadstageOptionsInterface::checkEnabledState() hsButton2->setLabel(" "); hsButton2->setEnabledState(false); } - + repaint(); - + } void HeadstageOptionsInterface::buttonClicked(Button* button) { - + if (!(editor->acquisitionIsActive) && board->foundInputSource()) { - + //std::cout << "Acquisition is not active" << std::endl; if (button == hsButton1) { @@ -1129,12 +1148,12 @@ void HeadstageOptionsInterface::buttonClicked(Button* button) channelsOnHs1 = 16; else channelsOnHs1 = 32; - + //std::cout << "HS1 has " << channelsOnHs1 << " channels." << std::endl; - + hsButton1->setLabel(String(channelsOnHs1)); board->setNumChannels(hsNumber1, channelsOnHs1); - + board->updateChannelNames(); editor->updateSettings(); @@ -1145,64 +1164,64 @@ void HeadstageOptionsInterface::buttonClicked(Button* button) channelsOnHs2 = 16; else channelsOnHs2 = 32; - + hsButton2->setLabel(String(channelsOnHs2)); board->setNumChannels(hsNumber2, channelsOnHs2); board->updateChannelNames(); editor->updateSettings(); } - - + + editor->getEditorViewport()->makeEditorVisible(editor, false, true); } - + } void HeadstageOptionsInterface::paint(Graphics& g) { g.setColour(Colours::lightgrey); - + g.fillRoundedRectangle(5,0,getWidth()-10,getHeight(),4.0f); - + if (isEnabled) g.setColour(Colours::black); else g.setColour(Colours::grey); - + g.setFont(Font("Small Text",15,Font::plain)); - + g.drawText(name, 8, 2, 200, 15, Justification::left, false); - + } // (Direct OpalKelly) Audio Options -------------------------------------------------------------------- AudioInterface::AudioInterface(RHD2000Thread* board_, - RHD2000Editor* editor_) : -board(board_), editor(editor_) + RHD2000Editor* editor_) : + board(board_), editor(editor_) { - + name = "Noise Slicer"; - + lastNoiseSlicerString = "0"; - + actualNoiseSlicerLevel = 0.0f; - + noiseSlicerLevelSelection = new Label("Noise Slicer",lastNoiseSlicerString); // this is currently set in RHD2000Thread, the cleaner would be to set it here again noiseSlicerLevelSelection->setEditable(true,false,false); noiseSlicerLevelSelection->addListener(this); noiseSlicerLevelSelection->setBounds(30,10,30,20); noiseSlicerLevelSelection->setColour(Label::textColourId, Colours::darkgrey); addAndMakeVisible(noiseSlicerLevelSelection); - - + + } AudioInterface::~AudioInterface() { - + } @@ -1212,27 +1231,28 @@ void AudioInterface::labelTextChanged(Label* label) { if (label == noiseSlicerLevelSelection) { - + Value val = label->getTextValue(); int requestedValue = int(val.getValue()); // Note that it might be nice to translate to actual uV levels (16*value) - + if (requestedValue < 0 || requestedValue > 127) { editor->sendActionMessage("Value out of range."); - + label->setText(lastNoiseSlicerString, dontSendNotification); - + return; } - + actualNoiseSlicerLevel = board->setNoiseSlicerLevel(requestedValue); - + std::cout << "Setting Noise Slicer Level to " << requestedValue << std::endl; label->setText(String((roundFloatToInt)(actualNoiseSlicerLevel)), dontSendNotification); - + } } - else { + else + { Value val = label->getTextValue(); int requestedValue = int(val.getValue()); // Note that it might be nice to translate to actual uV levels (16*value) if (requestedValue < 0 || requestedValue > 127) @@ -1258,15 +1278,15 @@ int AudioInterface::getNoiseSlicerLevel() void AudioInterface::paint(Graphics& g) { - + g.setColour(Colours::darkgrey); - + g.setFont(Font("Small Text",9,Font::plain)); - + g.drawText(name, 0, 0, 200, 15, Justification::left, false); - + g.drawText("Level: ", 0, 10, 200, 20, Justification::left, false); - + } @@ -1274,51 +1294,51 @@ void AudioInterface::paint(Graphics& g) // DSP Options -------------------------------------------------------------------- DSPInterface::DSPInterface(RHD2000Thread* board_, - RHD2000Editor* editor_) : -board(board_), editor(editor_) + RHD2000Editor* editor_) : + board(board_), editor(editor_) { name = "DSP"; - + dspOffsetSelection = new Label("DspOffsetSelection",String(round(board->getDspCutoffFreq()*10.f)/10.f)); dspOffsetSelection->setEditable(true,false,false); dspOffsetSelection->addListener(this); dspOffsetSelection->setBounds(0,0,30,20); dspOffsetSelection->setColour(Label::textColourId, Colours::darkgrey); - + addAndMakeVisible(dspOffsetSelection); - + } DSPInterface::~DSPInterface() { - + } void DSPInterface::labelTextChanged(Label* label) { - + if (!(editor->acquisitionIsActive) && board->foundInputSource()) { if (label == dspOffsetSelection) { - + Value val = label->getTextValue(); double requestedValue = double(val.getValue()); - + actualDspCutoffFreq = board->setDspCutoffFreq(requestedValue); - + std::cout << "Setting DSP Cutoff Freq to " << requestedValue << std::endl; std::cout << "Actual DSP Cutoff Freq: " << actualDspCutoffFreq << std::endl; label->setText(String(round(actualDspCutoffFreq*10.f)/10.f), dontSendNotification); - + } } else if (editor->acquisitionIsActive) { editor->sendActionMessage("Can't change DSP cutoff while acquisition is active!"); } - + } void DSPInterface::setDspCutoffFreq(double value) @@ -1335,9 +1355,9 @@ double DSPInterface::getDspCutoffFreq() void DSPInterface::paint(Graphics& g) { - + g.setColour(Colours::darkgrey); - + g.setFont(Font("Small Text",10,Font::plain)); } diff --git a/Source/Processors/DataThreads/RHD2000Thread.cpp b/Source/Processors/DataThreads/RHD2000Thread.cpp index e4969c8c4f2b74396b1d16e25766df273dad252b..9410d665637bb8108f5602c856ccc5654f22dd5d 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.cpp +++ b/Source/Processors/DataThreads/RHD2000Thread.cpp @@ -542,11 +542,11 @@ void RHD2000Thread::scanPorts() { //We just add it like a second headstage, allowing only one RHD2164 per channel //This would need to change - evalBoard->setDataSource(stream+1,initStreamDdrPorts[stream]); - enableHeadstage(stream,true); - enableHeadstage(stream+1,true); - chipId.set(stream+1,CHIP_ID_RHD2164_B); - stream++; + evalBoard->setDataSource(stream+1,initStreamDdrPorts[stream]); + enableHeadstage(stream,true); + enableHeadstage(stream+1,true); + chipId.set(stream+1,CHIP_ID_RHD2164_B); + stream++; } else enableHeadstage(stream, true); @@ -922,20 +922,20 @@ double RHD2000Thread::setLowerBandwidth(double lower) return actualLowerBandwidth; } - + double RHD2000Thread::setDspCutoffFreq(double freq) { - + desiredDspCutoffFreq = freq; - + updateRegisters(); - + return actualDspCutoffFreq; } double RHD2000Thread::getDspCutoffFreq() { - + return actualDspCutoffFreq; } @@ -943,7 +943,8 @@ void RHD2000Thread::setDSPOffset(bool state) { dspEnabled = state; updateRegisters(); - +} + void RHD2000Thread::setTTLoutputMode(bool state) { ttlMode = state; @@ -962,7 +963,7 @@ void RHD2000Thread::setFastTTLSettle(bool state, int channel) { fastTTLSettleEnabled = state; fastSettleTTLChannel = channel; - dacOutputShouldChange = true; + dacOutputShouldChange = true; } int RHD2000Thread::setNoiseSlicerLevel(int level)