Skip to content

Commit cbfaf6b

Browse files
author
jonnew
committed
Fixed the processing/UI thread sync issue brought up by Aaron in the PR
- Also, changed Clock divider level: label to Clock divide ratio: - Also, clock divide settings are now serialized to the configuration XML during a settings save.
1 parent 7f1731c commit cbfaf6b

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

152 KB
Binary file not shown.

Source/Processors/DataThreads/RHD2000Editor.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,7 @@ void RHD2000Editor::saveCustomParameters(XmlElement* xml)
933933
xml->setAttribute("save_impedance_measurements",saveImpedances);
934934
xml->setAttribute("auto_measure_impedances",measureWhenRecording);
935935
xml->setAttribute("LEDs", ledButton->getToggleState());
936+
xml->setAttribute("ClockDivideRatio", clockInterface->getClockDivideRatio());
936937
}
937938

938939
void RHD2000Editor::loadCustomParameters(XmlElement* xml)
@@ -955,6 +956,7 @@ void RHD2000Editor::loadCustomParameters(XmlElement* xml)
955956
saveImpedances = xml->getBoolAttribute("save_impedance_measurements");
956957
measureWhenRecording = xml->getBoolAttribute("auto_measure_impedances");
957958
ledButton->setToggleState(xml->getBoolAttribute("LEDs", true),sendNotification);
959+
clockInterface->setClockDivideRatio(xml->getIntAttribute("ClockDivideRatio"));
958960
}
959961

960962

@@ -1440,7 +1442,7 @@ ClockDivideInterface::ClockDivideInterface(RHD2000Thread* board_,
14401442
, editor(editor_)
14411443

14421444
{
1443-
divideRatioSelection = new Label("Clock Divider", lastDivideRatioString);
1445+
divideRatioSelection = new Label("Clock Divide", lastDivideRatioString);
14441446
divideRatioSelection->setEditable(true,false,false);
14451447
divideRatioSelection->addListener(this);
14461448
divideRatioSelection->setBounds(30,10,30,20);
@@ -1485,7 +1487,7 @@ void ClockDivideInterface::paint(Graphics& g)
14851487
g.setColour(Colours::darkgrey);
14861488
g.setFont(Font("Small Text",9,Font::plain));
14871489
g.drawText(name, 0, 0, 200, 15, Justification::left, false);
1488-
g.drawText("Level: ", 0, 10, 200, 20, Justification::left, false);
1490+
g.drawText("Ratio: ", 0, 10, 200, 20, Justification::left, false);
14891491
}
14901492

14911493
// DSP Options --------------------------------------------------------------------

Source/Processors/DataThreads/RHD2000Thread.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,6 +1710,7 @@ bool RHD2000Thread::updateBuffer()
17101710
evalBoard->setDacHighpassFilter(desiredDAChpf);
17111711
evalBoard->enableDacHighpassFilter(desiredDAChpfState);
17121712
evalBoard->enableBoardLeds(ledsEnabled);
1713+
evalBoard->setClockDivider(clockDivideFactor);
17131714

17141715
dacOutputShouldChange = false;
17151716
}
@@ -1823,10 +1824,6 @@ void RHD2000Thread::enableBoardLeds(bool enable)
18231824

18241825
int RHD2000Thread::setClockDivider(int divide_ratio)
18251826
{
1826-
// TODO: only allow if not running?
1827-
//if (isAcquisitionActive())
1828-
//
1829-
uint16_t N;
18301827

18311828
// Divide ratio should be 1 or an even number
18321829
if (divide_ratio != 1 && divide_ratio % 2)
@@ -1838,11 +1835,14 @@ int RHD2000Thread::setClockDivider(int divide_ratio)
18381835
// 1 0
18391836
// >=2 Ratio/2
18401837
if (divide_ratio == 1)
1841-
N = 0;
1838+
clockDivideFactor = 0;
18421839
else
1843-
N = static_cast<uint16_t>(divide_ratio/2);
1840+
clockDivideFactor = static_cast<uint16_t>(divide_ratio/2);
18441841

1845-
evalBoard->setClockDivider(N);
1842+
if (isAcquisitionActive())
1843+
dacOutputShouldChange = true;
1844+
else
1845+
evalBoard->setClockDivider(clockDivideFactor);
18461846

18471847
return divide_ratio;
18481848
}

Source/Processors/DataThreads/RHD2000Thread.h

Lines changed: 3 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>
@@ -209,6 +208,9 @@ class RHD2000Thread : public DataThread, public Timer
209208
ScopedPointer<RHDImpedanceMeasure> impedanceThread;
210209
bool ledsEnabled;
211210

211+
// Sync ouput divide factor
212+
int16_t clockDivideFactor;
213+
212214
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RHD2000Thread);
213215
};
214216

0 commit comments

Comments
 (0)