sensor

Android Orientation Sensor Different for Different Devices?

扶醉桌前 提交于 2019-12-22 09:48:24
问题 I'm developing an Android game that uses the orientation sensor to get the rotation of the device (to roll a ball). I have two devices that I test apps on, one is a Samsung Infuse (phone) and the other is an Asus Eee Pad Transformer TF101 (tablet). The app runs in landscape on both devices. The problem is that on the Eee Pad, the orientation is measured with the device sideways (landscape mode) while the Infuse measures in upright (portrait) no matter what I do. This makes is so the ball

Android, Using the hardware compass

a 夏天 提交于 2019-12-22 07:58:40
问题 I can't find much information out there on Android's hardware compass. I keep trying to setup my criteria to force Android to use the hardware compass. Basically my problem is I want the bearing to update even while the device is stationary. From my understanding the GPS will only update your bearing when your moving. I'd like bearing to update regardless if you're moving or not. I've tried tricking the device in to thinking it's moving by setting the speed at a constant 10 but the bearing

Reading temperature through DHT11 using Android Things

对着背影说爱祢 提交于 2019-12-21 02:27:30
问题 I am using Raspberry pi3 and DHT11 sensor for temperature monitoring project. I have following pin positions VCC to pin no : 2 Ground to pin no : 6 Output to GPIO : BCM22 i.e pin no 15 Code that I have used: public class WeatherStationActivity extends Activity { private Handler mHandler = new Handler(); private TextView mTxtStatus; private PeripheralManagerService service = new PeripheralManagerService(); private Gpio tempGpio; private int i = 0; int[] dht11_dat = {0, 0, 0, 0, 0}; @Override

read temperature from DHT11, using pi4j

我们两清 提交于 2019-12-20 14:55:10
问题 I'm trying to read temperature data from a DHT11 temperature sensor, using pi4j. I followed the code written in c and python in this site: http://www.uugear.com/portfolio/dht11-h ... or-module/ But it's not working. when I test the instruction 'dht11Pin.getState()' it's always in HIGH state, never changing. Is there anything wrong in my code? Below is my code: import java.util.concurrent.TimeUnit; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com

Accessing Ambient Light Sensor on Microsoft Band

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 10:58:12
问题 There is an Ambient Light Sensor with Microsoft Band, and some apps in the Windows Store show the ALS value in Lux, But I can't find a way in the Band SDK to read the ALS Lux value. How can I access the ALS? 回答1: As mentioned, that sensor is not exposed by the public SDK - but it is apparently possible to get the information (and a heap of other stuff) by using the raw Bluetooth interface - the public API is a kind of wrapper around the raw Bluetooth protocol. So, if you're not afraid of

How to Build a Sensor Simulator for Android?

孤街醉人 提交于 2019-12-20 10:41:42
问题 I am building a application for the Android platform and I would like to use the accelerometer. Now, I have found a very nice application for sensor simulation (OpenIntents' SensorSimulator) but, for what I want to do, a would like to create my own sensor simulator application. I have not found information on how to do this (I do not know if disassembly the jar of the Simulator is correct) and, as I said, I would like to build a smaller and simpler version of a sensor simulator, more suitable

How to add a click method in sensor

落爺英雄遲暮 提交于 2019-12-20 07:12:07
问题 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

Android - how to run your sensor ( service, thread, activity )?

匆匆过客 提交于 2019-12-20 06:25:34
问题 I'm writing a simple tilting game. Make a ball roll over the screen in the direction you tilt your phone. So I downloaded an example on how to get the sensor data and that works fine (I use a rotation matrix to avoid the Euler angle problem). But then I tried to put it into a bigger app and I have some trouble getting it to work. My first idea was to run the tilt sensor in a separate thread but my class: public class TiltSensor extends Thread implements SensorEventListener is not working to

Sensor reading in web worker

╄→гoц情女王★ 提交于 2019-12-19 10:17:30
问题 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

Can't access the sensors in Android

柔情痞子 提交于 2019-12-19 09:26:09
问题 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