PhilipK Member Licensed User Longtime User Jun 15, 2015 #1 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.
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.
Erel B4X founder Staff member Licensed User Longtime User Jun 16, 2015 #2 You can use the PhoneSensors library with this sensor. You need to pass 19 as the SensorType. Upvote 0
PhilipK Member Licensed User Longtime User Jun 16, 2015 #3 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
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.
Erel B4X founder Staff member Licensed User Longtime User Jun 16, 2015 #4 Which method do you need to access? Upvote 0
PhilipK Member Licensed User Longtime User Jun 16, 2015 #5 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: Code: Sub Service_Create sensor.Initialize2(sensor.TYPE_ACCELEROMETER,0) Code: 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. Click to expand... 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
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: Code: Sub Service_Create sensor.Initialize2(sensor.TYPE_ACCELEROMETER,0) Code: 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. Click to expand... 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!
Erel B4X founder Staff member Licensed User Longtime User Jun 17, 2015 #6 Your code looks correct. It probably returns an array with a single value. Upvote 0
MaFu Well-Known Member Licensed User Longtime User Jun 17, 2015 #7 Why do you expect more then one value? The accelerometer data are handled internally, the result value is only the number of steps. Upvote 0
Why do you expect more then one value? The accelerometer data are handled internally, the result value is only the number of steps.
PhilipK Member Licensed User Longtime User Jun 17, 2015 #8 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() Click to expand... In the low power mode, type 19, how do I access the acceleration data? Upvote 0
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() Click to expand... In the low power mode, type 19, how do I access the acceleration data?
MaFu Well-Known Member Licensed User Longtime User Jun 17, 2015 #9 PhilipK said: In the low power mode, type 19, how do I access the acceleration data? Click to expand... 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
PhilipK said: In the low power mode, type 19, how do I access the acceleration data? Click to expand... 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).
PhilipK Member Licensed User Longtime User Jun 17, 2015 #10 @MaFu thanks. It seems to me Sony are potentially offering access to all the on-board sensors in a low power mode, by way of a co-processor: http://developer.sonymobile.com/201...e-new-sensor-co-processor-video-code-example/ I'll contact Sony and ask if this concept has moved beyond a step counter. Attachments upload_2015-6-17_16-4-2.png 176.2 KB · Views: 434 Upvote 0
@MaFu thanks. It seems to me Sony are potentially offering access to all the on-board sensors in a low power mode, by way of a co-processor: http://developer.sonymobile.com/201...e-new-sensor-co-processor-video-code-example/ I'll contact Sony and ask if this concept has moved beyond a step counter.