diff core/RTAudioCommandLine.cpp @ 16:670be80463a3 matrix_gpio

- analog matrixIn/matrixOut are now mapped as floats from 0 to 1 - use of an external PRU code can be enabled with -P <filename> - 16 channels of programmable GPIO can be accessed straight from render() either writing directly to the matrixGpio[] array or using digitalWrite(), digitalRead(), setDigitalDirection() macros from Utilities.h .
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 27 Apr 2015 13:01:57 +0100
parents a6beeba3a648
children c98863e63174
line wrap: on
line diff
--- a/core/RTAudioCommandLine.cpp	Sat Feb 07 16:41:56 2015 +0000
+++ b/core/RTAudioCommandLine.cpp	Mon Apr 27 13:01:57 2015 +0100
@@ -9,7 +9,6 @@
 #include <cstdlib>
 #include <cstring>
 #include <getopt.h>
-
 #include "../include/RTAudio.h"
 
 // Default command-line options for RTAudio
@@ -18,15 +17,18 @@
 	{"period", 1, NULL, 'p'},
 	{"verbose", 0, NULL, 'v'},
 	{"use-matrix", 1, NULL, 'm'},
+	{"use-matrix-gpio", 1, NULL, 'g'},
 	{"matrix-channels", 1, NULL, 'C'},
+	{"matrix-gpio-channels", 1, NULL, 'G'},
 	{"mute-speaker", 1, NULL, 'M'},
 	{"dac-level", 1, NULL, 'D'},
 	{"adc-level", 1, NULL, 'A'},
 	{"hp-level", 1, NULL, 'H'},
+	{"pru-file",1,NULL,'P'},
 	{NULL, 0, NULL, 0}
 };
 
-const char gDefaultShortOptions[] = "p:vm:M:C:D:A:H:";
+const char gDefaultShortOptions[] = "p:vm:M:C:D:A:H:P:g:G:";
 
 // This function sets the default settings for the RTAudioSettings structure
 void BeagleRT_defaultSettings(RTAudioSettings *settings)
@@ -38,8 +40,11 @@
 	settings->adcLevel = DEFAULT_ADC_LEVEL;
 	settings->headphoneLevel = DEFAULT_HP_LEVEL;
 	settings->useMatrix = 1;
+	settings->useMatrixGpio = 1;
 	settings->numMatrixChannels = 8;
+	settings->numMatrixGpioChannels = 16;
 	settings->verbose = 0;
+	settings->pruFilename[0]='\0';
 	settings->codecI2CAddress = CODEC_I2C_ADDRESS;
 	settings->ampMutePin = kAmplifierMutePin;
 }
@@ -125,6 +130,10 @@
 		case 'm':
 			settings->useMatrix = atoi(optarg);
 			break;
+		case 'g':
+			settings->useMatrixGpio = atoi(optarg);
+			settings->numMatrixGpioChannels = 0;
+			break;
 		case 'C':
 			settings->numMatrixChannels = atoi(optarg);
 			if(settings->numMatrixChannels >= 8)
@@ -134,6 +143,16 @@
 			else
 				settings->numMatrixChannels = 2;
 			break;
+		case 'G':
+			settings->numMatrixGpioChannels = atoi(optarg);
+			if(settings->numMatrixGpioChannels >= 16)
+				settings->numMatrixGpioChannels = 16;
+			else if (settings->numMatrixGpioChannels < 1){
+				settings->numMatrixGpioChannels = 0;
+				settings->useMatrixGpio = 0; //TODO: this actually works only if -G 0 is specified after -g 1.
+											 //No worries, though: disabling numMatrixGpio will only prevent the pins from being exported.
+			}
+			break;
 		case 'M':
 			settings->beginMuted = atoi(optarg);
 			break;
@@ -146,6 +165,12 @@
 		case 'H':
 			settings->headphoneLevel = atof(optarg);
 			break;
+		case 'P':
+			if(strlen(optarg)<MAX_PRU_FILENAME_LENGTH)
+				strcpy(settings->pruFilename, optarg);
+			else
+				std::cerr << "Warning: filename for the PRU code is too long (>" << MAX_PRU_FILENAME_LENGTH << " characters). Using embedded PRU code instead\n";
+			break;
 		case '?':
 		default:
 			return c;
@@ -157,12 +182,16 @@
 // Call from within your own usage function
 void BeagleRT_usage()
 {
-	std::cerr << "   --period [-p] period:       Set the hardware period (buffer) size in matrix samples\n";
-	std::cerr << "   --dac-level [-D] dBs:       Set the DAC output level (0dB max; -63.5dB min)\n";
-	std::cerr << "   --adc-level [-A] dBs:       Set the ADC input level (0dB max; -12dB min)\n";
-	std::cerr << "   --hp-level [-H] dBs:        Set the headphone output level (0dB max; -63.5dB min)\n";
-	std::cerr << "   --mute-speaker [-M] val:    Set whether to mute the speaker initially (default: no)\n";
-	std::cerr << "   --use-matrix [-m] val:      Set whether to use ADC/DAC matrix\n";
-	std::cerr << "   --matrix-channels [-C] val: Set the number of ADC/DAC channels (default: 8)\n";
-	std::cerr << "   --verbose [-v]:             Enable verbose logging information\n";
+	std::cerr << "   --period [-p] period:            Set the hardware period (buffer) size in matrix samples\n";
+	std::cerr << "   --dac-level [-D] dBs:            Set the DAC output level (0dB max; -63.5dB min)\n";
+	std::cerr << "   --adc-level [-A] dBs:            Set the ADC input level (0dB max; -12dB min)\n";
+	std::cerr << "   --hp-level [-H] dBs:             Set the headphone output level (0dB max; -63.5dB min)\n";
+	std::cerr << "   --mute-speaker [-M] val:         Set whether to mute the speaker initially (default: no)\n";
+	std::cerr << "   --use-matrix [-m] val:           Set whether to use ADC/DAC matrix (default: yes)\n";
+	std::cerr << "   --use-gpio-matrix [-g] val:      Set whether to use GPIO matrix (default: yes)\n";
+	std::cerr << "   --matrix-channels [-C] val:      Set the number of ADC/DAC channels (default: 8)\n";
+	std::cerr << "   --matrix-gpio-channels [-G] val: Set the number of GPIO channels (default: 16)\n";
+	std::cerr << "   --pru-file [-P] val:             Set an optional external file to use for the PRU binary code\n";
+	std::cerr << "   --verbose [-v]:                  Enable verbose logging information\n";
 }
+