                                          ;; SensorManager/SENSOR_DELAY_UI
                                          SensorManager/SENSOR_DELAY_GAME))
                    listener))]
-    [(create "rotate" Sensor/TYPE_ROTATION_VECTOR rotate-stack)
-     (create "acc" Sensor/TYPE_LINEAR_ACCELERATION acc-stack)
+    [(create "acc" Sensor/TYPE_ACCELEROMETER acc-stack)
+     (create "rotate" Sensor/TYPE_ROTATION_VECTOR rotate-stack)
      ]))
 
 (def sensorManager (atom nil))

(set-error-handler! acc-stack err-handler-fn)
(set-error-handler! rotate-stack err-handler-fn)

(defn create-listeners [interval sensorManager]
  (let [create (fn [id sensor-type stack]
                 (let [listener (reify SensorEventListener
                                  (onAccuracyChanged [this sensor value] ())
                                  (onSensorChanged [this event]
                                    (apply #'replace-mean stack (seq (list (. event values))))))]
                   (send-every "Data" interval)
                   (.. sensorManager
                       (registerListener listener
                                         (.getDefaultSensor sensorManager sensor-type)

            (if (empty? xs) vals
                (map #(/ (+ %1 %2) 2.0) vals xs)))]
    (send-off stack mean)))
(defn send-every [id interval host port]
  (letfn [(task []            
            (let [client (osc-client host port)] (apply osc-send client (str "/" id) (concat [(now)] @acc-stack @rotate-stack)))
            ;; (apply osc-send client (str "/" id) (concat [(now)] [-0.74782043082746, 5.3259560276466, 8.299258563232] [0.21574099701674, -0.18960481184636, -0.74130249528735] ))
            ;; (apply osc-send client (str "/" id) [(now) -0.74782043082746, 5.3259560276466, 8.299258563232 0.21574099701674, -0.18960481184636, -0.74130249528735])
            ;; (let [client (osc-client host port)] (osc-send client (str "/" id) (now) -0.74782043082746, 5.3259560276466, 8.299258563232 0.21574099701674, -0.18960481184636, -0.74130249528735))
            (for [stack [acc-stack rotate-stack]] (send stack (fn [_] [])))
            )]    
    (every interval task my-pool)))

(defn push-vector [stack vals]
  (let [push (fn [xs xss]
