changeset 19:5d91c6f5aa90

Updates to support resetting baseline for key scan.
author Andrew McPherson <andrewm@eecs.qmul.ac.uk>
date Sat, 07 Dec 2013 18:44:48 +0000
parents c8387e4f119f
children dfff66c07936 aeec68269253
files Builds/MacOSX/TouchKeys.xcodeproj/project.pbxproj Builds/MacOSX/TouchKeys.xcodeproj/project.xcworkspace/xcuserdata/apm.xcuserdatad/UserInterfaceState.xcuserstate Source/TouchKeys/TouchkeyDevice.cpp Source/TouchKeys/TouchkeyDevice.h
diffstat 4 files changed, 35 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Builds/MacOSX/TouchKeys.xcodeproj/project.pbxproj	Wed Nov 27 00:37:43 2013 +0000
+++ b/Builds/MacOSX/TouchKeys.xcodeproj/project.pbxproj	Sat Dec 07 18:44:48 2013 +0000
@@ -2973,7 +2973,6 @@
 					"_DEBUG=1",
 					"DEBUG=1",
 					"JUCER_XCODE_MAC_F6D2F4CF=1",
-					ENABLE_TOUCHKEYS_SENSOR_TEST,
 				);
 				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
 				HEADER_SEARCH_PATHS = (
Binary file Builds/MacOSX/TouchKeys.xcodeproj/project.xcworkspace/xcuserdata/apm.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/Source/TouchKeys/TouchkeyDevice.cpp	Wed Nov 27 00:37:43 2013 +0000
+++ b/Source/TouchKeys/TouchkeyDevice.cpp	Sat Dec 07 18:44:48 2013 +0000
@@ -665,6 +665,40 @@
 	return checkForAck(250);	
 }
 
+// Update the baseline sensor values on the given key
+bool TouchkeyDevice::setKeyUpdateBaseline(int octave, int key) {
+    unsigned char baselineCommand[] = {ESCAPE_CHARACTER, kControlCharacterFrameBegin,
+        kFrameTypeSendI2CCommand, (unsigned char)octave, (unsigned char)key,
+        2 /* xmit */, 0 /* response */, 0 /* command offset */, 6 /* baseline update */,
+        ESCAPE_CHARACTER, kControlCharacterFrameEnd};
+    
+    // Send command
+	if(write(device_, (char*)baselineCommand, 11) < 0) {
+        if(verbose_ >= 1)
+            cout << "ERROR: unable to write baseline update command.  errno = " << errno << endl;
+	}
+	tcdrain(device_);
+	
+	if(verbose_ >= 2)
+		cout << "Updating baseline on octave " << octave << " key " << key << endl;
+	
+    checkForAck(100);
+    
+    unsigned char commandPrepareRead[] = {ESCAPE_CHARACTER, kControlCharacterFrameBegin,
+        kFrameTypeSendI2CCommand, (unsigned char)octave, (unsigned char)key,
+        1 /* xmit */, 0 /* response */, 6 /* data offset */,
+        ESCAPE_CHARACTER, kControlCharacterFrameEnd};
+    
+	if(write(device_, (char*)commandPrepareRead, 10) < 0) {
+        if(verbose_ >= 1)
+            cout << "ERROR: unable to write prepareRead command.  errno = " << errno << endl;
+	}
+	tcdrain(device_);
+    
+	// Return value depends on ACK or NAK received
+	return checkForAck(100);
+}
+
 // Jump to the built-in bootloader of the TouchKeys device
 void TouchkeyDevice::jumpToBootloader() {
 	unsigned char command[] = {ESCAPE_CHARACTER, kControlCharacterFrameBegin, kFrameTypeEnterSelfProgramMode,
--- a/Source/TouchKeys/TouchkeyDevice.h	Wed Nov 27 00:37:43 2013 +0000
+++ b/Source/TouchKeys/TouchkeyDevice.h	Sat Dec 07 18:44:48 2013 +0000
@@ -259,6 +259,7 @@
 	bool setKeyCentroidScaler(int octave, int key, int value);
 	bool setKeyMinimumCentroidSize(int octave, int key, int value);
 	bool setKeyNoiseThreshold(int octave, int key, int value);
+    bool setKeyUpdateBaseline(int octave, int key);
     
     // Jump to device internal bootloader
     void jumpToBootloader();