-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathleverThread_Runner.cpp
67 lines (53 loc) · 2.1 KB
/
leverThread_Runner.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* ************************ Runs the lever_thread for testing purposes ***********************************
Compile like this:
g++ -O3 -std=gnu++11 -Wall -lpulsedThread -lwiringPi GPIOlowlevel.cpp SimpleGPIO_thread.cpp PWM_thread.cpp leverThread.cpp leverThread_Runner.cpp -o leverThread
last modified:
2019/03/05 by Jamie Boyd - lever positions now 2 byte signed
2018/03/08 by Jamie Boyd - started lever_threadRunner */
#include "leverThread.h"
/* ************************ Gets a line of input from stdin into a passed-in char buffer ************************************************************************************
returns false if there are too many characters on the line to fit into the passed in buffer
Last modified :
2016/06/01 by Jamie Boyd - initial version */
bool myGetline(char * line, int lenMax, int keepNewLine) {
int len;
int readVal;
char readChar;
for(len=0; len < lenMax; len +=1) {
readVal = getchar(); // read next value into an int (need bigger than a char to account for EOF -which we should never see anyways
readChar = (char) readVal;
line[len] =readChar;
if ( readChar == '\n'){
if (keepNewLine)
len +=1;
break;
}
}
if (len == lenMax ){
printf ("You entered too many characters on the line; the limit is %d\n", lenMax);
return false;
}else{
line[len] = '\0';
return true;
}
}
int main(int argc, char **argv){
int16_t * positionData = new int16_t [6000];
leverThread * myLeverThread= leverThread::leverThreadMaker (positionData,1000, kTRIAL_CUED, 500, kLEVER_DIR_REVERSED, 22, 0, 0, false);
int oldZero = myLeverThread->zeroLever (1,0);
myLeverThread->setHoldParams (25, 175, 250);
myLeverThread->startTrial();
printf ("leverThread GO\n");
fflush (stdout);
int trialCode;
unsigned int goalEntryPos;
unsigned int ii =0;
while (myLeverThread->checkTrial(trialCode, goalEntryPos) == false){
printf ("LEVERPOS = %d; trialCode = %d.\n", myLeverThread->getLeverPos(), trialCode);
}
printf("goal entry pos = %d; trial code = %i\n", goalEntryPos, trialCode);
for (ii =0; ii < 1000; ii +=1){
printf ("%i, ", positionData[ii]);
}
printf ("\n");
}