Improved memory usage in Espruino

Posted on
Page
of 2
Prev
/ 2
  • Just fixed. In an hour or so the latest should be available at:

    http://www.espruino.com/binaries/git/com­mits/551b5c4adc7962e2485224c767816b95347­36d15

  • Thanks, just tested and works fine.
    Next tested a big application (>1800 blocks) and workd fine too.

  • Sorry if this is the wrong thread, but I'm also getting bogus readings from the BMP180 as reported in comment #12. For example -29363 Pa. Tested using both 1v69 and the 1v70 build from yesterday, with the same result.

    Is there something I can do to work around this in the meantime, or should I wait for a fix?

  • I'm gonna try and fix this tonight.

    I think it can be fixed with judicious use of parenthesis

    Edit: Okay, yeah, I see the problem. It looks like that was written for an unsigned 32-bit integer (the code was ported from arduino), and still has workarounds for handling the large numbers.

    var p = Math.round(B7 < 0x80000000 ? (B7 << 1) / B4 : (B7 / B4) << 1);
    

    In my tests at ambient pressure, B7 is 1.6 billion or so - so when it left-shifts it, it turns into a negative number.

    In at least the current ambient conditions, changing that to

    var p=Math.round((B7/B4) << 1);
    

    seems to work, but I don't think it will work at all pressures - I fear that B7 can get large enough that it could roll over to a negative number on the line before that one (since they test whether it's greater than 0x80000000, which is the point at which it would have already rolled over)

  • Thanks a lot! Works great, for my current ambient pressure at least. It will do the trick until the underlying problem is fixed :)

  • I've just pulled in @DrAzzy's changes, so hopefully this will magically be fixed the next time you upload your code.

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

Improved memory usage in Espruino

Posted by Avatar for Gordon @Gordon

Actions