From fdae755720ba07377e62655a4a9472ac2919ba84 Mon Sep 17 00:00:00 2001 From: Nikolas <nikolaskaralis@gmail.com> Date: Wed, 1 Oct 2014 20:11:03 +0200 Subject: [PATCH] Added DSP button and freq selection. --- .../open-ephys.xcodeproj/project.pbxproj | 4 +- .../Processors/DataThreads/RHD2000Thread.cpp | 26 ++ Source/Processors/DataThreads/RHD2000Thread.h | 4 + Source/Processors/Editors/RHD2000Editor.cpp | 403 +++++++++++------- Source/Processors/Editors/RHD2000Editor.h | 31 ++ .../Processors/Editors/SourceNodeEditor.cpp | 2 + Source/Processors/Editors/SourceNodeEditor.h | 1 + .../Visualization/LfpDisplayCanvas.cpp | 28 +- 8 files changed, 342 insertions(+), 157 deletions(-) diff --git a/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj b/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj index 225f7eae1..46cdbcc7a 100644 --- a/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj @@ -2752,7 +2752,6 @@ 9D050A509BEB9E3879DA35C6 /* ostrich.ttf */, 66F524552E8DE88CDC2E40FD /* silkscreen-serialized */, D01254FA41688494C3CB0889 /* silkscreen.ttf */, - 61317B5191E05925F232E18C /* unibody-8.otf */, ); name = Fonts; sourceTree = "<group>"; @@ -3514,7 +3513,7 @@ 41375E3272D6505F75FDEEEB /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0440; + LastUpgradeCheck = 0600; }; buildConfigurationList = 3B096175C0B17BFA58475A08 /* Build configuration list for PBXProject "open-ephys" */; compatibilityVersion = "Xcode 3.2"; @@ -3768,6 +3767,7 @@ GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; + ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "open-ephys"; WARNING_CFLAGS = "-Wreorder"; ZERO_LINK = NO; diff --git a/Source/Processors/DataThreads/RHD2000Thread.cpp b/Source/Processors/DataThreads/RHD2000Thread.cpp index c5805e0a1..a87583312 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.cpp +++ b/Source/Processors/DataThreads/RHD2000Thread.cpp @@ -653,6 +653,7 @@ double RHD2000Thread::setUpperBandwidth(double upper) return actualUpperBandwidth; } + double RHD2000Thread::setLowerBandwidth(double lower) { desiredLowerBandwidth = lower; @@ -662,6 +663,29 @@ double RHD2000Thread::setLowerBandwidth(double lower) return actualLowerBandwidth; } +double RHD2000Thread::setDspCutoffFreq(double freq) +{ + + desiredDspCutoffFreq = freq; + + updateRegisters(); + + return actualDspCutoffFreq; +} + +double RHD2000Thread::getDspCutoffFreq() +{ + + return actualDspCutoffFreq; +} + +void RHD2000Thread::setDSPOffset(bool state) +{ + dspEnabled = state; + updateRegisters(); + +} + int RHD2000Thread::setNoiseSlicerLevel(int level) { desiredNoiseSlicerLevel = level; @@ -912,9 +936,11 @@ void RHD2000Thread::updateRegisters() // Before generating register configuration command sequences, set amplifier // bandwidth paramters. actualDspCutoffFreq = chipRegisters.setDspCutoffFreq(desiredDspCutoffFreq); + //std::cout << "DSP Cutoff Frequency " << actualDspCutoffFreq << std::endl; actualLowerBandwidth = chipRegisters.setLowerBandwidth(desiredLowerBandwidth); actualUpperBandwidth = chipRegisters.setUpperBandwidth(desiredUpperBandwidth); chipRegisters.enableDsp(dspEnabled); + //std::cout << "DSP Offset Status " << dspEnabled << std::endl; // turn on aux inputs chipRegisters.enableAux1(true); diff --git a/Source/Processors/DataThreads/RHD2000Thread.h b/Source/Processors/DataThreads/RHD2000Thread.h index 0f9667b46..203cfa0b0 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.h +++ b/Source/Processors/DataThreads/RHD2000Thread.h @@ -72,6 +72,10 @@ public: double setUpperBandwidth(double upper); // set desired BW, returns actual BW double setLowerBandwidth(double lower); + double setDspCutoffFreq(double freq); + double getDspCutoffFreq(); + + void setDSPOffset(bool state); int setNoiseSlicerLevel(int level); diff --git a/Source/Processors/Editors/RHD2000Editor.cpp b/Source/Processors/Editors/RHD2000Editor.cpp index 1eb7808ea..5f6d87906 100644 --- a/Source/Processors/Editors/RHD2000Editor.cpp +++ b/Source/Processors/Editors/RHD2000Editor.cpp @@ -1,25 +1,25 @@ /* - ------------------------------------------------------------------ - - This file is part of the Open Ephys GUI - Copyright (C) 2013 Open Ephys - - ------------------------------------------------------------------ - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - -*/ + ------------------------------------------------------------------ + + This file is part of the Open Ephys GUI + Copyright (C) 2013 Open Ephys + + ------------------------------------------------------------------ + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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" @@ -38,11 +38,11 @@ inline double round(double x) { return floor(x+0.5);} RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, RHD2000Thread* board_, bool useDefaultParameterEditors - ) - : GenericEditor(parentNode, useDefaultParameterEditors), board(board_) + ) +: GenericEditor(parentNode, useDefaultParameterEditors), board(board_) { desiredWidth = 260; - + // add headstage-specific controls (currently just an enable/disable button) for (int i = 0; i < 4; i++) { @@ -51,17 +51,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, 65, 80, 50); - + 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); @@ -69,20 +74,20 @@ 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"); @@ -92,20 +97,20 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, 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); @@ -113,13 +118,27 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, adcButton->setClickingTogglesState(true); adcButton->setTooltip("Enable/disable ADC channels"); 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 + dspoffsetButton->setBounds(80, 108,30,18); // sets the x position, y position, width, and height of the button + dspoffsetButton->addListener(this); + dspoffsetButton->setClickingTogglesState(true); // makes the button toggle its state when clicked + 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); + } RHD2000Editor::~RHD2000Editor() { - + } void RHD2000Editor::scanPorts() @@ -129,16 +148,16 @@ void RHD2000Editor::scanPorts() void RHD2000Editor::buttonEvent(Button* button) { - + if (button == rescanButton && !acquisitionIsActive) { board->scanPorts(); - + for (int i = 0; i < 4; i++) { headstageOptionsInterfaces[i]->checkEnabledState(); } - + } else if (button == electrodeButtons[0]) { @@ -153,7 +172,13 @@ void RHD2000Editor::buttonEvent(Button* button) board->enableAdcs(button->getToggleState()); getEditorViewport()->makeEditorVisible(this, false, true); } - + else if (button == dspoffsetButton && !acquisitionIsActive) + { + std::cout << "DSP offset " << button->getToggleState() << std::endl; + board->setDSPOffset(button->getToggleState()); + getEditorViewport()->makeEditorVisible(this, false, true); + } + } void RHD2000Editor::channelChanged(int chan) @@ -164,7 +189,7 @@ void RHD2000Editor::channelChanged(int chan) { electrodeButtons[i]->setChannelNum(chan); electrodeButtons[i]->repaint(); - + board->assignAudioOut(i, chan-1); } } @@ -172,26 +197,28 @@ void RHD2000Editor::channelChanged(int chan) void RHD2000Editor::startAcquisition() { - + channelSelector->startAcquisition(); - + rescanButton->setEnabledState(false); adcButton->setEnabledState(false); - + dspoffsetButton-> setEnabledState(false); + acquisitionIsActive = true; - + } void RHD2000Editor::stopAcquisition() { - + channelSelector->stopAcquisition(); - + rescanButton->setEnabledState(true); adcButton->setEnabledState(true); - + dspoffsetButton-> setEnabledState(true); + acquisitionIsActive = false; - + } void RHD2000Editor::saveCustomParameters(XmlElement* xml) @@ -200,16 +227,19 @@ void RHD2000Editor::saveCustomParameters(XmlElement* xml) xml->setAttribute("LowCut", bandwidthInterface->getLowerBandwidth()); xml->setAttribute("HighCut", bandwidthInterface->getUpperBandwidth()); xml->setAttribute("ADCsOn", adcButton->getToggleState()); + 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")); adcButton->setToggleState(xml->getBoolAttribute("ADCsOn"), sendNotification); - + dspoffsetButton->setToggleState(xml->getBoolAttribute("DSPOffset"), sendNotification); + dspInterface->setDspCutoffFreq(xml->getDoubleAttribute("DSPCutoffFreq")); } @@ -217,90 +247,90 @@ void RHD2000Editor::loadCustomParameters(XmlElement* xml) 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); } } @@ -313,7 +343,7 @@ void BandwidthInterface::labelTextChanged(Label* label) label->setText(lastLowCutString, dontSendNotification); return; } - + } void BandwidthInterface::setLowerBandwidth(double value) @@ -342,28 +372,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"); @@ -381,22 +411,22 @@ SampleRateInterface::SampleRateInterface(RHD2000Thread* board_, 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) @@ -406,9 +436,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); } } @@ -427,13 +457,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); - + } @@ -442,9 +472,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 : @@ -462,15 +492,15 @@ HeadstageOptionsInterface::HeadstageOptionsInterface(RHD2000Thread* board_, 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); @@ -478,7 +508,7 @@ HeadstageOptionsInterface::HeadstageOptionsInterface(RHD2000Thread* board_, 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); @@ -486,20 +516,20 @@ HeadstageOptionsInterface::HeadstageOptionsInterface(RHD2000Thread* board_, 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; @@ -512,7 +542,7 @@ void HeadstageOptionsInterface::checkEnabledState() hsButton1->setLabel(" "); hsButton1->setEnabledState(false); } - + if (board->isHeadstageEnabled(hsNumber2)) { channelsOnHs2 = 32; @@ -525,17 +555,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) { @@ -543,12 +573,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); - + } else if (button == hsButton2) { @@ -556,33 +586,33 @@ void HeadstageOptionsInterface::buttonClicked(Button* button) channelsOnHs2 = 16; else channelsOnHs2 = 32; - + hsButton2->setLabel(String(channelsOnHs2)); board->setNumChannels(hsNumber2, channelsOnHs2); } - - + + 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); - + } @@ -590,28 +620,28 @@ void HeadstageOptionsInterface::paint(Graphics& g) AudioInterface::AudioInterface(RHD2000Thread* board_, RHD2000Editor* editor_) : - board(board_), editor(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() { - + } @@ -621,24 +651,24 @@ 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 @@ -668,15 +698,86 @@ 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); + +} + + + +// DSP Options -------------------------------------------------------------------- +DSPInterface::DSPInterface(RHD2000Thread* board_, + 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) +{ + actualDspCutoffFreq = board->setDspCutoffFreq(value); + dspOffsetSelection->setText(String(round(actualDspCutoffFreq*10.f)/10.f), dontSendNotification); +} + + +double DSPInterface::getDspCutoffFreq() +{ + return actualDspCutoffFreq; +} + +void DSPInterface::paint(Graphics& g) +{ + + g.setColour(Colours::darkgrey); + + g.setFont(Font("Small Text",10,Font::plain)); + +} diff --git a/Source/Processors/Editors/RHD2000Editor.h b/Source/Processors/Editors/RHD2000Editor.h index c7413a13b..706d6e18b 100644 --- a/Source/Processors/Editors/RHD2000Editor.h +++ b/Source/Processors/Editors/RHD2000Editor.h @@ -32,6 +32,7 @@ class HeadstageOptionsInterface; class SampleRateInterface; class BandwidthInterface; +class DSPInterface; class AudioInterface; class RHD2000Thread; @@ -72,11 +73,14 @@ private: ScopedPointer<SampleRateInterface> sampleRateInterface; ScopedPointer<BandwidthInterface> bandwidthInterface; + ScopedPointer<DSPInterface> dspInterface; ScopedPointer<AudioInterface> audioInterface; ScopedPointer<UtilityButton> rescanButton; ScopedPointer<UtilityButton> adcButton; + + ScopedPointer<UtilityButton> dspoffsetButton; ScopedPointer<Label> audioLabel; @@ -149,6 +153,33 @@ private: }; +class DSPInterface : public Component, +public Label::Listener +{ +public: + DSPInterface(RHD2000Thread*, RHD2000Editor*); + ~DSPInterface(); + + void paint(Graphics& g); + void labelTextChanged(Label* te); + + void setDspCutoffFreq(double value); + double getDspCutoffFreq(); + +private: + + String name; + + RHD2000Thread* board; + RHD2000Editor* editor; + + ScopedPointer<Label> dspOffsetSelection; + + double actualDspCutoffFreq; + +}; + + class SampleRateInterface : public Component, public ComboBox::Listener diff --git a/Source/Processors/Editors/SourceNodeEditor.cpp b/Source/Processors/Editors/SourceNodeEditor.cpp index 485482ad4..c2c52adda 100755 --- a/Source/Processors/Editors/SourceNodeEditor.cpp +++ b/Source/Processors/Editors/SourceNodeEditor.cpp @@ -77,6 +77,8 @@ SourceNodeEditor::SourceNodeEditor(GenericProcessor* parentNode, bool useDefault //values.add(1); values.add(2), values.add(3); //createRadioButtons(10, 25, 100, values); + + } diff --git a/Source/Processors/Editors/SourceNodeEditor.h b/Source/Processors/Editors/SourceNodeEditor.h index 5bf07e2bb..8425717a3 100755 --- a/Source/Processors/Editors/SourceNodeEditor.h +++ b/Source/Processors/Editors/SourceNodeEditor.h @@ -51,6 +51,7 @@ private: ImageIcon* icon; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SourceNodeEditor); + }; diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.cpp b/Source/Processors/Visualization/LfpDisplayCanvas.cpp index 722babcec..e3b567e11 100755 --- a/Source/Processors/Visualization/LfpDisplayCanvas.cpp +++ b/Source/Processors/Visualization/LfpDisplayCanvas.cpp @@ -70,18 +70,34 @@ LfpDisplayCanvas::LfpDisplayCanvas(LfpDisplayNode* processor_) : addAndMakeVisible(timescale); voltageRanges.add("-"); // placeholder for custom ranges (set by scroll wheel etc.) - voltageRanges.add("50"); + voltageRanges.add("25"); + voltageRanges.add("50"); voltageRanges.add("100"); voltageRanges.add("250"); + voltageRanges.add("400"); voltageRanges.add("500"); + voltageRanges.add("750"); voltageRanges.add("1000"); voltageRanges.add("2000"); voltageRanges.add("5000"); - - timebases.add("1.0"); + voltageRanges.add("10000"); + voltageRanges.add("50000"); + voltageRanges.add("100000"); + voltageRanges.add("500000"); + voltageRanges.add("1000000"); + voltageRanges.add("2000000"); + voltageRanges.add("5000000"); + + + timebases.add("0.25"); + timebases.add("0.5"); + timebases.add("1.0"); timebases.add("2.0"); - timebases.add("5.0"); + timebases.add("3.0"); + timebases.add("4.0"); + timebases.add("5.0"); timebases.add("10.0"); + timebases.add("20.0"); spreads.add("-"); // placeholder for custom ranges (set by scroll wheel etc.) spreads.add("10"); @@ -90,6 +106,10 @@ LfpDisplayCanvas::LfpDisplayCanvas(LfpDisplayNode* processor_) : spreads.add("40"); spreads.add("50"); spreads.add("60"); + spreads.add("70"); + spreads.add("80"); + spreads.add("90"); + spreads.add("100"); colorGroupings.add("1"); colorGroupings.add("2"); -- GitLab