lancaster-university / microbit-dal

http://lancaster-university.github.io/microbit-docs
Other
256 stars 130 forks source link

v1.5 vs v1.3 accelerometer notifications period #445

Closed NAllred91 closed 5 years ago

NAllred91 commented 5 years ago

I've noticed that using this hex file on v1.3 and v1.5 microbits give me different results when it comes to the period of accelerometer notifications.

https://makecode.microbit.org/_hKdJdb29WgMu

On the v1.3 the notifications are very rapid. No problems with this hex file or any previous ones.

On the v1.5 the notifications are very slow (probably around a second).

I connect to the micro:bit using web bluetooth. I write to the accelerometer period characteristic like this (javascript)

accelerometerPeriodCharacteristic.writeValue(new Uint8Array([160, 0]))

I'm wondering if v1.5 is known to have a longer period for accelerometer notifications? It could also be that I'm setting the period incorrectly and that v1.3 just had a shorter period by default than v1.5?

martinwork commented 5 years ago

I think requesting these periods gives the following periods on 1.3 and 1.5...

The actual available periods on the two devices are listed in microseconds here: https://github.com/lancaster-university/microbit-dal/blob/master/source/drivers/MMA8653.cpp#L53 and here https://github.com/lancaster-university/microbit-dal/blob/master/source/drivers/LSM303Accelerometer.cpp#L54

This lookup code maps the requested period to the matching or next larger available period: https://github.com/lancaster-university/microbit-dal/blob/master/source/core/MicroBitUtil.cpp#L31

NAllred91 commented 5 years ago

Thank you!