Re: [android-developers] Sensor events are received, but not working.
FWIW, the orientation sensor is deprecated. While I yanked the sensor coverage from my books (the third-generation sensor API makes my head hurt), I do have some samples that might help: https://github.com/commonsguy/cw-advandroid/tree/master/Sensor On Wed, Nov 16, 2011 at 8:46 AM, Raghav Sood raghavs...@androidactivist.org wrote: Having a little problem here. I am making an app that uses the GPS, accelerometer and compass. GPS works fine. The problem comes with the other two. According to the Log.d s splattered all over my code, the following code receives the sensor events for the sensor with the int code 1, which according to the docs is the accelerometer. public void onSensorChanged(SensorEvent evt) { float vals[] = evt.values; //Log.d(PAAR, Sensor triggered.); if(evt.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD || evt.sensor.getType() == Sensor.TYPE_ORIENTATION) { float rawDirection = vals[0]; Log.d(PAAR, compass Sensor triggered.); direction =(float) ((rawDirection * kFilteringFactor) + (direction * (1.0 - kFilteringFactor))); inclination = (float) ((vals[2] * kFilteringFactor) + (inclination * (1.0 - kFilteringFactor))); if(aboveOrBelow 0) { inclination = inclination * -1; } if(evt.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { aboveOrBelow = (float) ((vals[2] * kFilteringFactor) + (aboveOrBelow * (1.0 - kFilteringFactor))); Log.d(PAAR, Accelerometer ); } } } Yet the if statement for the accelerometer doesn't kick in. Also why am I not receiving the compass events? My device has a compass, I am 100% sure of that. I register the sensors as follows: sensorManager = (SensorManager)this.getSystemService(Context.SENSOR_SERVICE); sensorManager.registerListener(listener, sensorManager.getDefaultSensor( SensorManager.SENSOR_ORIENTATION), SensorManager.SENSOR_DELAY_FASTEST); sensorManager.registerListener(listener, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST); Ideas/solutions, anyone? Thanks -- Raghav Sood http://www.androidactivist.org/ - Author http://www.appaholics.in/ - Founder -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Sensor events are received, but not working.
Thanks Mark! I'll work on updating the orientation code. Do you have any idea why the if statement for the accelerometer doesn't kick in, even though I am getting a couple of thousand sensor events for type 1? Thanks On Wed, Nov 16, 2011 at 7:22 PM, Mark Murphy mmur...@commonsware.comwrote: FWIW, the orientation sensor is deprecated. While I yanked the sensor coverage from my books (the third-generation sensor API makes my head hurt), I do have some samples that might help: https://github.com/commonsguy/cw-advandroid/tree/master/Sensor On Wed, Nov 16, 2011 at 8:46 AM, Raghav Sood raghavs...@androidactivist.org wrote: Having a little problem here. I am making an app that uses the GPS, accelerometer and compass. GPS works fine. The problem comes with the other two. According to the Log.d s splattered all over my code, the following code receives the sensor events for the sensor with the int code 1, which according to the docs is the accelerometer. public void onSensorChanged(SensorEvent evt) { float vals[] = evt.values; //Log.d(PAAR, Sensor triggered.); if(evt.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD || evt.sensor.getType() == Sensor.TYPE_ORIENTATION) { float rawDirection = vals[0]; Log.d(PAAR, compass Sensor triggered.); direction =(float) ((rawDirection * kFilteringFactor) + (direction * (1.0 - kFilteringFactor))); inclination = (float) ((vals[2] * kFilteringFactor) + (inclination * (1.0 - kFilteringFactor))); if(aboveOrBelow 0) { inclination = inclination * -1; } if(evt.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { aboveOrBelow = (float) ((vals[2] * kFilteringFactor) + (aboveOrBelow * (1.0 - kFilteringFactor))); Log.d(PAAR, Accelerometer ); } } } Yet the if statement for the accelerometer doesn't kick in. Also why am I not receiving the compass events? My device has a compass, I am 100% sure of that. I register the sensors as follows: sensorManager = (SensorManager)this.getSystemService(Context.SENSOR_SERVICE); sensorManager.registerListener(listener, sensorManager.getDefaultSensor( SensorManager.SENSOR_ORIENTATION), SensorManager.SENSOR_DELAY_FASTEST); sensorManager.registerListener(listener, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST); Ideas/solutions, anyone? Thanks -- Raghav Sood http://www.androidactivist.org/ - Author http://www.appaholics.in/ - Founder -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Raghav Sood http://www.androidactivist.org/ - Author http://www.appaholics.in/ - Founder -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Sensor events are received, but not working.
It might be a combined bitfield, since they have a TYPE_ALL. Beyond that, no clue. On Wed, Nov 16, 2011 at 9:18 AM, Raghav Sood raghavs...@androidactivist.org wrote: Thanks Mark! I'll work on updating the orientation code. Do you have any idea why the if statement for the accelerometer doesn't kick in, even though I am getting a couple of thousand sensor events for type 1? Thanks On Wed, Nov 16, 2011 at 7:22 PM, Mark Murphy mmur...@commonsware.com wrote: FWIW, the orientation sensor is deprecated. While I yanked the sensor coverage from my books (the third-generation sensor API makes my head hurt), I do have some samples that might help: https://github.com/commonsguy/cw-advandroid/tree/master/Sensor On Wed, Nov 16, 2011 at 8:46 AM, Raghav Sood raghavs...@androidactivist.org wrote: Having a little problem here. I am making an app that uses the GPS, accelerometer and compass. GPS works fine. The problem comes with the other two. According to the Log.d s splattered all over my code, the following code receives the sensor events for the sensor with the int code 1, which according to the docs is the accelerometer. public void onSensorChanged(SensorEvent evt) { float vals[] = evt.values; //Log.d(PAAR, Sensor triggered.); if(evt.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD || evt.sensor.getType() == Sensor.TYPE_ORIENTATION) { float rawDirection = vals[0]; Log.d(PAAR, compass Sensor triggered.); direction =(float) ((rawDirection * kFilteringFactor) + (direction * (1.0 - kFilteringFactor))); inclination = (float) ((vals[2] * kFilteringFactor) + (inclination * (1.0 - kFilteringFactor))); if(aboveOrBelow 0) { inclination = inclination * -1; } if(evt.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { aboveOrBelow = (float) ((vals[2] * kFilteringFactor) + (aboveOrBelow * (1.0 - kFilteringFactor))); Log.d(PAAR, Accelerometer ); } } } Yet the if statement for the accelerometer doesn't kick in. Also why am I not receiving the compass events? My device has a compass, I am 100% sure of that. I register the sensors as follows: sensorManager = (SensorManager)this.getSystemService(Context.SENSOR_SERVICE); sensorManager.registerListener(listener, sensorManager.getDefaultSensor( SensorManager.SENSOR_ORIENTATION), SensorManager.SENSOR_DELAY_FASTEST); sensorManager.registerListener(listener, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST); Ideas/solutions, anyone? Thanks -- Raghav Sood http://www.androidactivist.org/ - Author http://www.appaholics.in/ - Founder -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Raghav Sood http://www.androidactivist.org/ - Author http://www.appaholics.in/ - Founder -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Sensor events are received, but not working.
Guess you could be right, Perhaps shifting all the sensor code to the newer APIs could fix it. Thanks On Wed, Nov 16, 2011 at 10:30 PM, Mark Murphy mmur...@commonsware.comwrote: It might be a combined bitfield, since they have a TYPE_ALL. Beyond that, no clue. On Wed, Nov 16, 2011 at 9:18 AM, Raghav Sood raghavs...@androidactivist.org wrote: Thanks Mark! I'll work on updating the orientation code. Do you have any idea why the if statement for the accelerometer doesn't kick in, even though I am getting a couple of thousand sensor events for type 1? Thanks On Wed, Nov 16, 2011 at 7:22 PM, Mark Murphy mmur...@commonsware.com wrote: FWIW, the orientation sensor is deprecated. While I yanked the sensor coverage from my books (the third-generation sensor API makes my head hurt), I do have some samples that might help: https://github.com/commonsguy/cw-advandroid/tree/master/Sensor On Wed, Nov 16, 2011 at 8:46 AM, Raghav Sood raghavs...@androidactivist.org wrote: Having a little problem here. I am making an app that uses the GPS, accelerometer and compass. GPS works fine. The problem comes with the other two. According to the Log.d s splattered all over my code, the following code receives the sensor events for the sensor with the int code 1, which according to the docs is the accelerometer. public void onSensorChanged(SensorEvent evt) { float vals[] = evt.values; //Log.d(PAAR, Sensor triggered.); if(evt.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD || evt.sensor.getType() == Sensor.TYPE_ORIENTATION) { float rawDirection = vals[0]; Log.d(PAAR, compass Sensor triggered.); direction =(float) ((rawDirection * kFilteringFactor) + (direction * (1.0 - kFilteringFactor))); inclination = (float) ((vals[2] * kFilteringFactor) + (inclination * (1.0 - kFilteringFactor))); if(aboveOrBelow 0) { inclination = inclination * -1; } if(evt.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { aboveOrBelow = (float) ((vals[2] * kFilteringFactor) + (aboveOrBelow * (1.0 - kFilteringFactor))); Log.d(PAAR, Accelerometer ); } } } Yet the if statement for the accelerometer doesn't kick in. Also why am I not receiving the compass events? My device has a compass, I am 100% sure of that. I register the sensors as follows: sensorManager = (SensorManager)this.getSystemService(Context.SENSOR_SERVICE); sensorManager.registerListener(listener, sensorManager.getDefaultSensor( SensorManager.SENSOR_ORIENTATION), SensorManager.SENSOR_DELAY_FASTEST); sensorManager.registerListener(listener, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST); Ideas/solutions, anyone? Thanks -- Raghav Sood http://www.androidactivist.org/ - Author http://www.appaholics.in/ - Founder -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Raghav Sood http://www.androidactivist.org/ - Author http://www.appaholics.in/ - Founder -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are