dlopen libpython2.6.so
java.lang.NullPointerException
Traceback (most recent call last):
File "/mnt/sdcard/sl4a/scripts/pythonaccelerometer.py", line 74, in <module>
currMOT = getMOT(interval, duration)
File "/mnt/sdcard/sl4a/scripts/pythonaccelerometer.py", line 39, in getMOT
meanX, stdX = meanstdv(accX)
File "/mnt/sdcard/sl4a/scripts/pythonaccelerometer.py", line 11, in meanstdv
mean = mean / float(n)
ZeroDivisionError: float division
Any idea why I might be getting this. I'd love to play around with the script, but I am quite a novice w/ python. Any help would be greatly appreciated!
Hi, all,I have been looking through the list of variables exposed by Tasker, and I haven't seen a way yet to access the variable getters or values for a mobile device's accelerometer, gyro, and magnetometer. The magnetometer, at least, appears to set %MFIELD, which I guess is the magnitude of the 3 components of the sensor's outputs? I'd like to read each one.Does Tasker support this yet?I understand the consequences for battery life.Thank you!
> Hello, i'm trying to get accelerator values for my app.
I believe you can also get these values from the shell dumpsys
import android, time
droid = android.Android()
class Task():
SET_VARIABLE = 547
def new_task(self):
self.action_cnt = 0
self.extras = {'version_number': '1.0', 'task_name': 'task' + str(time.time()), 'task_priority': 10 }
def set_var(self, varname, value):
self.action_cnt += 1
self.extras['action' + str(self.action_cnt)] = {'action': self.SET_VARIABLE, 'arg:1': varname, 'arg:2': value, 'arg:3': False, 'arg:4': False, 'arg:5': False}
def run_task(self):
taskIntent = droid.makeIntent('net.dinglisch.android.tasker.ACTION_TASK', None, None, self.extras).result
droid.sendBroadcastIntent(taskIntent)
def set_var_now(self, varname, value):
self.new_task()
self.set_var(varname, value)
self.run_task()
droid.wakeLockAcquirePartial()
temps = 20
droid.startSensingTimed(1,500)
while temps > 0:
time.sleep(0.5)
x, y, z = droid.sensorsReadOrientation().result
temps = temps - 1
if x is not None:
break
droid.stopSensing()
t = Task()
t.new_task()
if x is not None:
t.set_var("%ORIENTATION_X", str(x))
t.set_var("%ORIENTATION_Y", str(y))
t.set_var("%ORIENTATION_Z", str(z))
t.set_var("%ORIENTATION", "Done")
t.run_task()
droid.wakeLockRelease()