Avatar for fanoush

fanoush

Member since Jul 2018 • Last active Sep 2023

Most recent activity

  • in Bangle.js
    Avatar for fanoush

    but the espruino compiler isn't releasing memory when splice or shift.

    it is interpreter, compilers are supposed to compile, not manage runtime memory

    Just tried slice, splice, shift and also pop, at least in simple cases it works

    
     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v19.182 (c) 2023 G.Williams
    
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    
    >a=[];i=0
    =0
    >process.memory()
    ={ free: 13978, usage: 22, total: 14000, history: 9,
      gc: 0, gctime: 2.469, blocksize: 18 }
    >for (var i=0;i<100;i++)a.push(i)
    =undefined
    >process.memory()
    ={ free: 13878, usage: 122, total: 14000, history: 13,
      gc: 0, gctime: 2.435, blocksize: 18 }
    >while(a.length)a.shift()
    =undefined
    >process.memory()
    ={ free: 13978, usage: 22, total: 14000, history: 16,
      gc: 0, gctime: 1.872, blocksize: 18 }
    >for (var i=0;i<100;i++)a.push(i)
    =undefined
    >process.memory()
    ={ free: 13878, usage: 122, total: 14000, history: 16,
      gc: 0, gctime: 1.664, blocksize: 18 }
    >for (i=0;i<100;i++)a.push(i)
    =undefined
    >process.memory()
    ={ free: 13778, usage: 222, total: 14000, history: 20,
      gc: 0, gctime: 0.697, blocksize: 18 }
    >while(a.length)a.shift()
    =undefined
    >process.memory()
    ={ free: 13978, usage: 22, total: 14000, history: 20,
      gc: 0, gctime: 2.424, blocksize: 18 }
    >for (i=0;i<100;i++)a.push(i)
    =undefined
    >process.memory()
    ={ free: 13878, usage: 122, total: 14000, history: 20,
      gc: 0, gctime: 2.41, blocksize: 18 }
    >while(a.length)a.pop()
    =undefined
    >process.memory()
    ={ free: 13978, usage: 22, total: 14000, history: 23,
      gc: 0, gctime: 0.525, blocksize: 18 }
    >for (i=0;i<100;i++)a.push(i)
    =undefined
    >a=a.slice(50)
    =[ 50, 51, 52, 53, 54,  ... 95, 96, 97, 98, 99 ]
    >process.memory()
    ={ free: 13928, usage: 72, total: 14000, history: 25,
      gc: 0, gctime: 0.528, blocksize: 18 }
    >while(a.length)a.pop()
    =undefined
    >process.memory()
    ={ free: 13978, usage: 22, total: 14000, history: 25,
      gc: 0, gctime: 0.687, blocksize: 18 }
    >
    >a=[1,2,3,4,5]
    =[ 1, 2, 3, 4, 5 ]
    >process.memory()
    ={ free: 13973, usage: 27, total: 14000, history: 30,
      gc: 0, gctime: 0.812, blocksize: 18 }
    >a.splice(3,2,10,11)
    =[ 4, 5 ]
    >a
    =[ 1, 2, 3, 10, 11 ]
    >process.memory()
    ={ free: 13973, usage: 27, total: 14000, history: 30,
      gc: 0, gctime: 2.526, blocksize: 18 }
    >a.splice(3,2)
    =[ 10, 11 ]
    >process.memory()
    ={ free: 13975, usage: 25, total: 14000, history: 34,
      gc: 0, gctime: 2.294, blocksize: 18 }
    >a
    =[ 1, 2, 3 ]
    >
    

    check usage, goes up and down as expected

    It will limit you from creating good stable apps

    For me good and stable app is not bloated app that runs slow (=drains more battery) and needs lot of memory.

    which are easy to maintain and extend. Most of the apps in the current app library are not extendable or maintainable.

    This is debatable. Smaller code without unneeded abstractions can be easy to maintain and extend too. Someone else may see your perfectly testable and extensible code hard too. Also the size of typical watch app is not that big and people write it for fun and for free so extendable and maintainable may not be even the goal here.

  • in The Place for Patreon Patrons
    Avatar for fanoush

    you can monitor RX pin with setWatch (with input pulldown) and when it goes up you reconfigure it as serial, I had it like this on DS-D6
    https://gist.github.com/fanoush/ce461c73­c299834bcb53a615721b5a2e#file-dsd6-js-L2­34

    You could also have pull up and monitor when it goes low if the serial is permanently attached and the pin is high but first character may be lost, which is still ok for console if you first press Enter and wait a bit.

    For ds-d6 I went with first option so console was enabled when I plugged it into usb female attached to usb serial adapter.

  • in The Place for Patreon Patrons
    Avatar for fanoush

    It needs to be connected at boot time. There is check that RX is pulled high otherwise serial is not enabled. Keeping serial enabled draws about 1mA constantly.

    You can try from bluetooth connection to call Serial1.setup and then try Serial1.setConsole to see if it starts working.

  • in The Place for Patreon Patrons
    Avatar for fanoush

    it is better to use the provision script with your board name
    . ./scripts/provision.sh boardname
    it will download and patch sdk15 and also add good compiler to the path, your gcc 5.4 is not the best choice

  • in Bangle.js
    Avatar for fanoush

    That was one of the things that was specifically called out in Pebble development. The display was updated a horizontal row at a time, and a whole row had to be sent. So even if you were only updating a rectangle 10 px high by 3 px wide, you'd still have to send the entire 10 rows

    Yes, that is true also here, display is updated in whole lines. Framebuffer is in RAM, pixels are updated as needed, then at flip() time whole area between min and max modified Y coordinate is sent from RAM to the display (3 bits per pixel - 66 bytes per line).

    And the display's power consumption increased dramatically when updating.

    the watch has LPM013M126 display, found two datasheets for A and C versions, both have same table on page 9
    https://www.j-display.com/product/pdf/Da­tasheet/4LPM013M126A_specification_Ver02­.pdf#page=9
    https://www.j-display.com/product/pdf/Da­tasheet/5LPM013M126C_specification_ver03­.pdf#page=9

    Both values (no update vs data update) are very very low (116uW=~40uA at 3V absolute maximum or 10/3=3.3uA typical).

    CPU draws 4mA when not in sleep, SPI DMA transfer draws about 1mA (CPU can sleep) so both drawing and sending data takes far more power on CPU side.

    datasheet says max SPI frequency is 2MHz (page 10), we use 4 here https://github.com/espruino/Espruino/blo­b/master/libs/graphics/lcd_memlcd.c#L401­
    =500KB/s, whole display is 11.6KB so about 23ms (at ~1mA) to send over SPI (or 0.13ms per line)

    I'd guess the javascript code to compute and draw anything to framebuffer takes more than 23ms .

    Maybe on Pebble if the drawing code is native then updating screen over SPI may take proportionally more time than producing the change as the SPI frequency is quite low. But in both cases it is the nrf52 chip that consumes most of the energy here, not the display.

    But still for the whole watch it can be said that "power consumption increases dramatically when updating the screen" because otherwise everything sleeps most of the time. Well, unless you have backlight or GPS turned on :-) https://www.espruino.com/Bangle.js2#powe­r-consumption

  • in Bangle.js
    Avatar for fanoush
    1. button press is taken by first unlocking and second entering menu. Not sure you get touch event when input is locked but after pressing button to unlock you should get the touch event when screen is touched.

    2. Yes. However I guess it is not the display itself that consumes that much power on update it is the CPU wakeup and activity to produce something drawable before sending the result to display, here it is also the JavaScript interpreter that takes milliseconds to execute even few lines of code.

  • in Bangle.js
    Avatar for fanoush

    My first thought was that bangle was keeping files read from strorage (which I do in "loadRoute") in memory

    Storage.read returns just pointer to flash. However RAM is used once you start manipulating the data (like reading short blocks from storage and concatenating them) so sometimes it may be better to 'read' whole file at once and just iterating over the big string or array than reading in small chunks and possibly joining them back. so depends on your loadRoute code whether it ' was keeping files read from storage in memory' . If it was just iterating over it there is no data to garbage collect.

    Also the interpreter is running code directly from flash not using RAM. Unless you upload code to RAM, then it of course needs more RAM for storing uploaded code.

  • in ESP8266
    Avatar for fanoush

    Strange characters also appear on the serial monitor

    this is caused by incorrectly set baud rate on COM port, installed firmware is using different speed than you set there (9600 in bottom right)

    I think the software it came with is damaged.

    no, not 'damaged', it is no longer there at all, you overwrote it by installing other ones on top of it, and there is probably no point in installing it (and we can hardly guess which one it was)

    If you want to use Arduino I'd start from scratch and follow some tutorial like https://techtutorialsx.com/2016/02/28/es­p8266-uploading-code-from-arduino-ide/

    Also for Arduino issues it is better to ask in some Arduino forum, not here

  • in Bangle.js
    Avatar for fanoush

    Shame no1 linked to it (and I wasn't able to find it) when I was asking about which version of javascript Espruino is based on.

    You got that link right here https://forum.espruino.com/conversations­/388506/#17058616 when you asked :-)

  • in Bangle.js
    Avatar for fanoush

    Where does the changed code for (change #1) now live. Is it in my forked repository ?

    yes, the PR is based on branch in your repo that you want to merge to upstram repo so any change in that branch goes to the PR. I think there is no other way for changes done by others so you need to pull that branch and possibly merge those changes back to your local repo before you can push more changes

    Can anyone show me where the 'Update' button is on a github repo.

    not sure I understand but there is sync button on the branch

Actions