Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added parameters to FPGAOutput

  • Loading branch information...
commit cb54295881049f52287127f229a5c24bb85d5bad 1 parent 7f46cad
jsiegle authored
View
20 Source/Processors/Editors/FPGAOutputEditor.cpp
@@ -33,17 +33,17 @@ FPGAOutputEditor::FPGAOutputEditor (GenericProcessor* parentNode)
accumulator = 0;
- desiredWidth = 150;
+ desiredWidth = 180;
- Image im;
- im = ImageCache::getFromMemory (BinaryData::OpenEphysBoardLogoBlack_png,
- BinaryData::OpenEphysBoardLogoBlack_pngSize);
+ // Image im;
+ // im = ImageCache::getFromMemory (BinaryData::OpenEphysBoardLogoBlack_png,
+ // BinaryData::OpenEphysBoardLogoBlack_pngSize);
- icon = new ImageIcon(im);
- addAndMakeVisible(icon);
- icon->setBounds(15,15,120,120);
+ // icon = new ImageIcon(im);
+ // addAndMakeVisible(icon);
+ // icon->setBounds(15,15,120,120);
- icon->setOpacity(0.3f);
+ // icon->setOpacity(0.3f);
}
@@ -55,8 +55,8 @@ FPGAOutputEditor::~FPGAOutputEditor()
void FPGAOutputEditor::receivedEvent()
{
- icon->setOpacity(0.8f);
- startTimer(50);
+ //icon->setOpacity(0.8f);
+ //startTimer(50);
}
View
2  Source/Processors/Editors/FPGAOutputEditor.h
@@ -43,6 +43,8 @@ class FPGAOutputEditor : public GenericEditor
void receivedEvent();
+ // void buttonEvent(Button* button);
+
ImageIcon* icon;
private:
View
86 Source/Processors/FPGAOutput.cpp
@@ -28,9 +28,24 @@
#include "SourceNode.h"
FPGAOutput::FPGAOutput()
- : GenericProcessor("FPGA Output"), isEnabled(true)
+ : GenericProcessor("FPGA Output"), isEnabled(true), TTLchannel(3), continuousStim(false)
{
+ Array<var> channelNumbers;
+ channelNumbers.add(0);
+ channelNumbers.add(3);
+ channelNumbers.add(5);
+ //
+ // channelNumbers.add(6);
+
+ parameters.add(Parameter("TTL channel",channelNumbers, 1, 0));
+
+ Array<var> stimType;
+ stimType.add(0);
+ stimType.add(1);
+ stimType.add(2);
+
+ parameters.add(Parameter("Stim Type",stimType, 0, 1));
}
@@ -56,11 +71,24 @@ void FPGAOutput::handleEvent(int eventType, MidiMessage& event)
int eventId = *(dataptr+2);
int eventChannel = *(dataptr+3);
- if (eventId == 1 && eventChannel == 3) // channel 3 only at the moment
+ if (eventId == 1 && eventChannel == TTLchannel) // channel 3 only at the moment
{
sendActionMessage("HI");
isEnabled = false;
- startTimer(10); // pulse width
+
+ if (!continuousStim)
+ startTimer(5); // pulse width
+ else
+ startTimer(10); // pulse width
+
+ } else if (eventId == 0 && eventChannel == TTLchannel)
+ {
+ if (!continuousStim)
+ {
+ sendActionMessage("LO");
+ isEnabled = false;
+ stopTimer();
+ }
}
@@ -84,18 +112,37 @@ void FPGAOutput::updateSettings()
src = lastSrc->getSourceNode();
}
- //SourceNode* s = (SourceNode*) settings.originalSource;
- std::cout << "FPGA Output node communicating with " << lastSrc->getName() << std::endl;
-
- SourceNode* s = (SourceNode*) lastSrc;
+ if (lastSrc != 0)
+ {
+ SourceNode* s = (SourceNode*) lastSrc;
+ addActionListener(s);
+ std::cout << "FPGA Output node communicating with " << lastSrc->getName() << std::endl;
+ } else {
+ std::cout << "FPGA Output couldn't find a source" << std::endl;
+ }
+
- addActionListener(s);
//dataThread = (FPGAThread*) s->getThread();
}
void FPGAOutput::setParameter (int parameterIndex, float newValue)
{
+ //std::cout << "FPGAOutput received parameter change notification." << std::endl;
+
+ if (parameterIndex == 0)
+ {
+ TTLchannel = int(newValue);
+ } else if (parameterIndex == 1)
+ {
+ if (newValue == 0.0f)
+ {
+ continuousStim = false;
+ } else {
+ continuousStim = true;
+ }
+ }
+
}
void FPGAOutput::process(AudioSampleBuffer &buffer,
@@ -112,8 +159,25 @@ void FPGAOutput::process(AudioSampleBuffer &buffer,
void FPGAOutput::timerCallback()
{
//dataThread->setOutputLow();
- sendActionMessage("LO");
+
+ if (!continuousStim)
+ {
+ sendActionMessage("LO");
+
+ isEnabled = true;
+ stopTimer();
+ } else {
+
+ if (isEnabled)
+ {
+ sendActionMessage("HI");
+ isEnabled = false;
+ } else {
+ sendActionMessage("LO");
+ isEnabled = true;
+ }
+
+
+ }
- isEnabled = true;
- stopTimer();
}
View
4 Source/Processors/FPGAOutput.h
@@ -66,9 +66,13 @@ class FPGAOutput : public GenericProcessor,
private:
+ int TTLchannel;
+
void timerCallback();
bool isEnabled;
+
+ bool continuousStim;
FPGAThread* dataThread;
Please sign in to comment.
Something went wrong with that request. Please try again.