The code below is released under version 2 of the GPL.
'VB.NET Class for utilizing the IBM Active Protection System Accelerometer
'Copyright (C) 2008 Brad Isbell <brad@musatcha.com>
'See http://www.musatcha.com for more information.
'
'This program is free software; you can redistribute it and/or modify
'it under the terms of the GNU General Public License Version 2
'as published by the Free Software Foundation
'
'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
'GNU General Public License for more details.
'
'You should have received a copy of the GNU General Public License
'along with this program; if not, write to the Free Software
'Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Imports System.Runtime.InteropServices
Public Class IBMAPS
Dim AccX As Short
Dim AccY As Short
Dim AccStatus As Integer
<DllImport("sensor.dll")> _
Public Shared Sub ShockproofGetAccelerometerData(ByRef accData As AccData)
End Sub
<StructLayout(LayoutKind.Sequential)> _
Public Structure AccData
Friend status As Integer
Friend x As Short
Friend y As Short
'The following variables hold unknown data, but are required to avoid pointer issues
Private x1 As Short
Private y1 As Short
Private x2 As Short
Private y2 As Short
Private x3 As Short
Private y3 As Short
Private x4 As Short
Private y4 As Short
Private x5 As Short
Private y5 As Short
Private x6 As Short
Private y6 As Short
Private x7 As Short
Private y7 As Short
Private x8 As Short
Private y8 As Short
Private x9 As Short
Private y9 As Short
Private x10 As Short
Private y10 As Short
Private x11 As Short
Private y11 As Short
Private x12 As Short
Private y12 As Short
Private x13 As Short
Private y13 As Short
Private unknown0 As Short
Private unknown1 As Short
End Structure
Public Sub ReadSample()
Dim FreshData As New AccData
Try
ShockproofGetAccelerometerData(FreshData)
Catch
End Try
AccX = FreshData.x
AccY = FreshData.y
AccStatus = FreshData.status
End Sub
Public ReadOnly Property Status() As Integer
Get
Return AccStatus
End Get
End Property
Public ReadOnly Property X() As Short
Get
Return AccX
End Get
End Property
Public ReadOnly Property Y() As Short
Get
Return AccY
End Get
End Property
End Class