Jump to content

Search the Community

Showing results for tags 'Accelerometer'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Halo wounderfull Autoit Forum I have gotten a new laptop that i am going to have the next few year and i would like to be able to get data from all its sensors like Location & Movement (GPS, Accelometer) I have gotten the GPS to work I have found the code for the Accelorometer but its in C++ (and i have no experiance with .dll calls and c++) Could some on PLEASE help me / point me in the right direction ass i just cant get it to work in autoit / know where to start here is the autoit code i have tried so far but keep getting @error 1 = unable to use the DLL file, ;/* * LoadSensorDLL.cpp * * Created on: Feb 11, 2012 * Author: CONG NGUYEN * */ #include <iostream> #include <windows.h> #include <stdio.h> #include <math.h> struct AccelData { int status; short x; //raw data short y; //raw data short xx; //avg. of 40ms short yy; //avg. of 40ms char temp; //raw value short x0; //used for auto-center short y0; //used for auto-center }; using namespace std; typedef void * (__stdcall *ShockproofGetAccelerometerData)(AccelData* accData); //function prototypes void calibrate(void); void calibrateX(); void calibrateY(); short getAccelX(); short getAccelY(); double getRotationRadiansX(); double getRotationDegreesX(); double getRotationRadiansY(); double getRotationDegreesY(); //declare constants const double PI = 3.141592; //declare global variables HINSTANCE hinstDLL; AccelData accData = {0,0,0,0,0,0,0,0}; ShockproofGetAccelerometerData pfnGetData; bool isSupported; //declare global variables used for calibration and movement short x_hor = 0; short y_hor = 0; short x_max = 0; short y_max = 0; double x_norm = 0.0; double y_norm = 0.0; double test = 0.0; int main(void) { int loop = 1; hinstDLL = LoadLibrary(L"Sensor.dll"); if(hinstDLL == 0) { hinstDLL = LoadLibrary(L"sensor.dll"); } if(hinstDLL == 0) { isSupported = false; } else { isSupported = true; pfnGetData = (ShockproofGetAccelerometerData) GetProcAddress((HINSTANCE) hinstDLL, "ShockproofGetAccelerometerData"); } calibrate(); calibrateX(); calibrateY(); cout << x_hor << ", " << y_hor << endl; cout << x_max << ", " << y_max << endl; cout << endl; cout << "Calibration completed.\n"; getchar(); cout << "TIlt 45 degrees. Press any keys to confirm.\n"; getchar(); cout << getRotationDegreesY(); //end program getchar(); FreeLibrary(hinstDLL); return 0; } short getAccelX() { pfnGetData(&accData); return accData.x; } short getAccelY() { pfnGetData(&accData); return accData.y; } void calibrate(void) { cout << "Lay Thinkpad onto a flat and horizontal ground.\n"; cout << "Press any key to continue.\n"; if(getchar() == '\n') { x_hor = getAccelX(); y_hor = getAccelY(); } } void calibrateX() { cout << "Pitch your Thinkpad a bit backwards.\n"; cout << "Press any key, then rotate your Thinkpad back to normal position.\n"; getchar(); while(getAccelX() != x_hor) { if(getAccelX() > x_max) { x_max = getAccelX(); } } } void calibrateY() { cout << "Roll your Thinkpad to the right a bit.\n"; cout << "Press any key, then rotate your Thinkpad back to normal position.\n"; getchar(); while(getAccelY() != y_hor) { if(getAccelY() > y_max) { y_max = getAccelY(); } } } double getRotationRadiansX() { x_norm = (double)((double)getAccelX() - (double)x_hor) /((double)x_max - (double)x_hor); if(x_norm > 1) { x_norm = 1/x_norm; } return acos(x_norm); } double getRotationDegreesX() { return getRotationRadiansX() * 180 / PI; } double getRotationRadiansY() { y_norm = (double)((double)getAccelY() - (double)y_hor) /((double)y_max - (double)y_hor); if(y_norm > 1) { y_norm = 1/y_norm; } return acos(y_norm); } double getRotationDegreesY() { return getRotationRadiansY() * 180 / PI; } #cs ---------------------------------------------------------------------------- Author: Me Script Function: Get Data from the Different Sensors in the Computer 1. Accelerometer / Gyroscope 2. GPS / Location 3. ? 4. ? ----------SysWOW64---------------- Sensor.dll SensorsApi.dll SensorCpl.dll ----------------------------------- ----------System32--------------- Sensor64.dll SensorsApi.dll SensorsClassExtension.dll SensorCpl.dll ---------------------------------- ================================== How To / Help / Code Convert ========================= http://flashandrc.wordpress.com/2012/02/12/pulling-data-from-thinkpad-aps-sensor-using-c/ ; C++ http://www.xtremevbtalk.com/showthread.php?t=284179 ; Vbs http://www.autoitscript.com/forum/topic/71001-problems-with-dllcall/?hl=sensor#entry519806 ; Autoit3 ========================================================================================= ================================== Credits (UDF/Code Lines/Code Samples) ================ Autoit3 Forum and all its Users whom i have borrowed a line of code or sample script Thanks to all that have helped as well ========================================================================================= #ce ---------------------------------------------------------------------------- #include <Array.au3> #include <WinApi.au3> #region === Global Variables === Global $SensorWOW #endregion ===================== #region ============================================= SysWOW64 Dll ================================================================ $SensorWOW = DllOpen(@WindowsDir&"\SysWOW64\Sensor.dll") If $SensorWOW = -1 Then MsgBox(16,"Error","Dll File didn't open") #cs ============================================= Functions in Sensor64.dll =================================================== ShockproofCallSMAPIBIOS 0x000000018000230c 0x0000230c 1 (0x1) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofControl 0x0000000180001750 0x00001750 2 (0x2) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofEnableDisableSnooze 0x0000000180002230 0x00002230 3 (0x3) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetAccelerometerData 0x0000000180001da4 0x00001da4 4 (0x4) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetAccelerometerDataEx 0x0000000180001e78 0x00001e78 5 (0x5) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetAccelerometerMutex 0x0000000180001c78 0x00001c78 6 (0x6) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetAutoDisable 0x00000001800016c0 0x000016c0 7 (0x7) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetPenAbility 0x00000001800025e8 0x000025e8 8 (0x8) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetPenDelayTime 0x00000001800023e4 0x000023e4 9 (0x9) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetPenFeature 0x00000001800024e0 0x000024e0 10 (0xa) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetShockStatus 0x0000000180001b4c 0x00001b4c 11 (0xb) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetSlaveCPUinfo 0x0000000180001be4 0x00001be4 12 (0xc) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetUnloadCnt 0x0000000180001abc 0x00001abc 13 (0xd) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetVersion 0x0000000180001800 0x00001800 14 (0xe) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofInformPMevent 0x0000000180001f4c 0x00001f4c 15 (0xf) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofInvokeSnooze 0x00000001800020c8 0x000020c8 16 (0x10) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofManualSensitivitySetting 0x0000000180001fc8 0x00001fc8 17 (0x11) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofReleaseAccelerometerMutex 0x0000000180001d24 0x00001d24 18 (0x12) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofSetAutoDisable 0x0000000180001640 0x00001640 19 (0x13) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofSetPenDelayTime 0x0000000180002470 0x00002470 20 (0x14) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofSetPenFeature 0x0000000180002574 0x00002574 21 (0x15) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofSnoozeSetting 0x0000000180002130 0x00002130 22 (0x16) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofTaskComplete 0x0000000180001fbc 0x00001fbc 23 (0x17) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function #ce ======================================================================================================================== ;~ $SensorsApiWOW = DllOpen(@WindowsDir&"\SysWOW64\SensorsApi.dll") #cs ============================================= Functions in SensorsApi.dll ================================================= ;~ DllCanUnloadNow 0x07658f96 0x00008f96 1 (0x1) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function ;~ DllGetClassObject 0x07659bbd 0x00009bbd 2 (0x2) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function ;~ DllRegisterServer 0x07659ddb 0x00009ddb 3 (0x3) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function ;~ DllUnregisterServer 0x07659ea6 0x00009ea6 4 (0x4) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function ;~ SensorPermissionsHandler 0x07666a4c 0x00016a4c 5 (0x5) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function ;~ SensorPermissionsHandlerA 0x07666a4c 0x00016a4c 6 (0x6) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function ;~ SensorPermissionsHandlerW 0x0766681c 0x0001681c 7 (0x7) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function #ce ======================================================================================================================== #endregion ======================================================================================================================== $AccData = DllStructCreate("int;short;short;short;char;short;short") ;~ $res = DllCall("sensor.dll","none","ptr",DllStructGetPtr($AccData)) ;~ For $i=1 To 23 ;~ $status = DllStructGetData($AccData,$i) ;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $status = ' & $status & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ;~ Next $adll = DllCall($SensorWOW, "none", "ShockproofGetAccelerometerData", $AccData,"handle") If Not @error Then MsgBox(0, "Return", $adll[1] & " " & $adll[1] & " Length " & StringLen($adll[1])) Else MsgBox(0, "Error", @error) EndIf Thanks in advanced Sensor.7z
×
×
  • Create New...