Browse Source

actuate works with 3 intensities: 100%, 66%, 33%

videowall-pc-user 5 years ago
parent
commit
c70efe74f7

+ 11 - 3
SketchAssistant/SketchAssistantWPF/LocalArmbandInterface.cs

@@ -18,13 +18,21 @@ namespace SketchAssistantWPF
      CallingConvention = CallingConvention.Cdecl)]
         public static extern void startVibrate(int motorNumber, float intensity);
 
-        [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?stopVibrate@ArmbandInterface@@QAAXH@Z",
+        [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?stopVibrate@ArmbandInterface@@QAAXH@Z",                       
      CallingConvention = CallingConvention.Cdecl)]
         public static extern void stopVibration(int motorNumber);
 
-        [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?actuate@ArmbandInterface@@QAAXHNH@Z",
+        [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?actuate100@ArmbandInterface@@QAAXHMH@Z",
      CallingConvention = CallingConvention.Cdecl)]
-        public static extern void actuate(int motorNumber, double intensity, int duration);
+        public static extern void actuate100(int motorNumber, double intensity, int duration);
+
+        [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?actuate66@ArmbandInterface@@QAAXHMH@Z",
+     CallingConvention = CallingConvention.Cdecl)]
+        public static extern void actuate66(int motorNumber, double intensity, int duration);
+
+        [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?actuate33@ArmbandInterface@@QAAXHMH@Z",
+     CallingConvention = CallingConvention.Cdecl)]
+        public static extern void actuate33(int motorNumber, double intensity, int duration);
 
         [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?deleteArmband@ArmbandInterface@@QAAXXZ",
      CallingConvention = CallingConvention.Cdecl)]

+ 3 - 1
SketchAssistant/SketchAssistantWPF/MVP_Model.cs

@@ -361,7 +361,9 @@ namespace SketchAssistantWPF
                 currentLine.Add(currentCursorPosition);
             }
             //TODO remove
-            LocalArmbandInterface.startVibrate(0, 1);
+            //LocalArmbandInterface.startVibrate(0, 1);
+            LocalArmbandInterface.actuate33(0, 1.0, 1000);
+            Console.WriteLine("StartVibrate");
         }
 
         /// <summary>

+ 1 - 0
SketchAssistant/SketchAssistantWPF/MainWindow.xaml.cs

@@ -105,6 +105,7 @@ namespace SketchAssistantWPF
         private void Window_Closed(object sender, EventArgs e)
         {
             LocalArmbandInterface.deleteArmband();
+            Console.WriteLine("armband deleted 2");
         }
 
         /// <summary>

BIN
SketchAssistant/SketchAssistantWPF/StaticLibMotors.dll


+ 28 - 9
SketchAssistant/StaticLib1/ArmbandInterface.cpp

@@ -2,7 +2,7 @@
 extern "C" {
 #include "MotorHeader/BodyActuator.h"
 }
-#include <ctime>
+#include <time.h>
 #include <stdio.h>
 #include "ArmbandInterface.h"
 #include <stdlib.h>
@@ -10,7 +10,7 @@ extern "C" {
 typedef void(__cdecl *InitFunctionType)(BodyActuator*, BodyActuator_Type, char*, int);
 typedef void(__cdecl *StopFunctionType)(BodyActuator*, uint8_t);
 typedef void(__cdecl *StartFunctionType)(BodyActuator*, uint8_t, float);
-typedef void(__cdecl *ActuateFunctionType)(BodyActuator*, uint8_t, double, uint64_t);
+typedef void(__cdecl *ActuateFunctionType)(BodyActuator*, uint8_t, float, uint64_t);
 typedef void(__cdecl *DeleteFunctionType)(BodyActuator*);
 
 static InitFunctionType initFunctionHandle;
@@ -58,22 +58,37 @@ extern "C" {
 			}
 			//strcpy(port, "COM5");
 			setupMotors();
+			//actuate100(0, 1.0, 20);
 			//startVibrate(0, 1.0);
 			return -1;
 		}
 
 		DllExport void __cdecl ArmbandInterface::startVibrate(int tactor, float intensity) {
-			(startFunctionHandle)(armband, (uint8_t)tactor, intensity);
+			(startFunctionHandle)(armband, 0, 1.0);
+			printf("sollte gehen");
 		}
 
 		DllExport void __cdecl ArmbandInterface::stopVibrate(int tactor) {
 			(stopFunctionHandle)(armband, (uint8_t)tactor);
 		}
 		
-		DllExport void __cdecl ArmbandInterface::actuate(int tactor, double intensity, int duration) {
-			(actuateFunctionHandle)(armband, (uint8_t)tactor, intensity, (uint64_t)duration);
+		DllExport void __cdecl ArmbandInterface::actuate100(int tactor, float intensity, int duration) {
+			(actuateFunctionHandle)(armband, 0, 1.0, 20);
 		}
-	}
+
+		DllExport void __cdecl ArmbandInterface::actuate66(int tactor, float intensity, int duration) {
+		(actuateFunctionHandle)(armband, 0, 0.66, 20);
+		}
+
+		DllExport void __cdecl ArmbandInterface::actuate33(int tactor, float intensity, int duration) {
+		(actuateFunctionHandle)(armband, 0, 0.33, 20);
+		}
+	
+		DllExport void __cdecl ArmbandInterface::deleteArmband() {
+			(deleteFunctionHandle)(armband);
+			printf("armband deleted");
+		}
+}
 
  void ArmbandInterface::setupMotors() {
 	 char* port = (char*) "COM5";//malloc(7);
@@ -83,6 +98,10 @@ extern "C" {
 			printf("armband initialized");
 		}
 
- void ArmbandInterface::deleteArmband() {
-	 deleteFunctionHandle(armband);
- }
+ /*void ArmbandInterface::deleteArmband() {
+	 (deleteFunctionHandle)(armband);
+ }*/
+
+ /*void ArmbandInterface::actuate(int tactor, double intensity, int duration) {
+	 (actuateFunctionHandle)(armband, tactor, intensity, duration);
+}*/

+ 8 - 3
SketchAssistant/StaticLib1/ArmbandInterface.h

@@ -3,7 +3,7 @@
 extern "C" {
 #include "MotorHeader/BodyActuator.h"
 }
-#include <ctime>
+#include <time.h>
 #include <stdio.h>
 #define DllExport extern "C" __declspec( dllexport )
 
@@ -12,7 +12,9 @@ extern "C" {
 DllExport int setupArmband();
 DllExport void startVibrate(int tactor, float intensity);
 DllExport void stopVibrate(int tactor);
-DllExport void actuate(int tactor, double intensity, int duration);
+DllExport void actuate100(int tactor, float intensity, int duration);
+DllExport void actuate66(int tactor, float intensity, int duration);
+DllExport void actuate33(int tactor, float intensity, int duration);
 DllExport void deleteArmband();
 
 class ArmbandInterface
@@ -29,7 +31,10 @@ class ArmbandInterface
 		__declspec(dllexport) int __cdecl  setupArmband();
 		__declspec(dllexport) void __cdecl startVibrate(int tactor, float intensity);
 		__declspec(dllexport) void __cdecl stopVibrate(int tactor);
-		__declspec(dllexport) void __cdecl actuate(int tactor, double intensity, int duration);
+		__declspec(dllexport) void __cdecl actuate100(int tactor, float intensity, int duration);
+		__declspec(dllexport) void __cdecl actuate66(int tactor, float intensity, int duration);
+		__declspec(dllexport) void __cdecl actuate33(int tactor, float intensity, int duration);
 		__declspec(dllexport) void __cdecl deleteArmband();
 		void setupMotors();
+	//	void actuate(int tactor, double intensity, int duration);
 };