diff projects/d-box/main.cpp @ 15:901d205d1a3c

Updated to latest PRU library; external PRU file no longer needed. Also catch SIGTERM as well as SIGINT to clean up gracefully.
author andrewm
date Sat, 07 Feb 2015 16:41:56 +0000
parents 09f03ac40fcc
children be427da6fb9c
line wrap: on
line diff
--- a/projects/d-box/main.cpp	Fri Jan 23 15:35:10 2015 +0000
+++ b/projects/d-box/main.cpp	Sat Feb 07 16:41:56 2015 +0000
@@ -71,7 +71,7 @@
 
 int touchSensor0Address = 0x0C;				// I2C addresses of touch sensors
 int touchSensor1Address = 0x0B;
-bool useNewSensors = false;
+int sensorType = 0;
 
 char sdPath[256]			= "/dev/mmcblk0p2";			// system path of the SD, partition 2
 char mountPath[256]			= "/root/d-box/usersounds";	// mount point of SD partition 2 [where user files are]
@@ -275,7 +275,7 @@
 		{"file", 1, NULL, 'f'},
 		{"keyboard", 1, NULL, 'k'},
 		{"audio-test", 0, NULL, 'T'},
-		{"new-sensors", 0, NULL, 'S'},
+		{"sensor-type", 1, NULL, 'S'},
 		{"sensor0", 1, NULL, 'Q'},
 		{"sensor1", 1, NULL, 'R'},
 		{"log", 1, NULL, 'l'},
@@ -293,7 +293,7 @@
 	while (1)
 	{
 		int c;
-		if ((c = BeagleRT_getopt_long(args.argc, args.argv, "hf:ki:sTQ:R:Sl:u:o:n:g:", long_option, settings)) < 0)
+		if ((c = BeagleRT_getopt_long(args.argc, args.argv, "hf:ki:sTQ:R:S:l:u:o:n:g:", long_option, settings)) < 0)
 				break;
 		switch (c)
 		{
@@ -317,7 +317,7 @@
 				useAudioTest = true;
 				break;
 		case 'S':
-				useNewSensors = true;
+				sensorType = atoi(optarg);
 				break;
 		case 'Q':
 				touchSensor0Address = atoi(optarg);
@@ -396,7 +396,7 @@
 		free(gPartialFilename);
 
 	if(!useAudioTest) {
-		if(initSensorLoop(touchSensor0Address, touchSensor1Address, useNewSensors) != 0)
+		if(initSensorLoop(touchSensor0Address, touchSensor1Address, sensorType) != 0)
 			return -1;
 	}
 
@@ -450,8 +450,9 @@
 		}
 	}
 
-	// Set up interrupt handler to catch Control-C
+	// Set up interrupt handler to catch Control-C and SIGTERM
 	signal(SIGINT, interrupt_handler);
+	signal(SIGTERM, interrupt_handler);
 
 	// load all other files into oscBanks
 	loadAudioFiles(false);