devicesrv_plat/tiltcompensation_api/inc/tiltcompensation.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Tilt compensation algorithm interface.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef TILTCOMPENSATION_H
       
    20 #define TILTCOMPENSATION_H
       
    21 
       
    22 #include <e32std.h>
       
    23 
       
    24 // CONSTANT DEFINITIONS
       
    25 
       
    26 typedef RArray<TReal> RParamsArray;
       
    27 
       
    28 /** 16bit integer vector */
       
    29 class TInt16vector
       
    30     {
       
    31 public:
       
    32     TInt16 iX;
       
    33     TInt16 iY;
       
    34     TInt16 iZ;
       
    35     };
       
    36 
       
    37 /**
       
    38 * Tilt compensation input.
       
    39 * Input contains current accelerometer and magnetometer vectors.
       
    40 *
       
    41 * @since S60 5.0
       
    42 */
       
    43 class TTiltCompensationInput
       
    44     {
       
    45 public:
       
    46     /** Normalized magnetic vector in 12Q4 format */
       
    47     TInt16vector iMagneticVector;
       
    48 
       
    49     /** Normalized acceleration vector 12Q4 format */
       
    50     TInt16vector iAccelerationVector;
       
    51     };
       
    52 
       
    53 /**
       
    54 * Tilt compensation output.
       
    55 * Output contains compensated value from accelerometer and magnetometer
       
    56 * data.
       
    57 *
       
    58 * @since S60 5.0
       
    59 */
       
    60 class TTiltCompensationOutput
       
    61     {
       
    62 public:
       
    63     /** Heading (deg). Compensated tilt angle. */
       
    64     TInt16 iTheta;
       
    65 
       
    66     /** Inclination (deg) */
       
    67     TInt16 iDelta;
       
    68 
       
    69     /** Roll (deg) */
       
    70     TInt16 iRoll;
       
    71 
       
    72     /** Pitch (deg) */
       
    73     TInt16 iPitch;
       
    74     };
       
    75 
       
    76 /** Name of the library providing tilt compensation algorithms. */
       
    77 _LIT( KTiltCompensationLib, "tiltcompensation.dll" );
       
    78 
       
    79 /** Function ordinal definitions for the dynamically loading the library. */
       
    80 enum TTiltCompensationFuncOrdinal
       
    81     {
       
    82     /**
       
    83     * Ordinal for compensation functions which takes no parameters other than
       
    84     * input vector, output vector and previous theta value.
       
    85     */
       
    86     ECompensateNoParams = 1,
       
    87 
       
    88     /**
       
    89     * Ordinal for compensation functions which takes additional parameters in
       
    90     * a parameter array.
       
    91     */
       
    92     ECompensateWithParams
       
    93     };
       
    94 
       
    95 /** Function prototype for compensation function in ordinal ECompensateNoParams. */
       
    96 typedef TInt ( *CompensateFuncNoParams )(
       
    97     const TTiltCompensationInput&,
       
    98     TTiltCompensationOutput&,
       
    99     const TInt16 );
       
   100 
       
   101 /** Function prototype for compensation function in ordinal ECompensateWithParams. */
       
   102 typedef TInt ( *CompensateFuncWithParams )(
       
   103     const TTiltCompensationInput&,
       
   104     TTiltCompensationOutput&,
       
   105     const TInt16,
       
   106     const RParamsArray& );
       
   107 
       
   108 /**
       
   109 * Creates a compensation from accelerometer vector and magnetometer vector.
       
   110 *
       
   111 * @lib tiltcompensation.lib
       
   112 * @since S60 5.0
       
   113 * @param aInput Input for the compensation.
       
   114 * @param aOutput Output from the compensation.
       
   115 * @param aPreviousTheta Theta value from the previous calculation.
       
   116 * @return KErrNone if no errors. KErrGeneral if compensation error.
       
   117 */
       
   118 IMPORT_C TInt Compensate(
       
   119     const TTiltCompensationInput& aInput,
       
   120     TTiltCompensationOutput& aOutput,
       
   121     const TInt16 aPreviousTheta );
       
   122 
       
   123 /**
       
   124 * Creates a compensation from accelerometer vector and magnetometer vector.
       
   125 *
       
   126 * @lib tiltcompensation.lib
       
   127 * @since S60 5.0
       
   128 * @param aInput Input for the compensation.
       
   129 * @param aOutput Output from the compensation.
       
   130 * @param aPreviousTheta Theta value from the previous calculation.
       
   131 * @param aParamsArray array is used in inputing parameters to the
       
   132 *        tiltcompensation library.
       
   133 * @return KErrNone if no errors. KErrGeneral if compensation error.
       
   134 */
       
   135 IMPORT_C TInt Compensate(
       
   136     const TTiltCompensationInput& aInput,
       
   137     TTiltCompensationOutput& aOutput,
       
   138     const TInt16 aPreviousTheta,
       
   139     const RParamsArray& aParamsArray );
       
   140 
       
   141 #endif
       
   142 
       
   143 // End of File