diff projects/analogDigitalDemo/render.cpp @ 20:58eb99dac921 matrix_gpio

- rebuilt the eclipse project file - renamed matrixGpio to digital and matrix to analog in the analogDigitalDemo project
author Giulio Moro <giuliomoro@yahoo.it>
date Thu, 30 Apr 2015 17:43:08 +0100
parents c98863e63174
children fbfeb5895efd
line wrap: on
line diff
--- a/projects/analogDigitalDemo/render.cpp	Thu Apr 30 16:58:41 2015 +0100
+++ b/projects/analogDigitalDemo/render.cpp	Thu Apr 30 17:43:08 2015 +0100
@@ -21,50 +21,50 @@
 // in from the call to initAudio().
 //
 // Return true on success; returning false halts the program.
-int gNumMatrixGpioFrames=0;
-bool initialise_render(int numMatrixChannels, int numMatrixGpioChannels, int numAudioChannels,
-					   int numMatrixFramesPerPeriod,
+int gNumDigitalFrames=0;
+bool initialise_render(int numAnalogChannels, int numDigitalChannels, int numAudioChannels,
+					   int numAnalogFramesPerPeriod,
 					   int numAudioFramesPerPeriod,
-					   float matrixSampleRate, float audioSampleRate,
+					   float analogSampleRate, float audioSampleRate,
 					   void *userData)
 {
-	gNumMatrixChannels=numMatrixChannels;
+	gNumAnalogChannels=numAnalogChannels;
 	return true;
 }
 
 // render() is called regularly at the highest priority by the audio engine.
 // Input and output are given from the audio hardware and the other
-// ADCs and DACs (if available). If only audio is available, numMatrixFrames
+// ADCs and DACs (if available). If only audio is available, numAnalogFrames
 // will be 0.
 
 long int gCountFrames=0;
-void render(int numMatrixFrames, int numMatrixGpioFrames, int numAudioFrames, float *audioIn, float *audioOut,
-			float *matrixIn, float *matrixOut, uint32_t *matrixGpio)
+void render(int numAnalogFrames, int numDigitalFrames, int numAudioFrames, float *audioIn, float *audioOut,
+			float *analogIn, float *analogOut, uint32_t *digital)
 /*
  * Hey, expect buffer underruns to happen here, as we are doing lots of printfs
  * */
 {
-	gNumMatrixGpioFrames=numMatrixGpioFrames;
+	gNumDigitalFrames=numDigitalFrames;
 	if(gCountFrames==0){ //this will be executed only on the first call to render(), but the bits will go through this cycle for every subsequent buffer
 						// that is, P8_29 will pulse at the beginning of each buffer
 	}
-	for(int i=1; i<gNumMatrixGpioFrames; i++)
+	for(int i=1; i<gNumDigitalFrames; i++)
 		digitalWriteAll(i, GPIO_LOW); //write all channels on the given frame. Initialize them to zero
 	digitalWrite(0, 4, GPIO_HIGH); // set pin 0 HIGH from the current frame to the end of the buffer
-	for(int n=0; n<numMatrixFrames; n++) {
-		for(int c=0; c<gNumMatrixChannels; c++)
-			analogWriteFrame(c,n,0); //set channel c on frame n to 0, equivalent to matrixOut[n*numMatrixChannels+c]=0;
+	for(int n=0; n<numAnalogFrames; n++) {
+		for(int c=0; c<gNumAnalogChannels; c++)
+			AnalogWriteFrame(c,n,0); //set channel c on frame n to 0, equivalent to analogOut[n*numAnalogChannels+c]=0;
 	}
-	analogWrite(0,3,0.2); //set channel 0 to 0.2 from frame 3 onwards ...
-	analogWrite(1,3,0.7); //set channel 1 to 0.7 from frame 3 onwards ...
-	analogWrite(2,6,0.5); //set channel 2 to 0.5 from frame 6 onwards ...
+	AnalogWrite(0,3,0.2); //set channel 0 to 0.2 from frame 3 onwards ...
+	AnalogWrite(1,3,0.7); //set channel 1 to 0.7 from frame 3 onwards ...
+	AnalogWrite(2,6,0.5); //set channel 2 to 0.5 from frame 6 onwards ...
 	for(int n=0; n<numAudioFrames; n++){
-		printf("Digital frame %d: 0x%08x;\n",n,matrixGpio[n]);
+		printf("Digital frame %d: 0x%08x;\n",n,digital[n]);
 	}
-	for(int n=0; n<numMatrixFrames; n++){
+	for(int n=0; n<numAnalogFrames; n++){
 		printf("Analog out frame %d :",n);
-		for(int c=0; c<gNumMatrixChannels; c++)
-			printf("%.1f ",matrixOut[n*gNumMatrixChannels + c]);
+		for(int c=0; c<gNumAnalogChannels; c++)
+			printf("%.1f ",analogOut[n*gNumAnalogChannels + c]);
 		printf("\n");
 	}
 }