Browse Source

made armband vibrate

Vincenz Mechler 5 years ago
parent
commit
7cd0ca0a0c

+ 1 - 1
SketchAssistant/SketchAssistantWPF/LocalArmbandInterface.cs

@@ -54,7 +54,7 @@ namespace SketchAssistantWPF
         /// <param name="tactor">integer from 0 to 7 specifying the number of the tactor to actuate</param>
         /// <param name="intensity">intensity, ranging from 0.0 to 1.0 by default</param>
         /// <param name="duration">number of millisecons to actuate the tactor for</param>
-        [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?actuate@ArmbandInterface@@QAAXXZ",
+        [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?actuate100@ArmbandInterface@@QAAXHNH@Z",
      CallingConvention = CallingConvention.Cdecl)]
         public static extern void Actuate(int tactor, double intensity, int duration);
 

+ 2 - 5
SketchAssistant/SketchAssistantWPF/MVP_Model.cs

@@ -259,7 +259,6 @@ namespace SketchAssistantWPF
             {
                 PathTraveled = 0;
                 LocalArmbandInterface.Actuate(0, TACTILE_SURFACE_FEEDBACK_INTENSITY, TACTILE_SURFACE_FEEDBACK_DURATION);
-                //TODO: Activate vibration here
             }
         }
 
@@ -539,10 +538,6 @@ namespace SketchAssistantWPF
                     currentLine.Add(currentCursorPosition);
                 }
             }
-            //TODO remove
-            //LocalArmbandInterface.startVibrate(0, 1);
-            LocalArmbandInterface.Actuate(0, 1.0, 20);
-            Console.WriteLine("Vibrate motor 0 for 20ms");
         }
 
         /// <summary>
@@ -636,6 +631,8 @@ namespace SketchAssistantWPF
                     {
                         wristband.PushBackward();
                     }
+
+                    CheckPathTraveled();
                 }
             }
             else if( !optiTrackInUse && inDrawingMode)

+ 22 - 6
SketchAssistant/StaticLib1/ArmbandInterface.cpp

@@ -23,15 +23,15 @@ typedef void(__cdecl *ClearFunctionType)(BodyActuator*);
 //type of the BodyActuator_delete function
 typedef void(__cdecl *DeleteFunctionType)(BodyActuator*);
 //type of the BodyActuator_actuate function
-typedef void(__cdecl *ActuateFunctionType)(BodyActuator*, uint8_t, double, uint64_t);
+typedef void(__cdecl *ActuateFunctionType)(BodyActuator*, uint8_t, float, uint64_t);
 //type of the BodyActuator_startActuation function
-typedef void(__cdecl *StartFunctionType)(BodyActuator*, uint8_t, double);
+typedef void(__cdecl *StartFunctionType)(BodyActuator*, uint8_t, float);
 //type of the BodyActuator_stopActuation function
 typedef void(__cdecl *StopFunctionType)(BodyActuator*, uint8_t);
 //type of the BodyActuator_setFrequency function
 typedef void(__cdecl *SetFrequencyFunctionType)(BodyActuator*, uint8_t, uint16_t);
 //type of the BodyActuator_setIntensityRange function
-typedef void(__cdecl *SetIntensityRangeFunctionType)(BodyActuator*, uint8_t, double, double);
+typedef void(__cdecl *SetIntensityRangeFunctionType)(BodyActuator*, uint8_t, float, float);
 
 /*
 static variables to hold the dynamically linked function handles, one per linked function in the BodyActuator dll
@@ -161,11 +161,27 @@ extern "C" {
 	}
 	
 	/*
-	make the specified tactor (number from 0 to 7) actuate at a specified intensity (default: between 0.0 and 1.0, but range may be set using the setIntensityRange function) for the specified duration (number of milliseconds) ,or until it is stopped
+	make the specified tactor (number from 0 to 7) actuate at intensity 1.0 (default: between 0.0 and 1.0, but range may be set using the setIntensityRange function) for the specified duration (number of milliseconds) ,or until it is stopped
 	provides access to the DLLs BodyActuator_actuate method and handles type conversion to C types required by the DLL which are not available in C#
 	*/
-	DllExport void __cdecl ArmbandInterface::actuate(int tactor, double intensity, int duration) {
-		(actuateFunctionHandle)(armband, tactor, intensity, duration);
+	DllExport void __cdecl ArmbandInterface::actuate100(int tactor, double intensity, int duration) {
+		(actuateFunctionHandle)(armband, tactor, 1.0, duration);
+	}
+
+	/*
+	make the specified tactor (number from 0 to 7) actuate at a intensity 0.66 (default: between 0.0 and 1.0, but range may be set using the setIntensityRange function) for the specified duration (number of milliseconds) ,or until it is stopped
+	provides access to the DLLs BodyActuator_actuate method and handles type conversion to C types required by the DLL which are not available in C#
+	*/
+	DllExport void __cdecl ArmbandInterface::actuate66(int tactor, int duration) {
+		(actuateFunctionHandle)(armband, tactor, 0.66, duration);
+	}
+
+	/*
+	make the specified tactor (number from 0 to 7) actuate at intensity 0.33 (default: between 0.0 and 1.0, but range may be set using the setIntensityRange function) for the specified duration (number of milliseconds) ,or until it is stopped
+	provides access to the DLLs BodyActuator_actuate method and handles type conversion to C types required by the DLL which are not available in C#
+	*/
+	DllExport void __cdecl ArmbandInterface::actuate33(int tactor, int duration) {
+		(actuateFunctionHandle)(armband, tactor, 0.33, duration);
 	}
 
 	/*

+ 16 - 8
SketchAssistant/StaticLib1/ArmbandInterface.h

@@ -13,15 +13,13 @@ Basically, this class acts as a single static BodyActuator instance towards outs
 (side note: the use of the terms 'function' and 'method' might be a bit messy here...)
 */
 
-/*
 DllExport int setupArmband();
 DllExport void startVibrate(int tactor, float intensity);
 DllExport void stopVibrate(int tactor);
-DllExport void actuate100();
-DllExport void actuate66();
-DllExport void actuate33();
+DllExport void actuate100(int tactor, double intensity, int duration);
+DllExport void actuate66(int tactor, int duration);
+DllExport void actuate33(int tactor, int duration);
 DllExport void deleteArmband();
-*/
 
 class ArmbandInterface
 {
@@ -52,10 +50,20 @@ class ArmbandInterface
 		*/
 		__declspec(dllexport) void __cdecl stopVibrate(int tactor);
 		/*
-		make the specified tactor (number from 0 to 7) actuate at a specified intensity (default: between 0.0 and 1.0, but range may be set using the setIntensityRange function) for the specified duration (number of milliseconds) ,or until it is stopped
+		make the specified tactor (number from 0 to 7) actuate at intensity 1.0 (default: between 0.0 and 1.0, but range may be set using the setIntensityRange function) for the specified duration (number of milliseconds) ,or until it is stopped
+		provides access to the DLLs BodyActuator_actuate method and handles type conversion to C types required by the DLL which are not available in C#
+		*/
+		__declspec(dllexport) void __cdecl actuate100(int tactor, double intensity, int duration);
+		/*
+		make the specified tactor (number from 0 to 7) actuate at intensity 0.66 (default: between 0.0 and 1.0, but range may be set using the setIntensityRange function) for the specified duration (number of milliseconds) ,or until it is stopped
+		provides access to the DLLs BodyActuator_actuate method and handles type conversion to C types required by the DLL which are not available in C#
+		*/
+		__declspec(dllexport) void __cdecl actuate66(int tactor, int duration);
+		/*
+		make the specified tactor (number from 0 to 7) actuate at intensity 0.33 (default: between 0.0 and 1.0, but range may be set using the setIntensityRange function) for the specified duration (number of milliseconds) ,or until it is stopped
 		provides access to the DLLs BodyActuator_actuate method and handles type conversion to C types required by the DLL which are not available in C#
 		*/
-		__declspec(dllexport) void __cdecl actuate(int tactor, double intensity, int duration);
+		__declspec(dllexport) void __cdecl actuate33(int tactor, int duration);
 		/*
 		sets the frequency of the specified tactor to a new value (unit unknown, possibly Hz...)
 		*/
@@ -64,7 +72,7 @@ class ArmbandInterface
 		sets a new intensity range for a single actuator to make different actuators react differently even when receiving an actuation command with the same intensity (e.g. to to compensate differing tactile sensitivity on different parts of the human body)
 		*/
 		__declspec(dllexport) void __cdecl setIntensityRange(int tactor, double minIntensity, double maxIntensity);
-	private:
+	//private:
 		/*
 		internal method to initialize the BodyActuator object (and handle the memory allocation involved)
 		*/