You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • JSON wrapper with more than 4 parameters

    You can use JsVarArray and can decode all the arguments manually if you want more - it's not worth me wasting another byte (or more) for each function, as 99% of them have 4 or less arguments.

    main problem is right now how to read my pixelbuffer (uint8array), change some values and store back.

    Instead of trying to get a memory area I'd use jsvArrayBufferIterator - JSV_GET_AS_CHAR_ARRAY was added as a bit of a hack to allow other non-espruino bits of code to access data. All of Espruino's stuff is written to access the data in-place rather than copying it onto the stack first.

    However... what are you trying to accomplish? Espruino already lets you access 8x8 RGB matrices of WS2812 really easily: http://www.espruino.com/RGB123

    The Graphics library has everything built in, so realistically what you're doing can be accomplished in JS with:

    SPI2.setup({baud:3200000, mosi:B15});
    var leds = Graphics.createArrayBuffer(8,8,24,{zigza­g:true}); 
    leds.flip = function() { SPI2.send4bit(leds.buffer, 0b0001, 0b0011); };
    
    leds.clear();
    leds.setColor(r,g,b);
    leds.fillRect(0,0,7,7);
    leds.flip();
    
About

Avatar for Gordon @Gordon started