• Hi All,

    Is the FPU of the nRF52 utilised when working with 32 bit floats?

    I would like to find the most efficient method to process data from the accelerometer and I'm a bit confused at the moment:

    • Bangle.getAccel() returns floating point values already converted to g. It's not clear though if these should be considered as float or double in terms of C.
    • The Acceleration Recorder app converts and stores these in an Int16Array. However, one might think that a Float32Array would be more straightforward and efficient to avoid conversions.
    • There's a tutorial here in the subject but I wouldn't mind avoiding inline C for now.

    I'm new to Espruino/JS and I might be confused by how C types are converted in Espruino. Could someone advise me the best approach?

    Thanks,
    -Tamás

  • Unfortunately the FPU isn't really used, no.

    The issue is that the JavaScript says that basically all maths should be done using double - so there are very few points where floats can be used - and it makes very little sense to include two sets of maths functions for float and double in such a constrained device.

    Realistically you'll find that if you're using JS the execution overhead of JS is far greater than that of dealing with doubles, so your issue is what makes the most efficient use of memory (and for that, Int16Array wins).

  • @Gordon Thank you for the explanation.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Best way to process accelerometer data (floats, Float32Array)?

Posted by Avatar for Tamás @Tamás

Actions