Storage space on Bangle.js 2.

Posted on
  • Hi,
    The Bangle.js 2 feature page notes :

    256kB RAM 1024kB on-chip flash, 8MB external flash

    I'm confused about Espruino's various getFree() outputs :

    >process.version
    ="2v10.89"
    >process.memory()
    ={ free: 7172, usage: 4828, total: 12000, history: 34,
      gc: 0, gctime: 20.99609375, blocksize: 15, stackEndAddress: 537085312, flash_start: 0,
      flash_binary_end: 523848, flash_code_start: 1610612736, flash_length: 1048576 }
    

    'flash_length' would then be the size of the internal flash ?

    And then there is :

    >require("Flash").getFree()
    =[
      { addr: 524288, length: 483328 }
     ]
    >require("Storage").getFree()
    =8277864
    > 
    

    After reading

    Flash Library
    This module allows you to read and write the nonvolatile flash memory of your device.
    Also see the Storage library, which provides a safer file-like interface to nonvolatile storage.

    I thought the 'Flash' and 'Storage' modules accessed the same Flash memory, with a separate API (roughly page vs file). But how then is the getFree() output to be interpreted ? Do I actually have 8 MByte available for access through the 'Storage' module ?

    What then is the length of 483328 for the 'Flash' module ?

    (I have about 60 kByte of code and files on the Bangle.js 2 for the moment, so I don't think it has anything to do with the Flash not being consecutive anymore.)

    (All these questions because I need 'a lot' of space for storing a Far-East unicode font...)

  • Yes, it is a bit confusing, but basically:

    • flash_length is how much internal flash you have
    • require("Flash").getFree() is the memory in internal flash, not used by Storage
    • require("Storage").getFree() is the memory available in Storage, in Bangle.js this is external storage

    Do I actually have 8 MByte available for access through the 'Storage' module ?

    Yes.

    What then is the length of 483328 for the 'Flash' module ?

    That's internal flash that isn't used by code

    All these questions because I need 'a lot' of space for storing a Far-East unicode font...

    Eep. Obviously I don't know quite what you have planned, but the approach I'm taking with text messages on Bangle.js is to render them to a bitmap on a bigger computer, and send the bitmap over rather than just the text.

    You can now add images in-line in text that you draw with drawstring (just add a 0 character then the raw image data in Espruino's image format) so it may be quite easy to implement.

    The very newest firmware actually has two blocks of memory used for storage - internal and external - so it is possible to use that ~500k of internal flash as well.

    However I feel like if the difference between 8MB and 8.5MB is a killer for you, it may be worth looking at different approaches.

  • you can now add images in-line in text

    Could you do an example code snippet.

  • Like this:

    var txt = "Hello \0" + atob("HBKBAD///8H///iP//8cf//j4//8f5//j/x/8//j/H//H4//4PB//EYj/44HH/Hw+P4//8fH//44///xH///g////A==") + " World"; 
    g.clear(1).setFontAlign(0,0).setFont("6x8");
    g.drawString(txt,88,88);
    

    stringWidth/stringMetrics/wrapString will work even with the image inline too. Only gotcha is the line height is the height of the text, not that of the image (which is centered)


    1 Attachment

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

Storage space on Bangle.js 2.

Posted by Avatar for jgw @jgw

Actions