* adding first files (API draft)
[libnomaccel] / src / accel_p.c
diff --git a/src/accel_p.c b/src/accel_p.c
new file mode 100644 (file)
index 0000000..467757e
--- /dev/null
@@ -0,0 +1,82 @@
+/* ============================================================================
+    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/>.
+============================================================================ */
+#include "../include/accel.h"
+#include "global_p.h"
+
+value
+nom_accel_get_x () {
+       _accel_read_real_values ();
+       return _accel_proxy.x;
+}
+
+value
+nom_accel_get_y () {
+       _accel_read_real_values ();
+       return _accel_proxy.y;
+}
+
+value
+nom_accel_get_z () {
+       _accel_read_real_values ();
+       return _accel_proxy.z;
+}
+
+void
+nom_accel_get_xyz (value* x, value* y, value* z) {
+       _accel_read_real_values ();
+       *x = _accel_proxy.x;
+       *y = _accel_proxy.y;
+       *z = _accel_proxy.z;
+}
+
+angle
+nom_accel_get_pitch () {
+       _accel_read_real_values ();
+       _accel_recalculate_pitch ();
+       return _accel_proxy.pitch;
+}
+
+angle
+nom_accel_get_roll  () {
+       _accel_read_real_values ();
+       _accel_recalculate_roll ();
+       return _accel_proxy.roll;
+}
+
+void
+nom_accel_get_pitch_roll (angle* pitch, angle* roll) {
+       _accel_read_real_values ();
+       _accel_recalculate_pitch_roll ();
+       *pitch = _accel_proxy.pitch;
+        *roll = _accel_proxy.roll;
+}
+
+void
+nom_accel_get_all (value* x, value* y, value* z,
+                   angle* pitch, angle* roll)
+{
+       _accel_read_real_values ();
+       _accel_recalculate_pitch_roll ();
+       *pitch = _accel_proxy.pitch;
+        *roll = _accel_proxy.roll;
+           *x = _accel_proxy.x;
+           *y = _accel_proxy.y;
+           *z = _accel_proxy.z;
+}
\ No newline at end of file