From 1d9c446177b1a8ab7d740940c12268646e5b9051 Mon Sep 17 00:00:00 2001 From: bparks13 Date: Tue, 8 Apr 2025 14:04:50 -0400 Subject: [PATCH 01/15] Add updateSettings virtual method --- Source/UI/AnalogIOInterface.cpp | 12 ++++++++++++ Source/UI/AnalogIOInterface.h | 2 ++ Source/UI/Bno055Interface.h | 2 ++ Source/UI/DigitalIOInterface.h | 2 ++ Source/UI/HarpSyncInputInterface.h | 2 ++ Source/UI/NeuropixV1Interface.h | 2 ++ Source/UI/OutputClockInterface.h | 2 ++ Source/UI/SettingsInterface.h | 3 ++- 8 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Source/UI/AnalogIOInterface.cpp b/Source/UI/AnalogIOInterface.cpp index 7d304c0..9d761d1 100644 --- a/Source/UI/AnalogIOInterface.cpp +++ b/Source/UI/AnalogIOInterface.cpp @@ -81,6 +81,18 @@ AnalogIOInterface::AnalogIOInterface(std::shared_ptr d, OnixSourceEdit type = SettingsInterface::Type::ANALOGIO_SETTINGS_INTERFACE; } +void AnalogIOInterface::updateSettings() +{ + deviceEnableButton->setToggleState(device->isEnabled(), dontSendNotification); + + auto analogIO = std::static_pointer_cast(device); + + for (int i = 0; i < numChannels; i++) + { + channelDirectionComboBoxes[i]->setSelectedId(getChannelDirectionId(analogIO, i), dontSendNotification); + } +} + void AnalogIOInterface::buttonClicked(Button* button) { if (button == deviceEnableButton.get()) diff --git a/Source/UI/AnalogIOInterface.h b/Source/UI/AnalogIOInterface.h index b97529a..fc41642 100644 --- a/Source/UI/AnalogIOInterface.h +++ b/Source/UI/AnalogIOInterface.h @@ -52,6 +52,8 @@ class AnalogIOInterface : public SettingsInterface, /** Updates the info string on the right-hand side of the component */ void updateInfoString() override {}; + void updateSettings() override; + /** Listener methods*/ void buttonClicked(Button*) override; void comboBoxChanged(ComboBox* cb) override; diff --git a/Source/UI/Bno055Interface.h b/Source/UI/Bno055Interface.h index 5eeb121..cc903df 100644 --- a/Source/UI/Bno055Interface.h +++ b/Source/UI/Bno055Interface.h @@ -51,6 +51,8 @@ class Bno055Interface : public SettingsInterface, /** Updates the info string on the right-hand side of the component */ void updateInfoString() override {}; + void updateSettings() override {}; + /** Listener methods*/ void buttonClicked(Button*) override; diff --git a/Source/UI/DigitalIOInterface.h b/Source/UI/DigitalIOInterface.h index 168078c..9411a7b 100644 --- a/Source/UI/DigitalIOInterface.h +++ b/Source/UI/DigitalIOInterface.h @@ -51,6 +51,8 @@ class DigitalIOInterface : public SettingsInterface, /** Updates the info string on the right-hand side of the component */ void updateInfoString() override {}; + void updateSettings() override {}; + /** Listener methods*/ void buttonClicked(Button*) override; diff --git a/Source/UI/HarpSyncInputInterface.h b/Source/UI/HarpSyncInputInterface.h index 7b77512..a004a62 100644 --- a/Source/UI/HarpSyncInputInterface.h +++ b/Source/UI/HarpSyncInputInterface.h @@ -50,6 +50,8 @@ class HarpSyncInputInterface : public SettingsInterface, void updateInfoString() override {}; + void updateSettings() override {}; + /** Listener methods*/ void buttonClicked(Button*) override; diff --git a/Source/UI/NeuropixV1Interface.h b/Source/UI/NeuropixV1Interface.h index 1eb8389..eb0bed7 100644 --- a/Source/UI/NeuropixV1Interface.h +++ b/Source/UI/NeuropixV1Interface.h @@ -69,6 +69,8 @@ class NeuropixV1Interface : public SettingsInterface, /** Updates the info string on the right-hand side of the component */ void updateInfoString() override; + void updateSettings() override {}; + /** Set parameters */ void setApGain(int index); void setLfpGain(int index); diff --git a/Source/UI/OutputClockInterface.h b/Source/UI/OutputClockInterface.h index 089f47e..b90a1ea 100644 --- a/Source/UI/OutputClockInterface.h +++ b/Source/UI/OutputClockInterface.h @@ -52,6 +52,8 @@ class OutputClockInterface : public SettingsInterface, /** Updates the info string on the right-hand side of the component */ void updateInfoString() override {}; + void updateSettings() override; + /** Listener methods*/ void buttonClicked(Button*) override; void labelTextChanged(Label* l) override; diff --git a/Source/UI/SettingsInterface.h b/Source/UI/SettingsInterface.h index c42d2a8..85a4fb4 100644 --- a/Source/UI/SettingsInterface.h +++ b/Source/UI/SettingsInterface.h @@ -83,7 +83,8 @@ class SettingsInterface : public Component /** Updates the string with info about the underlying data source*/ virtual void updateInfoString() = 0; - virtual String getReferenceText() { return ""; } + /** Updates the UI elements based on the current device settings */ + virtual void updateSettings() = 0; /** Default type */ Type type = Type::UNKNOWN_SETTINGS_INTERFACE; From 2bce3d27ccf7ae09886edcfab4d9709a258fd236 Mon Sep 17 00:00:00 2001 From: bparks13 Date: Mon, 7 Apr 2025 15:25:54 -0400 Subject: [PATCH 02/15] Load/Save AnalogIO settings --- Source/Devices/AnalogIO.h | 39 ++++++++++------ Source/OnixSourceCanvas.cpp | 8 ++-- Source/UI/AnalogIOInterface.cpp | 83 +++++++++++++++++++++++++++++---- Source/UI/AnalogIOInterface.h | 5 +- 4 files changed, 108 insertions(+), 27 deletions(-) diff --git a/Source/Devices/AnalogIO.h b/Source/Devices/AnalogIO.h index d74466a..e21eacb 100644 --- a/Source/Devices/AnalogIO.h +++ b/Source/Devices/AnalogIO.h @@ -99,6 +99,19 @@ class AnalogIO : public OnixDevice return channelDirection[channelNumber]; } + static String getChannelDirection(AnalogIODirection direction) + { + switch (direction) + { + case AnalogIODirection::Input: + return "Input"; + case AnalogIODirection::Output: + return "Output"; + default: + return ""; + } + } + void setChannelDirection(int channelNumber, AnalogIODirection direction) { if (channelNumber > numChannels || channelNumber < 0) @@ -121,21 +134,8 @@ class AnalogIO : public OnixDevice return channelVoltageRange[channelNumber]; } - void setChannelVoltageRange(int channelNumber, AnalogIOVoltageRange direction) - { - if (channelNumber > numChannels || channelNumber < 0) - { - LOGE("Channel number must be between 0 and " + String(channelNumber)); - return; - } - - channelVoltageRange[channelNumber] = direction; - } - AnalogIODataType getDataType() const { return dataType; } - void setDataType(AnalogIODataType type) { dataType = type; } - int getNumChannels() { return numChannels; } private: @@ -174,5 +174,18 @@ class AnalogIO : public OnixDevice static float getVoltsPerDivision(AnalogIOVoltageRange voltageRange); + void setChannelVoltageRange(int channelNumber, AnalogIOVoltageRange direction) + { + if (channelNumber > numChannels || channelNumber < 0) + { + LOGE("Channel number must be between 0 and " + String(channelNumber)); + return; + } + + channelVoltageRange[channelNumber] = direction; + } + + void setDataType(AnalogIODataType type) { dataType = type; } + JUCE_LEAK_DETECTOR(AnalogIO); }; diff --git a/Source/OnixSourceCanvas.cpp b/Source/OnixSourceCanvas.cpp index 072f4d2..899be96 100644 --- a/Source/OnixSourceCanvas.cpp +++ b/Source/OnixSourceCanvas.cpp @@ -532,12 +532,12 @@ void OnixSourceCanvas::stopAcquisition() void OnixSourceCanvas::saveCustomParametersToXml(XmlElement* xml) { - //for (int i = 0; i < settingsInterfaces.size(); i++) - // settingsInterfaces[i]->saveParameters(xml); + for (int i = 0; i < settingsInterfaces.size(); i++) + settingsInterfaces[i]->saveParameters(xml); } void OnixSourceCanvas::loadCustomParametersFromXml(XmlElement* xml) { - //for (int i = 0; i < settingsInterfaces.size(); i++) - // settingsInterfaces[i]->loadParameters(xml); + for (int i = 0; i < settingsInterfaces.size(); i++) + settingsInterfaces[i]->loadParameters(xml); } diff --git a/Source/UI/AnalogIOInterface.cpp b/Source/UI/AnalogIOInterface.cpp index 9d761d1..129bc75 100644 --- a/Source/UI/AnalogIOInterface.cpp +++ b/Source/UI/AnalogIOInterface.cpp @@ -50,11 +50,6 @@ AnalogIOInterface::AnalogIOInterface(std::shared_ptr d, OnixSourceEdit directionList.add("Input"); directionList.add("Output"); - StringArray voltageRangeList; - voltageRangeList.add("+/- 2.5 V"); - voltageRangeList.add("+/- 5.0 V"); - voltageRangeList.add("+/- 10.0 V"); - for (int i = 0; i < numChannels; i += 1) { channelDirectionLabels[i] = std::make_unique