From e97992eefba7fd6f567283bdd8de4ca029f96826 Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Thu, 30 May 2013 00:01:54 -0400 Subject: [PATCH] Add option of enabling ADCs in Rhythm interface --- .../Processors/DataThreads/RHD2000Thread.cpp | 27 ++++++++++++++- Source/Processors/DataThreads/RHD2000Thread.h | 2 ++ Source/Processors/Editors/RHD2000Editor.cpp | 34 +++++++++++++++++++ Source/Processors/Editors/RHD2000Editor.h | 4 +++ 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/Source/Processors/DataThreads/RHD2000Thread.cpp b/Source/Processors/DataThreads/RHD2000Thread.cpp index ebe2204fb..6eb3a7918 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.cpp +++ b/Source/Processors/DataThreads/RHD2000Thread.cpp @@ -28,6 +28,7 @@ RHD2000Thread::RHD2000Thread(SourceNode* sn) : DataThread(sn), isTransmitting(fa fastSettleEnabled(false), chipRegisters(30000.0f), dspEnabled(true), boardSampleRate(30000.0f), desiredDspCutoffFreq(0.5f), desiredUpperBandwidth(7500.0f), desiredLowerBandwidth(1.0f), savedSampleRateIndex(16), audioOutputL(-1), audioOutputR(-1), dacOutputShouldChange(false), + acquireAdcChannels(false), cableLengthPortA(0.914f), cableLengthPortB(0.914f), cableLengthPortC(0.914f), cableLengthPortD(0.914f) // default is 3 feet (0.914 m) { evalBoard = new Rhd2000EvalBoard; @@ -381,7 +382,6 @@ int RHD2000Thread::getNumChannels() } - /* if (chipRegisters->adcAux1En){ // no public function to read these? fix this in some way numChannels += 1; @@ -395,6 +395,12 @@ int RHD2000Thread::getNumChannels() */ } + + if (acquireAdcChannels) + { + numChannels += 8; // add 8 channels for the ADCs + } + if (numChannels > 0) return numChannels; else @@ -503,6 +509,15 @@ void RHD2000Thread::assignAudioOut(int dacChannel, int dataChannel) } +void RHD2000Thread::enableAdcs(bool t) +{ + + acquireAdcChannels = t; + + dataBuffer->resize(getNumChannels(), 10000); + +} + void RHD2000Thread::setSampleRate(int sampleRateIndex, bool isTemporary) { @@ -857,6 +872,16 @@ bool RHD2000Thread::updateBuffer() thisSample[channel] = auxBuffer[channel]; } + if (acquireAdcChannels) + { + for (int adcChan = 0; adcChan < 8; ++adcChan) { + + channel++; + // ADC waveform units = volts + thisSample[channel] = + 0.000050354 * float(dataBlock->boardAdcData[adcChan][samp]); + } + } } diff --git a/Source/Processors/DataThreads/RHD2000Thread.h b/Source/Processors/DataThreads/RHD2000Thread.h index c5f164e08..71f77d7ce 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.h +++ b/Source/Processors/DataThreads/RHD2000Thread.h @@ -78,6 +78,7 @@ public: int getNumEventChannels(); void assignAudioOut(int dacChannel, int dataChannel); + void enableAdcs(bool); bool isAcquisitionActive(); @@ -102,6 +103,7 @@ private: bool isTransmitting; bool dacOutputShouldChange; + bool acquireAdcChannels; bool fastSettleEnabled; diff --git a/Source/Processors/Editors/RHD2000Editor.cpp b/Source/Processors/Editors/RHD2000Editor.cpp index 6935f09cc..65a84dc7a 100644 --- a/Source/Processors/Editors/RHD2000Editor.cpp +++ b/Source/Processors/Editors/RHD2000Editor.cpp @@ -82,6 +82,12 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, 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); } @@ -114,6 +120,10 @@ void RHD2000Editor::buttonEvent(Button* button) } else if (button == electrodeButtons[1]) { channelSelector->setRadioStatus(true); + } else if (button == adcButton) + { + board->enableAdcs(button->getToggleState()); + getEditorViewport()->makeEditorVisible(this, false, true); } } @@ -132,6 +142,30 @@ void RHD2000Editor::channelChanged(int 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 -------------------------------------------------------------------- BandwidthInterface::BandwidthInterface(RHD2000Thread* board_, diff --git a/Source/Processors/Editors/RHD2000Editor.h b/Source/Processors/Editors/RHD2000Editor.h index 588315553..5ae7c7f38 100644 --- a/Source/Processors/Editors/RHD2000Editor.h +++ b/Source/Processors/Editors/RHD2000Editor.h @@ -56,6 +56,9 @@ public: void scanPorts(); + void startAcquisition(); + void stopAcquisition(); + void channelChanged(int chan); private: @@ -67,6 +70,7 @@ private: ScopedPointer<BandwidthInterface> bandwidthInterface; ScopedPointer<UtilityButton> rescanButton; + ScopedPointer<UtilityButton> adcButton; ScopedPointer<Label> audioLabel; -- GitLab