Ergebnis 1 bis 13 von 13
-
Bin neu hier
- 07.11.2009, 13:35
- #1
Hallo,
ich habe folgende Problemstellung, ich moechte mir eine Bluetooth Fernbedienung Programmieren die mittels Bewegung und einigen wenigen Tasten funktioniert.
Das eigentliche Problem ist nun der G-Sensor, um genauer zu sein die Daten des Sensors zu lesen, das Auswerten sollte eigentlich kein Problem sein, ist hier evt. jemand der Erfahrung hat oder einen Link empfehlen kann, SDK etc.? Bin dankbar fuer jegliche Hilfe. Programmiersprache sollte C++ sein, ungern aber moeglich waere auch C#.
Vielen Dank schonmal im Vorraus.
-
Bin neu hier
- 07.11.2009, 18:38
- #2
Guck mal hier:
http://blog.enterprisemobile.com/200...-managed-code/
Damit hab ich mal was programmiert (Visual Studio, .NET CF, C#), ging super...
-
- 07.11.2009, 18:43
- #3
Ich habe den Thread verschoben, hier würdest du mehr Antworten bekommen.
mfg
timsah
-
- 08.11.2009, 01:24
- #4
http://scottandmichelle.net/scott/co...html?entry=784 (Englisch) ist ein Beispielprojekt in C++.
-
Bin neu hier
- 15.11.2009, 19:00
- #5
Vielen dank fuer die schnelle Hilfe, hab gefunden wonach ich gesucht hab.
Denke es werden jetzt einige lange Naechte folgen
-
- 16.11.2009, 09:45
- #6
Hallo,
ich versuche ebenfalls den G-Sensor auf einem HTC HD zu programmieren, finde bisher aber nichts dazu im .NET Compact Framework. Die bereits geposteten Links habe ich bereits gefunden, diese beziehen sich aber nur auf C#. Hat das jemand schon in VB realisiert?
-
Bin neu hier
- 16.11.2009, 10:12
- #7
Bis auf eine leicht andere Syntax sollte das genauso funktionieren!
-
- 16.11.2009, 10:34
- #8
Leicht andere Syntax? Ich weiß nicht mal, wie ich mit dem C# Code anfangen muss
-
entwickelt Apps
- 16.11.2009, 21:20
- #9
Das C# Projekt gibt's hier (unter source code). Das enthält Code für die verschiedenen Sensoren für HTC und Omnia.
Da ich nur den G-Sensor für HTC Geräte brauche, habe ich die folgende Klasse erstellt:
Code:using System; using System.Runtime.InteropServices; namespace GSensorTest { public class GSensor : IDisposable { public struct SensorData { public short TiltX; // From -1000 to 1000, 0 is flat public short TiltY; // From -1000 to 1000, 0 is flat public short TiltZ; // From -1000 to 1000, 0 = Straight up, -1000 = Flat, 1000 = Upside down public short Unknown1; public int AngleY; // From 0 to 359 degrees public int AngleX; // From 0 to 359 degrees public int Unknown2; }; [DllImport("HTCSensorSDK")] extern static IntPtr HTCSensorGetDataOutput(IntPtr handle, out SensorData sensorData); [DllImport("HTCSensorSDK")] extern static IntPtr HTCSensorOpen(int sensor); [DllImport("HTCSensorSDK")] extern static void HTCSensorClose(IntPtr handle); [DllImport("coredll", SetLastError = true)] extern static IntPtr CreateEvent(IntPtr eventAttributes, bool manualReset, bool intialState, string name); [DllImport("coredll", SetLastError = true)] extern static bool EventModify(IntPtr handle, uint func); [DllImport("coredll")] extern static bool CloseHandle(IntPtr handle); private IntPtr _handle; public GSensor() { _handle = HTCSensorOpen(1); IntPtr hEvent = CreateEvent(IntPtr.Zero, true, false, "HTC_GSENSOR_SERVICESTART"); EventModify(hEvent, 3); CloseHandle(hEvent); } public void GetSensorData(ref SensorData data) { HTCSensorGetDataOutput(_handle, out data); } #region IDisposable Members public void Dispose() { if (_handle != IntPtr.Zero) { HTCSensorClose(_handle); _handle = IntPtr.Zero; } IntPtr hEvent = CreateEvent(IntPtr.Zero, true, false, "HTC_GSENSOR_SERVICESTOP"); EventModify(hEvent, 3); CloseHandle(hEvent); } #endregion } }
Mit folgendem Resultat:
Code:Imports System Imports System.Runtime.InteropServices Namespace GSensorTest Public Class GSensor Implements IDisposable Public Structure SensorData Public TiltX As Short ' From -1000 to 1000, 0 is flat Public TiltY As Short ' From -1000 to 1000, 0 is flat Public TiltZ As Short ' From -1000 to 1000, 0 = Straight up, -1000 = Flat, 1000 = Upside down Public Unknown1 As Short Public AngleY As Integer ' From 0 to 359 degrees Public AngleX As Integer ' From 0 to 359 degrees Public Unknown2 As Integer End Structure <DllImport("HTCSensorSDK")> _ Private Shared Function HTCSensorGetDataOutput(ByVal handle As IntPtr, ByRef sensorData As SensorData) As IntPtr End Function <DllImport("HTCSensorSDK")> _ Private Shared Function HTCSensorOpen(ByVal sensor As Integer) As IntPtr End Function <DllImport("HTCSensorSDK")> _ Private Shared Sub HTCSensorClose(ByVal handle As IntPtr) End Sub <DllImport("coredll", SetLastError := True)> _ Private Shared Function CreateEvent(ByVal eventAttributes As IntPtr, ByVal manualReset As Boolean, ByVal intialState As Boolean, ByVal name As String) As IntPtr End Function <DllImport("coredll", SetLastError := True)> _ Private Shared Function EventModify(ByVal handle As IntPtr, ByVal func As UInteger) As Boolean End Function <DllImport("coredll")> _ Private Shared Function CloseHandle(ByVal handle As IntPtr) As Boolean End Function Private _handle As IntPtr Public Sub New() _handle = HTCSensorOpen(1) Dim hEvent As IntPtr = CreateEvent(IntPtr.Zero, True, False, "HTC_GSENSOR_SERVICESTART") EventModify(hEvent, 3) CloseHandle(hEvent) End Sub Public Sub GetSensorData(ByRef data As SensorData) HTCSensorGetDataOutput(_handle, data) End Sub #Region "IDisposable Members" Public Sub Dispose() If _handle <> IntPtr.Zero Then HTCSensorClose(_handle) _handle = IntPtr.Zero End If Dim hEvent As IntPtr = CreateEvent(IntPtr.Zero, True, False, "HTC_GSENSOR_SERVICESTOP") EventModify(hEvent, 3) CloseHandle(hEvent) End Sub #End Region End Class End Namespace
Code:private GSensor _gSensor; ... // init if (File.Exists(@"\Windows\HTCSensorSDK.dll")) { _gSensor = new GSensor(); } ... // get sensor data if (_gSensor != null) { GSensor.SensorData sensorData = new GSensor.SensorData(); _gSensor.GetSensorData(ref sensorData); } ... // close application if (_gSensor != null) { _gSensor.Dispose(); }
-
- 17.11.2009, 10:41
- #10
Wow, cool! Ich werde es damit mal ausprobieren! Vielen Dank!
-
- 18.11.2009, 20:23
- #11
So, habe es nun endlich ausprobieren können und es funktioniert
Vielen Dank nochmal
-
Unregistriert Gast
Hallo,
könntet Ihr wohl ein Beispiel zum Download bereitstellen? Irgendwie bekomme ich das nicht hin.
Danke im Voraus!
Gruß,
T.u.b.e.
-
- 09.02.2010, 21:47
- #13
Das ist die GSensor-API-Klasse in VB.NET, so wie ich sie gerade verwende:
Code:Imports System Imports System.Runtime.InteropServices Public Class GSensor Implements IDisposable Public Structure SensorData Public TiltX As Short ' From -1000 to 1000, 0 is flat Public TiltY As Short ' From -1000 to 1000, 0 is flat Public TiltZ As Short ' From -1000 to 1000, 0 = Straight up, -1000 = Flat, 1000 = Upside down Public Unknown1 As Short Public AngleY As Integer ' From 0 to 359 degrees Public AngleX As Integer ' From 0 to 359 degrees Public Unknown2 As Integer End Structure <DllImport("HTCSensorSDK")> _ Private Shared Function HTCSensorGetDataOutput(ByVal handle As IntPtr, ByRef sensorData As SensorData) As IntPtr End Function <DllImport("HTCSensorSDK")> _ Private Shared Function HTCSensorOpen(ByVal sensor As Integer) As IntPtr End Function <DllImport("HTCSensorSDK")> _ Private Shared Sub HTCSensorClose(ByVal handle As IntPtr) End Sub <DllImport("coredll", SetLastError:=True)> _ Private Shared Function CreateEvent(ByVal eventAttributes As IntPtr, ByVal manualReset As Boolean, ByVal intialState As Boolean, ByVal name As String) As IntPtr End Function <DllImport("coredll", SetLastError:=True)> _ Private Shared Function EventModify(ByVal handle As IntPtr, ByVal func As UInteger) As Boolean End Function <DllImport("coredll")> _ Private Shared Function CloseHandle(ByVal handle As IntPtr) As Boolean End Function Private _handle As IntPtr Public Sub New() Dim hEvent As IntPtr Try _handle = HTCSensorOpen(1) hEvent = CreateEvent(IntPtr.Zero, True, False, "HTC_GSENSOR_SERVICESTART") EventModify(hEvent, 3) CloseHandle(hEvent) Catch MsgBox("This is not a HTC Device") End Try End Sub Public Sub GetSensorData(ByRef data As SensorData) If (_handle <> IntPtr.Zero) Then HTCSensorGetDataOutput(_handle, data) End If End Sub Public Sub Dispose() Implements System.IDisposable.Dispose Dim hEvent As IntPtr If (_handle <> IntPtr.Zero) Then HTCSensorClose(_handle) _handle = IntPtr.Zero End If hEvent = CreateEvent(IntPtr.Zero, True, False, "HTC_GSENSOR_SERVICESTOP") EventModify(hEvent, 3) CloseHandle(hEvent) End Sub End Class
Ähnliche Themen
-
Einstieg in die Mobile Programmierung
Von Ha_Pe im Forum ProgrammierenAntworten: 5Letzter Beitrag: 11.04.2008, 13:46 -
GapiDraw Programmierung
Von rainfle im Forum ProgrammierenAntworten: 0Letzter Beitrag: 02.02.2006, 08:59 -
SPV C-500 cmos-Sensor, SDA ccd-Sensor?
Von im Forum PlaudereckeAntworten: 1Letzter Beitrag: 12.10.2004, 19:41 -
PocketPC2003 Programmierung in C++
Von Rico im Forum ProgrammierenAntworten: 2Letzter Beitrag: 21.11.2003, 22:34 -
Programmierung am Pocket PC
Von dekana im Forum PlaudereckeAntworten: 1Letzter Beitrag: 29.09.2002, 14:30
Pixel 10 Serie mit Problemen:...