* adding first files (API draft)
[libnomaccel] / src / global_p.h
diff --git a/src/global_p.h b/src/global_p.h
new file mode 100644 (file)
index 0000000..4841845
--- /dev/null
@@ -0,0 +1,48 @@
+/* ============================================================================
+    Copyright (C) 2010 nomrasco
+    Nom Rasco <nomrasco@gmail.com>
+
+    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 <http://www.gnu.org/licenses/>.
+============================================================================ */
+#ifndef _NOM_GLOBAL_H_
+#define _NOM_GLOBAL_H_
+#include <math.h>
+
+#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