Skip to content

Commit 8049176

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 566af66 + a2359eb commit 8049176

11 files changed

Lines changed: 143 additions & 22 deletions

File tree

Builds/Linux/build/rhd2000.bit

0 Bytes
Binary file not shown.
-874 KB
Binary file not shown.
-1.42 MB
Binary file not shown.

Resources/Bitfiles/rhd2000.bit

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Source/Processors/DataThreads/RhythmNode/RHD2000Editor.cpp

Lines changed: 74 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -631,12 +631,15 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode,
631631
// add HW audio parameter selection
632632
audioInterface = new AudioInterface(board, this);
633633
addAndMakeVisible(audioInterface);
634-
audioInterface->setBounds(175, 65, 65, 50);
634+
audioInterface->setBounds(179, 58, 70, 50);
635635

636+
clockInterface = new ClockDivideInterface(board, this);
637+
addAndMakeVisible(clockInterface);
638+
clockInterface->setBounds(179, 82, 70, 50);
636639

637640
adcButton = new UtilityButton("ADC 1-8", Font("Small Text", 13, Font::plain));
638641
adcButton->setRadius(3.0f);
639-
adcButton->setBounds(175,100,65,18);
642+
adcButton->setBounds(179,108,70,18);
640643
adcButton->addListener(this);
641644
adcButton->setClickingTogglesState(true);
642645
adcButton->setTooltip("Enable/disable ADC channels");
@@ -742,7 +745,7 @@ void RHD2000Editor::handleAsyncUpdate()
742745

743746
String path(CoreServices::RecordNode::getRecordingPath().getFullPathName()
744747
+ File::separatorString + "impedance_measurement.xml");
745-
std::cout << "Saving impedance measurements in " << path << std::endl;
748+
std::cout << "Saving impedance measurements in " << path << "\n";
746749
File file(path);
747750

748751
if (!file.getParentDirectory().exists())
@@ -840,17 +843,17 @@ void RHD2000Editor::buttonEvent(Button* button)
840843
{
841844
board->enableAdcs(button->getToggleState());
842845
// board->updateChannelNames();
843-
std::cout << "ADC Button toggled" << std::endl;
846+
std::cout << "ADC Button toggled" << "\n";
844847
CoreServices::updateSignalChain(this);
845-
std::cout << "Editor visible." << std::endl;
848+
std::cout << "Editor visible." << "\n";
846849
}
847850
else if (button == dacTTLButton)
848851
{
849852
board->setTTLoutputMode(dacTTLButton->getToggleState());
850853
}
851854
else if (button == dspoffsetButton && !acquisitionIsActive)
852855
{
853-
std::cout << "DSP offset " << button->getToggleState() << std::endl;
856+
std::cout << "DSP offset " << button->getToggleState() << "\n";
854857
board->setDSPOffset(button->getToggleState());
855858
}
856859
else if (button == ledButton)
@@ -930,6 +933,7 @@ void RHD2000Editor::saveCustomParameters(XmlElement* xml)
930933
xml->setAttribute("save_impedance_measurements",saveImpedances);
931934
xml->setAttribute("auto_measure_impedances",measureWhenRecording);
932935
xml->setAttribute("LEDs", ledButton->getToggleState());
936+
xml->setAttribute("ClockDivideRatio", clockInterface->getClockDivideRatio());
933937
}
934938

935939
void RHD2000Editor::loadCustomParameters(XmlElement* xml)
@@ -952,6 +956,7 @@ void RHD2000Editor::loadCustomParameters(XmlElement* xml)
952956
saveImpedances = xml->getBoolAttribute("save_impedance_measurements");
953957
measureWhenRecording = xml->getBoolAttribute("auto_measure_impedances");
954958
ledButton->setToggleState(xml->getBoolAttribute("LEDs", true),sendNotification);
959+
clockInterface->setClockDivideRatio(xml->getIntAttribute("ClockDivideRatio"));
955960
}
956961

957962

@@ -1027,8 +1032,8 @@ void BandwidthInterface::labelTextChanged(Label* label)
10271032

10281033
actualUpperBandwidth = board->setUpperBandwidth(requestedValue);
10291034

1030-
std::cout << "Setting Upper Bandwidth to " << requestedValue << std::endl;
1031-
std::cout << "Actual Upper Bandwidth: " << actualUpperBandwidth << std::endl;
1035+
std::cout << "Setting Upper Bandwidth to " << requestedValue << "\n";
1036+
std::cout << "Actual Upper Bandwidth: " << actualUpperBandwidth << "\n";
10321037
label->setText(String(round(actualUpperBandwidth*10.f)/10.f), dontSendNotification);
10331038

10341039
}
@@ -1049,8 +1054,8 @@ void BandwidthInterface::labelTextChanged(Label* label)
10491054

10501055
actualLowerBandwidth = board->setLowerBandwidth(requestedValue);
10511056

1052-
std::cout << "Setting Lower Bandwidth to " << requestedValue << std::endl;
1053-
std::cout << "Actual Lower Bandwidth: " << actualLowerBandwidth << std::endl;
1057+
std::cout << "Setting Lower Bandwidth to " << requestedValue << "\n";
1058+
std::cout << "Actual Lower Bandwidth: " << actualLowerBandwidth << "\n";
10541059

10551060
label->setText(String(round(actualLowerBandwidth*10.f)/10.f), dontSendNotification);
10561061
}
@@ -1157,7 +1162,7 @@ void SampleRateInterface::comboBoxChanged(ComboBox* cb)
11571162
{
11581163
board->setSampleRate(cb->getSelectedId()-1);
11591164

1160-
std::cout << "Setting sample rate to index " << cb->getSelectedId()-1 << std::endl;
1165+
std::cout << "Setting sample rate to index " << cb->getSelectedId()-1 << "\n";
11611166

11621167
CoreServices::updateSignalChain(editor);
11631168
}
@@ -1286,15 +1291,15 @@ void HeadstageOptionsInterface::buttonClicked(Button* button)
12861291
if (!(editor->acquisitionIsActive) && board->foundInputSource())
12871292
{
12881293

1289-
//std::cout << "Acquisition is not active" << std::endl;
1294+
//std::cout << "Acquisition is not active" << "\n";
12901295
if ((button == hsButton1) && (board->getChannelsInHeadstage(hsNumber1) == 32))
12911296
{
12921297
if (channelsOnHs1 == 32)
12931298
channelsOnHs1 = 16;
12941299
else
12951300
channelsOnHs1 = 32;
12961301

1297-
//std::cout << "HS1 has " << channelsOnHs1 << " channels." << std::endl;
1302+
//std::cout << "HS1 has " << channelsOnHs1 << " channels." << "\n";
12981303

12991304
hsButton1->setLabel(String(channelsOnHs1));
13001305
board->setNumChannels(hsNumber1, channelsOnHs1);
@@ -1390,7 +1395,7 @@ void AudioInterface::labelTextChanged(Label* label)
13901395

13911396
actualNoiseSlicerLevel = board->setNoiseSlicerLevel(requestedValue);
13921397

1393-
std::cout << "Setting Noise Slicer Level to " << requestedValue << std::endl;
1398+
std::cout << "Setting Noise Slicer Level to " << requestedValue << "\n";
13941399
label->setText(String((roundFloatToInt)(actualNoiseSlicerLevel)), dontSendNotification);
13951400

13961401
}
@@ -1424,16 +1429,66 @@ void AudioInterface::paint(Graphics& g)
14241429
{
14251430

14261431
g.setColour(Colours::darkgrey);
1427-
14281432
g.setFont(Font("Small Text",9,Font::plain));
1429-
14301433
g.drawText(name, 0, 0, 200, 15, Justification::left, false);
1431-
14321434
g.drawText("Level: ", 0, 10, 200, 20, Justification::left, false);
1435+
}
14331436

1437+
1438+
// Clock Divider options
1439+
ClockDivideInterface::ClockDivideInterface(RHD2000Thread* board_,
1440+
RHD2000Editor* editor_) :
1441+
board(board_)
1442+
, editor(editor_)
1443+
1444+
{
1445+
divideRatioSelection = new Label("Clock Divide", lastDivideRatioString);
1446+
divideRatioSelection->setEditable(true,false,false);
1447+
divideRatioSelection->addListener(this);
1448+
divideRatioSelection->setBounds(30,10,30,20);
1449+
divideRatioSelection->setColour(Label::textColourId, Colours::darkgrey);
1450+
addAndMakeVisible(divideRatioSelection);
14341451
}
14351452

1453+
void ClockDivideInterface::labelTextChanged(Label* label)
1454+
{
1455+
if (board->foundInputSource())
1456+
{
1457+
if (label == divideRatioSelection)
1458+
{
1459+
Value val = label->getTextValue();
1460+
int requestedValue = int(val.getValue());
1461+
1462+
if (requestedValue < 1 || requestedValue > 65534)
1463+
{
1464+
CoreServices::sendStatusMessage("Value must be between 1 and 65534.");
1465+
label->setText(lastDivideRatioString, dontSendNotification);
1466+
return;
1467+
}
14361468

1469+
actualDivideRatio = board->setClockDivider(requestedValue);
1470+
lastDivideRatioString = String(actualDivideRatio);
1471+
1472+
std::cout << "Setting clock divide ratio to " << actualDivideRatio << "\n";
1473+
label->setText(lastDivideRatioString, dontSendNotification);
1474+
}
1475+
}
1476+
}
1477+
1478+
void ClockDivideInterface::setClockDivideRatio(int value)
1479+
{
1480+
actualDivideRatio = board->setClockDivider(value);
1481+
divideRatioSelection->setText(String(actualDivideRatio), dontSendNotification);
1482+
}
1483+
1484+
void ClockDivideInterface::paint(Graphics& g)
1485+
{
1486+
1487+
g.setColour(Colours::darkgrey);
1488+
g.setFont(Font("Small Text",9,Font::plain));
1489+
g.drawText(name, 0, 0, 200, 15, Justification::left, false);
1490+
g.drawText("Ratio: ", 0, 10, 200, 20, Justification::left, false);
1491+
}
14371492

14381493
// DSP Options --------------------------------------------------------------------
14391494

@@ -1472,8 +1527,8 @@ void DSPInterface::labelTextChanged(Label* label)
14721527

14731528
actualDspCutoffFreq = board->setDspCutoffFreq(requestedValue);
14741529

1475-
std::cout << "Setting DSP Cutoff Freq to " << requestedValue << std::endl;
1476-
std::cout << "Actual DSP Cutoff Freq: " << actualDspCutoffFreq << std::endl;
1530+
std::cout << "Setting DSP Cutoff Freq to " << requestedValue << "\n";
1531+
std::cout << "Actual DSP Cutoff Freq: " << actualDspCutoffFreq << "\n";
14771532
label->setText(String(round(actualDspCutoffFreq*10.f)/10.f), dontSendNotification);
14781533

14791534
}

Source/Processors/DataThreads/RhythmNode/RHD2000Editor.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class SampleRateInterface;
3535
class BandwidthInterface;
3636
class DSPInterface;
3737
class AudioInterface;
38+
class ClockDivideInterface;
3839
class RHD2000Thread;
3940

4041
class UtilityButton;
@@ -199,6 +200,7 @@ class RHD2000Editor : public VisualizerEditor, public ComboBox::Listener, public
199200
ScopedPointer<DSPInterface> dspInterface;
200201

201202
ScopedPointer<AudioInterface> audioInterface;
203+
ScopedPointer<ClockDivideInterface> clockInterface;
202204

203205
ScopedPointer<UtilityButton> rescanButton,dacTTLButton;
204206
ScopedPointer<UtilityButton> adcButton;
@@ -371,5 +373,28 @@ class AudioInterface : public Component,
371373

372374
};
373375

376+
class ClockDivideInterface : public Component,
377+
public Label::Listener
378+
{
379+
public:
380+
ClockDivideInterface(RHD2000Thread*, RHD2000Editor*);
381+
382+
void paint(Graphics& g);
383+
void labelTextChanged(Label* te);
384+
385+
void setClockDivideRatio(int value);
386+
int getClockDivideRatio() const { return actualDivideRatio; };
374387

388+
private:
389+
390+
String name {"Clock Divider"};
391+
String lastDivideRatioString {"1"};
392+
393+
RHD2000Thread * board;
394+
RHD2000Editor * editor;
395+
396+
ScopedPointer<Label> divideRatioSelection;
397+
int actualDivideRatio {1};
398+
399+
};
375400
#endif // __RHD2000EDITOR_H_2AD3C591__

Source/Processors/DataThreads/RhythmNode/RHD2000Thread.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,6 +1720,7 @@ bool RHD2000Thread::updateBuffer()
17201720
evalBoard->setDacHighpassFilter(desiredDAChpf);
17211721
evalBoard->enableDacHighpassFilter(desiredDAChpfState);
17221722
evalBoard->enableBoardLeds(ledsEnabled);
1723+
evalBoard->setClockDivider(clockDivideFactor);
17231724

17241725
dacOutputShouldChange = false;
17251726
}
@@ -1831,6 +1832,31 @@ void RHD2000Thread::enableBoardLeds(bool enable)
18311832
evalBoard->enableBoardLeds(enable);
18321833
}
18331834

1835+
int RHD2000Thread::setClockDivider(int divide_ratio)
1836+
{
1837+
1838+
// Divide ratio should be 1 or an even number
1839+
if (divide_ratio != 1 && divide_ratio % 2)
1840+
divide_ratio--;
1841+
1842+
// Format the divide ratio from its true value to the
1843+
// format required by the firmware
1844+
// Ratio N
1845+
// 1 0
1846+
// >=2 Ratio/2
1847+
if (divide_ratio == 1)
1848+
clockDivideFactor = 0;
1849+
else
1850+
clockDivideFactor = static_cast<uint16>(divide_ratio/2);
1851+
1852+
if (isAcquisitionActive())
1853+
dacOutputShouldChange = true;
1854+
else
1855+
evalBoard->setClockDivider(clockDivideFactor);
1856+
1857+
return divide_ratio;
1858+
}
1859+
18341860
void RHD2000Thread::runImpedanceTest(ImpedanceData* data)
18351861
{
18361862
impedanceThread->stopThreadSafely();
@@ -2459,4 +2485,4 @@ void RHDImpedanceMeasure::restoreFPGA()
24592485
{
24602486
board->evalBoard->enableExternalFastSettle(true);
24612487
}
2462-
}
2488+
}

Source/Processors/DataThreads/RhythmNode/RHD2000Thread.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#ifndef __RHD2000THREAD_H_2C4CBD67__
2626
#define __RHD2000THREAD_H_2C4CBD67__
2727

28-
2928
#include "../../../../JuceLibraryCode/JuceHeader.h"
3029

3130
#include <stdio.h>
@@ -130,6 +129,7 @@ class RHD2000Thread : public DataThread, public Timer
130129

131130
void runImpedanceTest(ImpedanceData* data);
132131
void enableBoardLeds(bool enable);
132+
int setClockDivider(int divide_ratio);
133133
GenericEditor* createEditor(SourceNode* sn);
134134

135135
static DataThread* createDataThread(SourceNode* sn);
@@ -211,6 +211,9 @@ class RHD2000Thread : public DataThread, public Timer
211211
ScopedPointer<RHDImpedanceMeasure> impedanceThread;
212212
bool ledsEnabled;
213213

214+
// Sync ouput divide factor
215+
uint16 clockDivideFactor;
216+
214217
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RHD2000Thread);
215218
};
216219

Source/Processors/DataThreads/RhythmNode/rhythm-api/rhd2000evalboard.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,17 @@ void Rhd2000EvalBoard::enableBoardLeds(bool enable)
16671667
dev->ActivateTriggerIn(TrigInOpenEphys, 0);
16681668
}
16691669

1670+
// Ratio divide_factor
1671+
// 1 0
1672+
// >=2 Ratio/2
1673+
void Rhd2000EvalBoard::setClockDivider(int divide_factor)
1674+
{
1675+
1676+
dev->SetWireInValue(WireInMultiUse, divide_factor);
1677+
dev->UpdateWireIns();
1678+
dev->ActivateTriggerIn(TrigInOpenEphys, 1);
1679+
}
1680+
16701681
bool Rhd2000EvalBoard::isUSB3()
16711682
{
16721683
return usb3;
@@ -1676,4 +1687,4 @@ void Rhd2000EvalBoard::printFIFOmetrics()
16761687
{
16771688
dev->UpdateWireOuts();
16781689
std::cout << "In FIFO: " << dev->GetWireOutValue(0x28) << " DDR: " << dev->GetWireOutValue(0x2a) << " Out FIFO: " << dev->GetWireOutValue(0x29) << std::endl;
1679-
}
1690+
}

0 commit comments

Comments
 (0)