Avatar for asez73

asez73

Member since Oct 2014 • Last active Jan 2019
  • 9 conversations
  • 154 comments

I have an Espruino board 1v4 and a Kickstarter Pico board...

Most recent activity

  • in General
    Avatar for asez73

    Hi again,
    Well now github offers unlimited private projects for free, the restriction is on the number of developpers allowed to participate.
    There is also gitlab which does more or less the same.
    Their rate limits are probably high enough for me as I don't frenetically type on my keyboard :)
    Still we would need some API on their side.
    And finally, I'd prefer a save to a local storage.

  • in JavaScript
    Avatar for asez73

    Hi,
    Not really, but quite close to that... In fact it was a class and I did not found a way to list the source of a class. My trick gets the source of an instance of a class.
    All of this happened on an instance of the class runningStats which was itself a property or an instance of the class object stopWatch.

    Indeed I deleted the source code in the editor (right side pane) and stupidly saved that incomplete source code to my PC without noticing what had disappeared. Could we get versionning every time we save a source, maybe just renaming the previous same named file with an added time stamp automatically?

    The joined file contains that whole thing in terms of: what the little trick gave from the running source on the Espruino, what I finally got after re-editing this dump to get a new version of the source.
    Thus I was left with a running instance of my program on the Pico and no way to list it to get back the almost last version of it.
    That said, I think it would be nice to be able to reconstruct an object by just a simple dump.

    Eventually, some improvements on the editor side would be nice too: something like "Do you want to delete the lines selected" when there are many of them.

  • in General
    Avatar for asez73

    Hi,
    a) Well other options are not always remembered: the minification options for instance are more or less randomly saved, and so does the time set option.

    b) Ok, so this is a feature reserved to the native application: I use the linux one on Ubuntu 16.04.

    c) It's just disapointing and onec I got used, yet some thing to do manually. By the way, I would greatly appreciate having an otion to peridically save the source AND journalise those saves (git commits with automatic commit comment would be nice). I guess, reading your answer, that it won't happen unfortunately.

    Thank's for your answer.

  • in JavaScript
    Avatar for asez73

    Hi,
    I would like to share this as I had some difficulties some weeks ago and got out of trouble using this:

    Here is a recipe to extract the class definition of an object in the console pane.

    I used it on a running Espruino Pico which had an objet stopwatch.runningOnStats saved but could not get its source defintion from dump().
    It was no more available in the WebIde editor pane because I had wiped it and saved without seeing this before... So I had lost all of the source code for the class runningOnStats property of stopwatch

    In the following case, stopwatch.runningOnStats is the object which we want to get the defintion on the console.
    We will have to copy/paste/edit the result from the console to get it in a source form

    
    var rs=Object.getPrototypeOf(stopwatch.runni­ngOnStats);
    for (var p of Object.getOwnPropertyNames(rs)) {
      console.log(p);
      console.log(Object.getOwnPropertyDescrip­tor(Object.getPrototypeOf(stopwatch.runn­ingOnStats), p));
    }
    
    

    The attached file is a more explicit result and execution trace of what this gave to me.

  • in General
    Avatar for asez73

    Hi, this is an old thread, however, I face some difficulties with the WebIde as a Chrome application and just the https://www.espruino.com/ide/.
    Here are what they are:
    a- In the WebIde settings>Communications, I have to reselect the last option "Set current time" each time the WedIde is restarted from Android. It seems, it is not saved in this configuration.
    b- The "Project directory for sandbox" button in Settings>Project doesn't display any select box.
    It gets darker a few 1/10 of a second each time i press it. Again that's on Android through the Chrome application and the web served ide https://www.espruino.com/ide/.
    c- Saving (disquette button) displays a disturbing "download" message and doesn't let me choose the file name. I get a code(some number).js file in my download directory.

    My Android version is 7.0.

    I was wondering if there could be some "hidden setting" to properly setup in Chrome?

    Thanks for your attention.

  • in JavaScript
    Avatar for asez73

    Thanks,
    Yes, I had forgotten about decimals beeing rounded somewhere when transformed into binaries.

    So I tested the second solution and it works.

    I totally agree with the no bug approach. The trick is that it's a silent killer. As well as dynamic typing is indeed.

    However, the value of v is continuous (risk level in probability) so the exact comparison done by Array.indexOf was not my need.

    I finally settled on Array.findIndex as I can get an index through a comparison function even if the value is really not in the array but rather in between values in the array. My array is sorted in increase order.
    And this came from your first answer. tab1mAlpha.findIndex(a=>Math.abs(a-v)<0.­000001)

    This page provides the formulas and statistics tables from which I extracted the 2 arrays below...
    That gave me:

    // approximately computes the xhi2 of 2 degrees of liberty value for alpha risk
      function xhi2_2(alphaRisk) { 
            var idx = [0.05, 0.1, 0.2, 0.3, 0.5, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999].findIndex(elt => elt>=(1-alphaRisk));
        return [0.10, 0.21, 0.45, 0.71, 1.39, 2.41, 3.22, 4.61, 5.99, 9.21, 13.82][idx];
      }
     
    

    Thank's again for your reactivity and commitment to understand our questions!

  • in JavaScript
    Avatar for asez73

    Hi @Gordon,

    While trying to do some statistics, I found that situation on a v2.00 upgrade Pico:

    >var tab1mAlpha = new Array( 0.05, 0.1, 0.2, 0.3, 0.5, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999);
    =[ 0.05, 0.1, 0.2, 0.3, 0.5, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999 ]
    >console.log(tab1mAlpha.indexOf(v))
    -1
    =undefined
    >v
    =0.95
    >typeof v
    ="number"
    

    However, using the test box in the mozilla page, I got

    var tab1mAlpha= [0.05, 0.1, 0.2, 0.3, 0.5, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999];
    var v=1-0.05;
    console.log(tab1mAlpha.indexOf(v));
    console.log(typeof v);
    

    which once run showed:

    > 8
    > "number"
    

    So, is this a bug or I am not understanding something?

    P.S.: Should I report this type of problem on the forum or in github?

  • in JavaScript
    Avatar for asez73

    HI @Robin and @Gordon,

    Thanks for your help, it did worked and I globally saved some time AND events stack depth.
    Now I don't have to separate in time, by emiting events, concatenation, slicing and storing from the Serial.on handler: it just happens fast enough without throwing any event to my Gps object.
    In some cases, I could receive enough messages and emit one event per messages, which stopped the program with strange corrupted data in the line received. The result was a buffer way too long (32Kb) and other mysterious unvalid gps data.

    Now, I am more on 2 colateral problems:
    1-one in Javascript (Serial.pipe chunk parameter in order to limit the number of calls to handler of the input data and get at least any message header at once),
    2-one in hardware (Pico powered by 3.7 V battery, deep sleeping as long as possible, using the B0 mosfet with the supplied 3.7 V)

    So I think we are far enough of flat strings and should open 2 other threads to handle those points.

    Thanks again!

Actions