@@ -35,15 +35,26 @@ AuxiliaryIOInterface::AuxiliaryIOInterface(std::shared_ptr<AuxiliaryIO> d, OnixS
3535 {
3636 auto auxiliaryIO = std::static_pointer_cast<AuxiliaryIO>(device);
3737
38- static int offset = 55 ;
39- FontOptions font = FontOptions (" Fira Code" , " Bold" , 22 .0f );
40-
4138 analogDigitalLabel = std::make_unique<Label>(" analogDigitalLabel" , " Analog and Digital IO" );
4239 analogDigitalLabel->setBounds (20 , 20 , 350 , 35 );
43- analogDigitalLabel->setFont (font );
40+ analogDigitalLabel->setFont (FontOptions ( " Fira Code " , " Bold " , 22 . 0f ) );
4441 addAndMakeVisible (analogDigitalLabel.get ());
4542
43+ deviceEnableButton = std::make_unique<UtilityButton>(enabledButtonText);
44+ deviceEnableButton->setFont (FontOptions (" Fira Code" , " Regular" , 12 .0f ));
45+ deviceEnableButton->setRadius (3 .0f );
46+ deviceEnableButton->setBounds (20 , 60 , 100 , 22 );
47+ deviceEnableButton->setClickingTogglesState (true );
48+ deviceEnableButton->setTooltip (" If disabled, AnalogIO and DigitalIO devices will not stream or receive data during acquisition" );
49+ deviceEnableButton->setToggleState (true , dontSendNotification);
50+ deviceEnableButton->addListener (this );
51+ addAndMakeVisible (deviceEnableButton.get ());
52+ deviceEnableButton->setToggleState (device->isEnabled (), sendNotification);
53+
54+ const int offset = deviceEnableButton->getBottom () + 5 ;
55+
4656 analogInterface = std::make_unique<AnalogIOInterface>(auxiliaryIO->getAnalogIO (), e, c);
57+ analogInterface->hideEnableButton ();
4758 analogViewport = std::make_unique<CustomViewport>(analogInterface.get (), SettingsInterface::Width / 2 , SettingsInterface::Height);
4859 analogViewport->setBounds (0 , offset, SettingsInterface::Width / 2 , SettingsInterface::Height);
4960 addAndMakeVisible (analogViewport.get ());
@@ -55,6 +66,41 @@ AuxiliaryIOInterface::AuxiliaryIOInterface(std::shared_ptr<AuxiliaryIO> d, OnixS
5566 }
5667}
5768
69+ void AuxiliaryIOInterface::buttonClicked (Button* b)
70+ {
71+ if (b == deviceEnableButton.get ())
72+ {
73+ device->setEnabled (deviceEnableButton->getToggleState ());
74+
75+ if (canvas->foundInputSource ())
76+ {
77+ try
78+ {
79+ device->configureDevice ();
80+ }
81+ catch (const error_str& e)
82+ {
83+ LOGE (e.what ());
84+ b->setToggleState (!b->getToggleState (), dontSendNotification);
85+ return ;
86+ }
87+
88+ canvas->resetContext ();
89+ }
90+
91+ if (device->isEnabled ())
92+ {
93+ deviceEnableButton->setLabel (enabledButtonText);
94+ }
95+ else
96+ {
97+ deviceEnableButton->setLabel (disabledButtonText);
98+ }
99+
100+ CoreServices::updateSignalChain (editor);
101+ }
102+ }
103+
58104void AuxiliaryIOInterface::setInterfaceEnabledState (bool newState)
59105{
60106 analogInterface->setInterfaceEnabledState (newState);
0 commit comments