X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fglobal_p.h;fp=src%2Fglobal_p.h;h=4841845058978d326b4ee661eb44905e05bcf146;hb=718b114789f33651f138b33e7d39d80b028c98c6;hp=0000000000000000000000000000000000000000;hpb=d1be4beed531e6062d781c3adfd74cfea626a7c4;p=libnomaccel diff --git a/src/global_p.h b/src/global_p.h new file mode 100644 index 0000000..4841845 --- /dev/null +++ b/src/global_p.h @@ -0,0 +1,48 @@ +/* ============================================================================ + Copyright (C) 2010 nomrasco + Nom Rasco + + This file is part of libnomaccel. + + libnomaccel is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + libnomaccel 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with libnomaccel. If not, see . +============================================================================ */ +#ifndef _NOM_GLOBAL_H_ +#define _NOM_GLOBAL_H_ +#include + +#define YZ_TO_PITCH(y,z) atan2((y),(-z)) +#define XY_TO_ROLL(x,y) atan2((x),(-y)) +#define XYZ_TO_PITCH(x,y,z) YZ_TO_PITCH(y,z) +#define XYZ_TO_ROLL(x,y,z) XY_TO_ROLL(x,y) + +typedef struct _NomAccelProxy NomAccelProxy; +struct _NomAccelProxy { + value x; + value y; + value z; + angle pitch; + angle roll; +}; + +void _accel_proxy_init (); +void _accel_proxy_finit (); +void _accel_read_real_values (); +void _accel_recalculate_pitch (); +void _accel_recalculate_roll (); +#define _accel_recalculate_pitch_roll() _accel_recalculate_pitch(); _accel_recalculate_roll() + +const char* const _accel_device_file_name = "/sys/class/i2c-adapter/i2c-3/3-001d/coord"; +NomAccelProxy _accel_proxy = {0}; + +#endif