Skip to content
Snippets Groups Projects
Commit b6ae1c6a authored by jsiegle's avatar jsiegle
Browse files

Spikes are now written to disk through the SpikeDisplayCanvas

parent 6d9452c5
No related branches found
No related tags found
No related merge requests found
...@@ -333,6 +333,8 @@ void SpikeDetector::addSpikeEvent(SpikeObject* s, MidiBuffer& eventBuffer, int p ...@@ -333,6 +333,8 @@ void SpikeDetector::addSpikeEvent(SpikeObject* s, MidiBuffer& eventBuffer, int p
// std::cout << "Adding spike event for index " << peakIndex << std::endl; // std::cout << "Adding spike event for index " << peakIndex << std::endl;
s->eventType = SPIKE_EVENT_CODE;
int numBytes = packSpike(s, spikeBuffer, 256); int numBytes = packSpike(s, spikeBuffer, 256);
eventBuffer.addEvent(spikeBuffer, numBytes, peakIndex); eventBuffer.addEvent(spikeBuffer, numBytes, peakIndex);
......
...@@ -416,6 +416,9 @@ SpikePlot::SpikePlot(SpikeDisplayCanvas* sdc, int elecNum, int p, String name_) ...@@ -416,6 +416,9 @@ SpikePlot::SpikePlot(SpikeDisplayCanvas* sdc, int elecNum, int p, String name_)
rangeButtons.add(rangeButton); rangeButtons.add(rangeButton);
} }
spikeBuffer = new uint8_t[MAX_SPIKE_BUFFER_LEN]; // MAX_SPIKE_BUFFER_LEN defined in SpikeObject.h
} }
SpikePlot::~SpikePlot() SpikePlot::~SpikePlot()
...@@ -536,7 +539,12 @@ void SpikePlot::closeFile() ...@@ -536,7 +539,12 @@ void SpikePlot::closeFile()
void SpikePlot::writeSpike(const SpikeObject& s) void SpikePlot::writeSpike(const SpikeObject& s)
{ {
// write spike to the file
packSpike(&s, spikeBuffer, 256);
fwrite(spikeBuffer, 1, 256, file);
} }
String SpikePlot::generateHeader() String SpikePlot::generateHeader()
......
...@@ -236,6 +236,7 @@ private: ...@@ -236,6 +236,7 @@ private:
FILE* file; FILE* file;
String filename; String filename;
File dataDirectory; File dataDirectory;
uint8_t* spikeBuffer;
}; };
......
...@@ -27,16 +27,13 @@ ...@@ -27,16 +27,13 @@
#include "time.h" #include "time.h"
// Simple method for serializing a SpikeObject into a string of bytes // Simple method for serializing a SpikeObject into a string of bytes
int packSpike(SpikeObject* s, uint8_t* buffer, int bufferSize) int packSpike(const SpikeObject* s, uint8_t* buffer, int bufferSize)
{ {
//int reqBytes = 1 + 4 + 2 + 2 + 2 + 2 * s->nChannels * s->nSamples + 2 * s->nChannels * 2; //int reqBytes = 1 + 4 + 2 + 2 + 2 + 2 * s->nChannels * s->nSamples + 2 * s->nChannels * 2;
int idx = 0; int idx = 0;
s->eventType = SPIKE_EVENT_CODE;
memcpy(buffer+idx, &(s->eventType), 1); memcpy(buffer+idx, &(s->eventType), 1);
idx += 1; idx += 1;
......
...@@ -68,7 +68,7 @@ struct SpikeObject ...@@ -68,7 +68,7 @@ struct SpikeObject
}; };
/** Simple method for serializing a SpikeObject into a string of bytes, returns true is the packaged spike buffer is valid */ /** Simple method for serializing a SpikeObject into a string of bytes, returns true is the packaged spike buffer is valid */
int packSpike(SpikeObject* s, uint8_t* buffer, int bufferLength); int packSpike(const SpikeObject* s, uint8_t* buffer, int bufferLength);
/** Simple method for deserializing a string of bytes into a Spike object, returns true is the provided spike buffer is valid */ /** Simple method for deserializing a string of bytes into a Spike object, returns true is the provided spike buffer is valid */
bool unpackSpike(SpikeObject* s, const uint8_t* buffer, int bufferLength); bool unpackSpike(SpikeObject* s, const uint8_t* buffer, int bufferLength);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment