diff --git a/Source/Processors/Serial/PulsePal.cpp b/Source/Processors/Serial/PulsePal.cpp index a4ef5c8412f48f959b83e858c3ba0260ebe19530..0593774c109b13b4a126a0603e1cd0300aab6bbe 100644 --- a/Source/Processors/Serial/PulsePal.cpp +++ b/Source/Processors/Serial/PulsePal.cpp @@ -36,7 +36,8 @@ PulsePal::PulsePal() { - + setDefaultParameters(); + } PulsePal::~PulsePal() @@ -45,6 +46,30 @@ PulsePal::~PulsePal() serial.close(); } +void PulsePal::setDefaultParameters() +{ + + for (int i = 1; i < 5; i++) + { + currentOutputParams[i].isBiphasic = 0; + currentOutputParams[i].phase1Voltage = 5; + currentOutputParams[i].phase2Voltage = -5; + currentOutputParams[i].phase1Duration = 0.001; + currentOutputParams[i].interPhaseInterval = 0.001; + currentOutputParams[i].phase2Duration = 0.001; + currentOutputParams[i].interPulseInterval = 0.01; + currentOutputParams[i].burstDuration = 0; + currentOutputParams[i].interBurstInterval = 0; + currentOutputParams[i].pulseTrainDuration = 1; + currentOutputParams[i].pulseTrainDelay = 0; + currentOutputParams[i].linkTriggerChannel1 = 1; + currentOutputParams[i].linkTriggerChannel2 = 0; + currentOutputParams[i].customTrainID = 0; + currentOutputParams[i].customTrainTarget = 0; + currentOutputParams[i].customTrainLoop = 0; + } +} + void PulsePal::initialize() { @@ -78,7 +103,7 @@ uint32_t PulsePal::getFirmwareVersion() // JS 1/30/2014 uint8_t handshakeByte = 72; uint8_t responseBytes[5] = { 0 }; serial.writeByte(handshakeByte); - Sleep(100); + usleep(100000); serial.readBytes(responseBytes,5); firmwareVersion = makeLong(responseBytes[4], responseBytes[3], responseBytes[2], responseBytes[1]); return firmwareVersion; diff --git a/Source/Processors/Serial/PulsePal.h b/Source/Processors/Serial/PulsePal.h index 3e9167a93c4355731c05b6466822f950b14ab682..ec307ac7211ea1ff5648a990a3150580eb8677b4 100644 --- a/Source/Processors/Serial/PulsePal.h +++ b/Source/Processors/Serial/PulsePal.h @@ -44,9 +44,11 @@ public: PulsePal(); ~PulsePal(); void initialize(); - uint32_t PulsePal::getFirmwareVersion(); + uint32_t getFirmwareVersion(); void disconnectClient(); + void setDefaultParameters(); + // Program single parameter void setBiphasic(uint8_t channel, bool isBiphasic); void setPhase1Voltage(uint8_t channel, float voltage); @@ -82,22 +84,22 @@ public: // Fields struct OutputParams { - int isBiphasic = 0; - float phase1Voltage = 5; - float phase2Voltage = -5; - float phase1Duration = 0.001; - float interPhaseInterval = 0.001; - float phase2Duration = 0.001; - float interPulseInterval = 0.01; - float burstDuration = 0; - float interBurstInterval = 0; - float pulseTrainDuration = 1; - float pulseTrainDelay = 0; - int linkTriggerChannel1 = 1; - int linkTriggerChannel2 = 0; - int customTrainID = 0; - int customTrainTarget = 0; - int customTrainLoop = 0; + int isBiphasic; + float phase1Voltage; + float phase2Voltage; + float phase1Duration; + float interPhaseInterval; + float phase2Duration; + float interPulseInterval; + float burstDuration; + float interBurstInterval; + float pulseTrainDuration; + float pulseTrainDelay; + int linkTriggerChannel1; + int linkTriggerChannel2; + int customTrainID; + int customTrainTarget; + int customTrainLoop; } currentOutputParams[5]; // Use 1-indexing for the channels (output channels 1-4 = currentOutputParams[1]-currentOutputParams[4]) struct InputParams { int triggerMode;