@@ -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
935939void 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 }
0 commit comments