Skip to content
Snippets Groups Projects
Commit 2c9fecc6 authored by Jakob Voigts's avatar Jakob Voigts
Browse files

added editor controls for sample rate and RHD bandpass filter

bandpass filter setting seem to work only when set before acquiring data for the 1st time
parent 0400cf32
No related branches found
No related tags found
No related merge requests found
......@@ -34,27 +34,187 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode,
{
desiredWidth = 400;
int width = desiredWidth/4 - 10;
// add headstage-specific controls (currently just an enable/disable button)
for (int i = 0; i < 4; i++)
{
HeadstageOptionsInterface* hsOptions = new HeadstageOptionsInterface(board, this, i);
headstageOptionsInterfaces.add(hsOptions);
addAndMakeVisible(hsOptions);
hsOptions->setBounds(8+i*width,30, width, 85);
hsOptions->setBounds(80,25+i*23, 60, 22);
}
// add sample rate selection
SampleRateInterface* rateOptions = new SampleRateInterface(board, this);
addAndMakeVisible(rateOptions);
rateOptions->setBounds(150,25,160, 50);
// add Bandwidth selection
BandwidthInterface* bandwidthOptions = new BandwidthInterface(board, this);
addAndMakeVisible(bandwidthOptions);
bandwidthOptions->setBounds(150,65,160, 50);
}
RHD2000Editor::~RHD2000Editor()
{
}
// Bandwidth Options --------------------------------------------------------------------
BandwidthInterface::BandwidthInterface(RHD2000Thread* board_,
RHD2000Editor* editor_) :
board(board_), editor(editor_)
{
name="Bandwidth";
UpperBandwidthSelection = new Label("UpperBandwidth","7500 Hz"); // 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(0,10,300,30);
addAndMakeVisible(UpperBandwidthSelection);
LowerBandwidthSelection = new Label("LowerBandwidth","1 Hz");
LowerBandwidthSelection->setEditable(true,false,false);
LowerBandwidthSelection->addListener(this);
LowerBandwidthSelection->setBounds(0,30,300,30);
addAndMakeVisible(LowerBandwidthSelection);
}
BandwidthInterface::~BandwidthInterface()
{
}
void BandwidthInterface::labelTextChanged(Label* te)
{
if (!(editor->acquisitionIsActive))
{
if (te == UpperBandwidthSelection)
{
double actualUpperBandwidth = board->setUpperBandwidth(te->getText().getDoubleValue());
// cb->setText(cb->getItemText(te->getSelectedId()),true);
std::cout << "Setting Upper Bandwidth to " << te->getText().getDoubleValue() << std::endl;
std::cout << "Actual Upper Bandwidth: " << actualUpperBandwidth << std::endl;
te->setText(String(actualUpperBandwidth)+" Hz",false);
repaint();
} else {
double actualLowerBandwidth = board->setLowerBandwidth(te->getText().getDoubleValue());
// cb->setText(cb->getItemText(te->getSelectedId()),true);
std::cout << "Setting Lower Bandwidth to " << te->getText().getDoubleValue() << std::endl;
std::cout << "Actual Lower Bandwidth: " << actualLowerBandwidth << std::endl;
te->setText(String(actualLowerBandwidth)+" Hz",false);
repaint();
}
}
}
void BandwidthInterface::paint(Graphics& g)
{
//g.setColour(Colours::lightgrey);
//g.fillRoundedRectangle(5,0,getWidth()-10,getHeight(),4.0f);
// g.setColour(Colours::grey);
g.setFont(Font("Small Text",15,Font::plain));
g.drawText(name, 0, 0, 200, 15, Justification::left, false);
}
// Sample rate Options --------------------------------------------------------------------
SampleRateInterface::SampleRateInterface(RHD2000Thread* board_,
RHD2000Editor* editor_) :
board(board_), editor(editor_)
{
name="SampleRate";
sampleRateOptions.add("1.00 kS/s");
sampleRateOptions.add("1.25 kS/s");
sampleRateOptions.add("1.50 kS/s");
sampleRateOptions.add("2.00 kS/s");
sampleRateOptions.add("2.50 kS/s");
sampleRateOptions.add("3.00 kS/s");
sampleRateOptions.add("3.33 kS/s");
sampleRateOptions.add("4.00 kS/s");
sampleRateOptions.add("5.00 kS/s");
sampleRateOptions.add("6.25 kS/s");
sampleRateOptions.add("8.00 kS/s");
sampleRateOptions.add("10.0 kS/s");
sampleRateOptions.add("12.5 kS/s");
sampleRateOptions.add("15.0 kS/s");
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,false);
rateSelection->addListener(this);
rateSelection->setBounds(0,15,300,20);
addAndMakeVisible(rateSelection);
}
SampleRateInterface::~SampleRateInterface()
{
}
void SampleRateInterface::comboBoxChanged(ComboBox* cb)
{
if (!(editor->acquisitionIsActive))
{
if (cb == rateSelection)
{
board->setSampleRate(cb->getSelectedId());
//cb->setText(cb->getItemText(cb->getSelectedId()),true);
std::cout << "Setting sample rate to index " << cb->getSelectedId() << std::endl;
repaint();
}
}
}
void SampleRateInterface::paint(Graphics& g)
{
//g.setColour(Colours::lightgrey);
//g.fillRoundedRectangle(5,0,getWidth()-10,getHeight(),4.0f);
// g.setColour(Colours::grey);
g.setFont(Font("Small Text",15,Font::plain));
g.drawText(name, 0, 0, 200, 15, Justification::left, false);
}
// --------------------------------------------------------------------
// Headstage Options --------------------------------------------------------------------
HeadstageOptionsInterface::HeadstageOptionsInterface(RHD2000Thread* board_,
RHD2000Editor* editor_,
......@@ -82,10 +242,10 @@ HeadstageOptionsInterface::HeadstageOptionsInterface(RHD2000Thread* board_,
isEnabled = board->isHeadstageEnabled(hsNumber);
enabledButton = new UtilityButton("enabled", Font("Small Text", 13, Font::plain));
enabledButton = new UtilityButton("on", Font("Small Text", 13, Font::plain));
enabledButton->addListener(this);
enabledButton->setRadius(3.0f);
enabledButton->setBounds(10,30,70,25);
enabledButton->setBounds(25,2,20,19);
addAndMakeVisible(enabledButton);
......
......@@ -27,8 +27,9 @@
#include "../../../JuceLibraryCode/JuceHeader.h"
#include "GenericEditor.h"
class HeadstageOptionsInterface;
class SampleRateInterface;
class BandwidthInterface;
class RHD2000Thread;
class UtilityButton;
......@@ -52,6 +53,7 @@ public:
private:
OwnedArray<HeadstageOptionsInterface> headstageOptionsInterfaces;
ScopedPointer<SampleRateInterface> RateInterface;
RHD2000Thread* board;
......@@ -86,5 +88,53 @@ private:
};
class BandwidthInterface : public Component,
public Label::Listener
{
public:
BandwidthInterface(RHD2000Thread*, RHD2000Editor*);
~BandwidthInterface();
void paint(Graphics& g);
void labelTextChanged(Label* te);
private:
String name;
RHD2000Thread* board;
RHD2000Editor* editor;
ScopedPointer<Label> UpperBandwidthSelection;
ScopedPointer<Label> LowerBandwidthSelection;
};
class SampleRateInterface : public Component,
public ComboBox::Listener
{
public:
SampleRateInterface(RHD2000Thread*, RHD2000Editor*);
~SampleRateInterface();
void paint(Graphics& g);
void comboBoxChanged(ComboBox* cb);
private:
int sampleRate;
String name;
RHD2000Thread* board;
RHD2000Editor* editor;
ScopedPointer<ComboBox> rateSelection;
StringArray sampleRateOptions;
};
#endif // __RHD2000EDITOR_H_2AD3C591__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment