/* GRAPHTPU.CC Prints the output of TPU 13 to a graph. Alistair Sutherland suthe-aj@ee.uwa.edu.au CIIPS, 2003 */ // Test TPU output #include #include "eyebot.h" extern "C" { #include "ppwa.h" } #define MAX_SAMPLES 4000 #define MINY 6000 #define MAXY 9000 #define FREE_EXIT(x) \ { \ if (rgiTPU13) free(rgiTPU13); \ return (x); \ } // Prototypes... int ScaleDataToScreen64(int iMinY,int iMaxY,int iY); int main( ) { int iKey; int iSampleNumber; int iStart; int iEnd; int i; // Initialise sample arrays int * rgiTPU13; // Allocate memory for accn sensor samples rgiTPU13 = (int *)malloc(MAX_SAMPLES * sizeof(int)); if (rgiTPU13 == NULL) { LCDPrintf("Failed to malloc rgiTPU13\n"); FREE_EXIT(-1); } // Start writing 50% to SERVO S11 (this is unreltated to TPU13) ServoHandle hServo = SERVOInit(SERVO11); SERVOSet(hServo, 127); LCDPrintf("Graph TPU13:\n"); LCDPrintf(" KEY1 start\n"); LCDPrintf(" KEY4 stop\n"); // Wait for KEY1 before starting iKey = KEYGet(); iKey = 0; // Beep three times before starting AUBeep(); OSWait(100); AUBeep(); OSWait(100); AUBeep(); LCDClear(); tpuinit(); tpurelease(); tpuinit(); // Get TPU reading of the first sample iSampleNumber = 0; rgiTPU13[iSampleNumber] = tpuread13(); OSWait(100); for ( rgiTPU13[iSampleNumber]=-1; rgiTPU13[iSampleNumber]<0; rgiTPU13[iSampleNumber] = tpuread13()) { OSWait(10); } iSampleNumber++; // Now take samples until the key is pressed again, or we have the maximum... while (iKey!=KEY4 && iSampleNumber