@@ -349,40 +349,30 @@ type(type_), gains(gains_), channelList(cl), channel(ch), name(N), gainIndex(gai
349349 editName->setColour (Label::backgroundColourId,juce::Colours::lightgrey);
350350 editName->addListener (this );
351351 addAndMakeVisible (editName);
352- /* if (gainIndex > 0)
353- {
354352
355- gainComboBox = new ComboBox("Gains");
356- for (int k=0; k<gains.size(); k++)
357- {
358- if (gains[k] < 1)
359- {
360- gainComboBox->addItem("x"+String(gains[k],2),k+1);
361- }
362- else
363- {
364- gainComboBox->addItem("x"+String((int)gains[k]),k+1);
365- }
366- }
367- gainComboBox->setSelectedId(gainIndex, sendNotificationSync);
368- gainComboBox->addListener(this);
369- addAndMakeVisible(gainComboBox);
370- }
371- else
372- {*/
373- gainComboBox = nullptr ;
374- // }
375-
376- if (type == DataChannel::HEADSTAGE_CHANNEL)
353+ if (type == DataChannel::HEADSTAGE_CHANNEL)
377354 {
378355 impedance = new Label (" Impedance" ," ? Ohm" );
379356 impedance->setFont (Font (" Default" , 13 , Font::plain));
380357 impedance->setEditable (false );
381358 addAndMakeVisible (impedance);
382359 }
360+ else if (type == DataChannel::ADC_CHANNEL)
361+ {
362+ impedance = nullptr ;
363+ rangeComboBox = new ComboBox (" ADC Ranges" );
364+ rangeComboBox->addItem (" -5V - +5V" ,1 );
365+ rangeComboBox->addItem (" 0V - +5V" ,2 );
366+ SourceNode* proc = channelList->proc ;
367+ RHD2000Thread* thread = static_cast <RHD2000Thread*>(proc->getThread ());
368+ rangeComboBox->setSelectedId (thread->getAdcRange (proc->getDataChannel (channel)->getSourceTypeIndex ()) + 1 , dontSendNotification);
369+ rangeComboBox->addListener (this );
370+ addAndMakeVisible (rangeComboBox);
371+ }
383372 else
384373 {
385374 impedance = nullptr ;
375+ rangeComboBox = nullptr ;
386376 }
387377}
388378FPGAchannelComponent::~FPGAchannelComponent ()
@@ -409,12 +399,11 @@ void FPGAchannelComponent::setImpedanceValues(float mag, float phase)
409399
410400void FPGAchannelComponent::comboBoxChanged (ComboBox* comboBox)
411401{
412- if (comboBox == gainComboBox )
402+ if (comboBox == rangeComboBox )
413403 {
414- int newGainIndex = gainComboBox->getSelectedId ();
415- float mult = gains[newGainIndex-1 ];
416- float bitvolts = channelList->proc ->getBitVolts (channelList->proc ->getDataChannel (channel));
417- channelList->setNewGain (channel, mult*bitvolts);
404+ SourceNode* proc = channelList->proc ;
405+ RHD2000Thread* thread = static_cast <RHD2000Thread*>(proc->getThread ());
406+ thread->setAdcRange (proc->getDataChannel (channel)->getSourceTypeIndex (), comboBox->getSelectedId () - 1 );
418407 }
419408}
420409void FPGAchannelComponent::labelTextChanged (Label* lbl)
@@ -450,9 +439,9 @@ int FPGAchannelComponent::getUserDefinedData()
450439void FPGAchannelComponent::resized ()
451440{
452441 editName->setBounds (0 ,0 ,90 ,20 );
453- if (gainComboBox != nullptr )
442+ if (rangeComboBox != nullptr )
454443 {
455- gainComboBox ->setBounds (100 ,0 ,70 ,20 );
444+ rangeComboBox ->setBounds (100 ,0 ,80 ,20 );
456445 }
457446 if (impedance != nullptr )
458447 {
@@ -934,6 +923,12 @@ void RHD2000Editor::saveCustomParameters(XmlElement* xml)
934923 xml->setAttribute (" auto_measure_impedances" ,measureWhenRecording);
935924 xml->setAttribute (" LEDs" , ledButton->getToggleState ());
936925 xml->setAttribute (" ClockDivideRatio" , clockInterface->getClockDivideRatio ());
926+ for (int i = 0 ; i < 8 ; i++)
927+ {
928+ XmlElement* adc = xml->createNewChildElement (" ADCRANGE" );
929+ adc->setAttribute (" Channel" , i);
930+ adc->setAttribute (" Range" , board->getAdcRange (i));
931+ }
937932}
938933
939934void RHD2000Editor::loadCustomParameters (XmlElement* xml)
@@ -957,6 +952,13 @@ void RHD2000Editor::loadCustomParameters(XmlElement* xml)
957952 measureWhenRecording = xml->getBoolAttribute (" auto_measure_impedances" );
958953 ledButton->setToggleState (xml->getBoolAttribute (" LEDs" , true ),sendNotification);
959954 clockInterface->setClockDivideRatio (xml->getIntAttribute (" ClockDivideRatio" ));
955+ forEachXmlChildElementWithTagName (*xml, adc, " ADCRANGE" )
956+ {
957+ int channel = adc->getIntAttribute (" Channel" , -1 );
958+ int range = adc->getIntAttribute (" Range" , -1 );
959+ if (channel >= 0 && range >= 0 )
960+ board->setAdcRange (channel, range);
961+ }
960962}
961963
962964
0 commit comments