Avatar for d3nd3-o0

d3nd3-o0

Member since Jun 2020 • Last active Oct 2021
  • 35 conversations
  • 174 comments

Most recent activity

  • in Bangle.js
    Avatar for d3nd3-o0

    https://github.com/espruino/BangleApps/b­lob/f1ce196ad1de28f1d07affe81d27ae4d284b­d6f7/apps/doztime/app.js#L175

    let wait = 4167*(1-(x%1));

    Any variable that is % modulo operator with 1 will output 0. So that code is saying, 4167* (1 - 0) ... which is equivalent to 4167 * 1 equivalent to 4167.

    let wait = 4167

    Am I wrong?

  • in Bangle.js
    Avatar for d3nd3-o0

    Agreed.

  • in Bangle.js
    Avatar for d3nd3-o0

    No, its not like that at all from my end. I am digging at it because I am willing to contribute and try to assist you because I am fully aware that you take on a lot of responsibility and workload. I think that the way I go about trying to be helpful just ends up wasting your attention and you'd prefer if I created a solution in code myself and just pop a PR?

    Edit: There is no rush, forgive my eagerness, take your time and focus on what matters most to you. I will step back a bit. I am not familiar with how developers respond/react to issue improvements. I thought it was always the more the merrier, but if the problems are small, its just annoying?

  • in General
    Avatar for d3nd3-o0

    I will try updating it, and see how it goes.

  • in Bangle.js
    Avatar for d3nd3-o0

    Pastebin Code from my latest attempt
    Above is a link to code snippet I tried.

    My goal is to have a custom-paletted image larger than RAM to be drawn to screen and for it to be supported by the default upload format for images in Upload a File within the ide. It uses the string format and you have told me that its difficult to have what I want. Yet I have demonstrate that with extract the palette from string and load into memory and use the Object method, I can almost correctly draw images.

    The problem that remains :
    @_jswrap_graphics_parseImage for if (jsvIsObject(image))

        JsVar *buf = jsvObjectGetChild(image, "buffer", 0);
        info->buffer = jsvGetArrayBufferBackingString(buf);
        jsvUnLock(buf);
        info->bitmapOffset = imageOffset;
    

    compared to @_jswrap_graphics_parseImage for else if (jsvIsString(image)

    info->bitmapOffset += info->headerLength;
    // modify image start
    info->headerLength += (unsigned short)(paletteEntries*2);
    info->bitmapOffset += (unsigned short)(paletteEntries*2);
    

    The issue here is that info->buffer = jsvGetArrayBufferBackingString(buf); doesn't respect ArrayBufferViews substring. Or rather that it always takes the 'real' string behind the view of a string. Thus I can't extract just the string data out of the string returned from the require("Storage").read('filename'), forcing me to draw the headerData as pixels, pushing all pixels by 30 or so forward making my images not aligned properly and having weird dots in top row.
    I propose that this info->buffer = jsvGetArrayBufferBackingString(buf); could read the real string length and starting position, end position etc.. instead of defaulting to the 'real buffer'.
    If thats not what you want to do then I suggest you change the default upload of image converter to use the Object method over the string method, but as I already highlighted, it has to save all pixel/buffer data into one file on its own. The palette data loaded into a flatString, so thats 2 files, one for the image object/palette/header, one for the pixel data. The image object file could load the other file.

    I am willing to make these changes to save you the time and effort, if you tell me what you prefer.

  • in Bangle.js
    Avatar for d3nd3-o0

    The palette needs to be in RAM.

    Why does this have to be true, I thought the external SPI was memory-mapped. Can't it read the palette data this way? I can only guess it has to be true for speed concerns?

    A workaround could be that I use an object instead but have the data buffer point to the file, then the palette is on the ram and all is fine?

  • in Bangle.js
    Avatar for d3nd3-o0

    Palette: the issue is Espruino needs to be able to access the palette from RAM, and you're reading the image direct from flash. For small palettes (4 cols) it just stores the palette on the stack, and while I could extend that to 8 colors for 3 bits, at some point you'll complain that 4 bit fails too :)

    I don't really understand. Could you elaborate? The way I see it is that the palette colors are on disk within the image file. I would like to be able to drawImage direct from flash without have to load it into RAM. Is this a bug or feature?

    EDIT: Ah so you are saying that the combined memory usage of storing the palette in RAM means that it can't draw the image? I mean if thats true then it should work for slightly smaller images, I will test it. Also I can't imagine a 3 bit palette taking up that much RAM. 3 bits is 8 colours, so 8 variables or if its 16bit color conversion, 8 x 16 bit, its 4 dwords.

    If it can draw the non-paletted versions from file, it should also the paletted. I see no reason why it should be RAM intensive.

  • in Bangle.js
    Avatar for d3nd3-o0

    Yes I am trying this :

    function test(i)
    {
      let imgname = `rc${i}.img`;
      console.log(imgname);
      let imgdata = require("Storage").read(imgname);
      if ( !imgdata ) {
        console.log("cant find image");
      }
      try{
        g.drawImage(imgdata);
      } catch(e) {
        try{
          g.drawImage(E.toString(imgdata));
        }
        catch(e) {
          console.log(e);
          console.log("too large to flatstring");
        }
      }
      Bangle.setLCDPower(true);
    }
    
    function hashow() {
      let delay = 1000;
      let hihi = 27;
    for(var lol=1;lol<=hihi;lol++){
      setTimeout(test,delay*lol,lol);
    }
    }
    

    And the memory is just getting more and more full, because of the for loop. Is there a way to free memory within a for loop to run a task like this? Its meant to be a slideshow of images..
    EDIT: its related to using setTimeout within the loop I think, it doesnt activate the garbage collection cos of the setTimeout or something?

Actions