Skip to content

Commit

Permalink
Fixed the processing/UI thread sync issue brought up by Aaron in the PR
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
jonnew committed Jan 26, 2016
1 parent 7f1731c commit cbfaf6b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Binary file modified Builds/Linux/build/libokFrontPanel.so
Binary file not shown.
6 changes: 4 additions & 2 deletions Source/Processors/DataThreads/RHD2000Editor.cpp
Expand Up @@ -933,6 +933,7 @@ void RHD2000Editor::saveCustomParameters(XmlElement* xml)
xml->setAttribute("save_impedance_measurements",saveImpedances);
xml->setAttribute("auto_measure_impedances",measureWhenRecording);
xml->setAttribute("LEDs", ledButton->getToggleState());
xml->setAttribute("ClockDivideRatio", clockInterface->getClockDivideRatio());
}

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


Expand Down Expand Up @@ -1440,7 +1442,7 @@ ClockDivideInterface::ClockDivideInterface(RHD2000Thread* board_,
, editor(editor_)

{
divideRatioSelection = new Label("Clock Divider", lastDivideRatioString);
divideRatioSelection = new Label("Clock Divide", lastDivideRatioString);
divideRatioSelection->setEditable(true,false,false);
divideRatioSelection->addListener(this);
divideRatioSelection->setBounds(30,10,30,20);
Expand Down Expand Up @@ -1485,7 +1487,7 @@ void ClockDivideInterface::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);
g.drawText("Ratio: ", 0, 10, 200, 20, Justification::left, false);
}

// DSP Options --------------------------------------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions Source/Processors/DataThreads/RHD2000Thread.cpp
Expand Up @@ -1710,6 +1710,7 @@ bool RHD2000Thread::updateBuffer()
evalBoard->setDacHighpassFilter(desiredDAChpf);
evalBoard->enableDacHighpassFilter(desiredDAChpfState);
evalBoard->enableBoardLeds(ledsEnabled);
evalBoard->setClockDivider(clockDivideFactor);

dacOutputShouldChange = false;
}
Expand Down Expand Up @@ -1823,10 +1824,6 @@ void RHD2000Thread::enableBoardLeds(bool enable)

int RHD2000Thread::setClockDivider(int divide_ratio)
{
// TODO: only allow if not running?
//if (isAcquisitionActive())
//
uint16_t N;

// Divide ratio should be 1 or an even number
if (divide_ratio != 1 && divide_ratio % 2)
Expand All @@ -1838,11 +1835,14 @@ int RHD2000Thread::setClockDivider(int divide_ratio)
// 1 0
// >=2 Ratio/2
if (divide_ratio == 1)
N = 0;
clockDivideFactor = 0;
else
N = static_cast<uint16_t>(divide_ratio/2);
clockDivideFactor = static_cast<uint16_t>(divide_ratio/2);

evalBoard->setClockDivider(N);
if (isAcquisitionActive())
dacOutputShouldChange = true;
else
evalBoard->setClockDivider(clockDivideFactor);

return divide_ratio;
}
Expand Down
4 changes: 3 additions & 1 deletion Source/Processors/DataThreads/RHD2000Thread.h
Expand Up @@ -25,7 +25,6 @@
#ifndef __RHD2000THREAD_H_2C4CBD67__
#define __RHD2000THREAD_H_2C4CBD67__


#include "../../../JuceLibraryCode/JuceHeader.h"

#include <stdio.h>
Expand Down Expand Up @@ -209,6 +208,9 @@ class RHD2000Thread : public DataThread, public Timer
ScopedPointer<RHDImpedanceMeasure> impedanceThread;
bool ledsEnabled;

// Sync ouput divide factor
int16_t clockDivideFactor;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RHD2000Thread);
};

Expand Down

0 comments on commit cbfaf6b

Please sign in to comment.