Android Question Reduced Power Consumption with Sensor Co-Processor

PhilipK

Member
Licensed User
Longtime User
Hi

I have come across the following:

The power consumption of a Sony smartphone using its on-board sensors can be dramatically reduced: http://developer.sonymobile.com/201...e-new-sensor-co-processor-video-code-example/

Sony say there is a 10 x power saving. Normal running of a Sony phone (display off) with the sensors enabled is about 42mA. Using the sensor co-processor the consumption drops to around 3.9mA.

I'd like a piece of this!

How could this functionality be incorporated in B4A?

Here is the link to the developer site: http://developer.android.com/reference/android/hardware/Sensor.html#TYPE_STEP_COUNTER

Thanks.
 

PhilipK

Member
Licensed User
Longtime User
Erel, great news, thanks.

I'd like to reduce the power consumption of my app which uses the accelerometers.

I've passed SensorType 19 but can't access any of the object's constants, methods etc.referred to in the developers guide. Please could you give a hint on how to implement this functionality, in code?

Your help is very much appreciated.
 
Upvote 0

PhilipK

Member
Licensed User
Longtime User
The background: I have a service that handles the accelerometers. If collects values and posts the data into a public array. The data is processed in another service module (called DAS).

This is the current starting point:

B4X:
Sub Service_Create
   
    sensor.Initialize2(sensor.TYPE_ACCELEROMETER,0)


B4X:
Sub Sensor_SensorChanged (Values() As Float)
    DAS.DataArray(1,ArrayPoint)=Values(0)
    DAS.DataArray(2,ArrayPoint)=Values(1)
    DAS.DataArray(3,ArrayPoint)=Values(2)
    ArrayPoint=ArrayPoint+1
    If ArrayPoint>(DAS.ArraySize-1) Then ArrayPoint=0
End Sub

I think the following from the documentation is possibly the way to go but how?:


Having set SensorType to 19 it gives a single value which results in an index out of bounds error.

As you see, I'm completely lost!
 
Upvote 0

PhilipK

Member
Licensed User
Longtime User
I'm missing something big here: How to pick up the X,Y,Z acceleration data, if only a single value is returned which MaFu says is a step count.

With the standard sensor.Initialize2(sensor.TYPE_ACCELEROMETER,0) you use 'Sub Sensor_SensorChanged (Values() As Float)' delivering an array with 3 axes of acceleration. The developer documentation refers to:

Implement a SensorEvent callback function, onSensorChanged()

In the low power mode, type 19, how do I access the acceleration data?
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
In the low power mode, type 19, how do I access the acceleration data?
Mode 19 is only a step counter. If you need the full acceleration data you cannot use the low power mode (maybe in future but not yet).
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…