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?
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?
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?:
Create a sensor manager instance.
Register a listener for the STEP_COUNTER sensor type.
Implement a SensorEvent callback function, onSensorChanged(), which serves the STEP_COUNTER sensor events.
Make sure to handle the initial step-count value accordingly. As per definition the STEP_COUNTER will reset its value at system restart and increment it as long as there is a client application for it. This means that any application using it needs to track the start-offset itself, see variables mStepsSInceBoot and mLastReport in the java file for an example.
Discard any OnPause() or other power management handling, this is not needed when having a built-in step counter. The sensor co-processor will be notified when the system goes up or down, and only send events when the system is up.
During system down, the sensor co-processor will keep tracking steps and send an event as soon as the system is up. No action is needed in your app.
To support devices without the sensor co-processor, however, you will need to maintain a fallback solution of streaming raw accelerometer data instead of using the built-in step counter sensor type.
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()