sensor

How to add a click method in sensor

此生再无相见时 提交于 2019-12-02 07:45:06
I have successfully, with a fellow programmers help to create the following code: import android.app.Activity; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.Toast; public class SensorTestActivity extends Activity implements SensorEventListener { private SensorManager sensorManager; private boolean color = false; private

Getting magnetic field values in global coordinates

半腔热情 提交于 2019-12-01 13:14:29
For an Android application, I need to get magnetic field measurements across the axis of global (world's) coordinate system. Here is how I'm going (guessing) to implement this. Please, correct me if necessary. Also, please, note that the question is about algorithmic part of the task, and not about Android APIs for sensors - I have an experience with the latter. First step is to obtain TYPE_MAGNETIC_FIELD sensor data ( M ) and TYPE_ACCELEROMETER sensor data ( G ). The second is supposed to be used according to Android's documentation, but I'm not sure if it shouldn't be TYPE_GRAVITY instead

Sensor reading in web worker

☆樱花仙子☆ 提交于 2019-12-01 11:09:10
It seems that we can not get sensor data in the web workers. I wonder the reason behind it. The use case is that I am thinking about getting geolocation data in the worker thread and only send the processed version to the main thread. For GPS, this post says it is not supported in the worker thread (no reason is given). And I double checked it, navigator.geolocation is not supported in web workers. For accelerator and gyroscope, we have DeviceOrientationEvent and DeviceMotionEvent. But we need to use them through the window object, which is not available to the worker thread. The same

Can't access the sensors in Android

╄→гoц情女王★ 提交于 2019-12-01 09:09:53
I am writing an compass application but can't access the sensors needed for some reason. I have implemented the SensorEventListener interface and register my sensors this way: sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); magnetometer = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); In my onSensorChange() method: public void onSensorChanged(SensorEvent event) { Toast t = Toast.makeText(this, "onSensorChanged", Toast.LENGTH_LONG); t.setGravity(Gravity.TOP, 0, 0); t.show(); if(event

how to save sensor data output into excel using python

情到浓时终转凉″ 提交于 2019-12-01 07:48:58
问题 I'm currently working with raspberry pi and using DHT11 to read temperature and humidity values every second. I have to save these values into a database in real time. here's my code that showing sensor data every second, I don't know how to save the data/result in excel. import RPi.GPIO as GPIO import dht11 import time import datetime import os # initialize GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.cleanup() instance = dht11.DHT11(pin=dht11_pin) while True: cnt += 1 if cnt

android SensorEventListener problem

ε祈祈猫儿з 提交于 2019-12-01 02:19:45
I am trying to create an application which reads data from digital compass. I tried to reuse the code from the book Professional Android Application Development but the IDE displayed a note The type SensorListener is deprecated I guess it is because the code from the book is written for the earlier SDK version so I tried to use SensorEventListener instead. Then when I tried to register the listener sensorManager.registerListener(sensorListener, SensorManager.SENSOR_ORIENTATION, SensorManager.SENSOR_DELAY_FASTEST); an error appeared: The method registerListener(SensorListener, int, int) in the

Android accelerometer full range

喜你入骨 提交于 2019-12-01 01:15:09
I am currently working with Android Sensor API and accelerometer data. Though the internal components should support high acceleration (even +-16g), I tried some recent smartphone and found that the maximum range of exposed data is usually +-2g (e.g. Nexus 5) and sometimes +-4g (e.g. Nexus 4). Is there any way to set the full scale of the sensor? (I didn't manage to find a public API for this) Alternatively, is there any flagship smartphone that support higher range from stock? (e.g. +-8g, +-16g). I'm facing the same problem as yours. DISCLAIMER: I just discovered what I'm writing, so I haven

Android: Which thread calls .onSensorChanged?

◇◆丶佛笑我妖孽 提交于 2019-11-30 20:47:36
I've read a few discussions about which thread calls various callback methods, for example those associated with Sensors. Most claim that the UI thread calls the callbacks - even when a separate worker thread is involved. Are we CERTAIN about that? Consider this scenario: A separate class implements Runnable and SensorListener. The UI thread (during onCreate) starts the runnable and then goes back to its other business. The now-independent worker thread, in its own class, then registers the SensorListener. Note that the UI thread never has any interaction with SensorManager nor SensorListener.

Android accelerometer full range

雨燕双飞 提交于 2019-11-30 20:33:51
问题 I am currently working with Android Sensor API and accelerometer data. Though the internal components should support high acceleration (even +-16g), I tried some recent smartphone and found that the maximum range of exposed data is usually +-2g (e.g. Nexus 5) and sometimes +-4g (e.g. Nexus 4). Is there any way to set the full scale of the sensor? (I didn't manage to find a public API for this) Alternatively, is there any flagship smartphone that support higher range from stock? (e.g. +-8g, +

Android SENSOR_DELAY_FASTEST isn't fast enough

南楼画角 提交于 2019-11-30 16:40:16
I'm using the sensors to balance a robot, but SENSOR_DELAY_FASTEST only provides a 10Hz sampling rate, which is simply not fast enough. Is there a way of sampling even faster? Is there a way of polling the sensors rather than waiting for a SensorEvent ? Is there a way of sampling even faster? SENSOR_DELAY_FASTEST is a 0ms delay. You cannot have negative time, at least as far as physicists have determined. Hence, there is no "faster" delay than SENSOR_DELAY_FASTEST . Use Traceview to determine where your time is being taken up. It is possible that it is your code that is slowing down your