Skip to content
Browse files

Remove parameter initialization from header file

  • Loading branch information...
1 parent e0590a2 commit 28ec88eaf5635304c4e7a1c4ab56817e88c4af6a jsiegle committed Feb 5, 2014
Showing with 46 additions and 19 deletions.
  1. +27 −2 Source/Processors/Serial/PulsePal.cpp
  2. +19 −17 Source/Processors/Serial/PulsePal.h
View
29 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;
View
36 Source/Processors/Serial/PulsePal.h
@@ -44,9 +44,11 @@ class PulsePal
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 @@ class PulsePal
// 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;

0 comments on commit 28ec88e

Please sign in to comment.
Something went wrong with that request. Please try again.