Avatar for allObjects

allObjects

Member since Jul 2014 • Last active Apr 2019

Espruino makes IoT as easy as 123!

Most recent activity

  • in JavaScript
    Avatar for allObjects

    this is another ES6 feature that's really unfriendly to implement in Espruino's parser, because you don't actually know whether [a,b,c] is an array or a destructuring assignment until you get to the = sign.

    I can vividly see that... because you try to resolve every '(sub)expression' as soon as possible. For the simplest solution - (plain) variable references - It would require to keep a prallel array with the references and when the = shows throw either away and continue processing accordingly. An optimization could be by having a first level of array construction with simple value object references only - no functions and other ('complex') objects - and have an earlier decision of continuing with array build process... what would then either throw an error when hitting the = sign or keep going and 'emptying' the result stack onto the references kept in the array. (...as seen from my interpreter-illiterate 'frog perspective'.) I guess the detection of wether the array element - in the anonymous array (and that is the only array type it would work) - is a plain var reference or something else is the challenge... --- Resolution of the encountered array element(s) is postponed until a non-simple-value-object-reference (variable) his hit or the array closes.

    PS: Did 'vote' on the ES6 wishlist. It is all very relative due to the nature of Espruino.

  • in JavaScript
    Avatar for allObjects

    I know that there is always hunger for every thing to be in Espruino... ;-)

    This multi-assignment / array and object destructuring assignment could give some space relieve for quite many things (the example though does not really portray that):

    >var a,b,c;
    =undefined
    >[a,b,c]=[1,2,3]
    Uncaught Error: Unable to assign value to non-reference Array
     at line 1 col 15
    [a,b,c]=[1,2,3]
                  ^
    >
    

    Would work for returns from functions as well:

    >var a,b,c;
    =undefined
    >var trippler = function(){ return [1,2,3]; }
    =function () { ... }
    >[a,b,c] = trippler();
    Uncaught Error: Unable to assign value to non-reference Array
     at line 1 col 20
    [a,b,c] = trippler();
                       ^
    >
    

    I 'expect' only the simple implementation(s)... even though sometimes nothing is better than not all...

  • in ESP32
    Avatar for allObjects

    Feels like a jitter to me, caused may be by auto-flipping pin modes...

    Try to set pin mode before using the pins...

    ESP826, ESP32 and the various STMs are all different hardware. The GPIO HW and how the are 'operated' have impact on Espruino behavior.

  • in ESP32
    Avatar for allObjects

    @Robin, I don't think so because it is calculating the values for each array element every time, even though it would need only to shift and only to calculate for the few new ones when also considering the modulus in the color sequence generation formula.

  • in ESP32
    Avatar for allObjects

    @sebafudi, since you just shift the pattern through the string, did you consider to just chop off the the falling off tuple(s) and calculate and append only the new ones?

  • in ESP8266
    Avatar for allObjects

    Reference http://www.espruino.com/Reference#l_Wifi­_connect mentions that options will have a way to pass expected ip address to use rather than dhcp... but as said: will - as future enhancement.

    On the other hand, your access point may have the option to not do dhcp at all or for not for particular MAC addresses and define the repsective ip to use. May be you can control it there.

  • in Interfacing
    Avatar for allObjects

    Great project. Surprised that the LDR is obviously fast enough because when discussing use of it in a different project - Help for Newbie. LED lights for game board , @DrAzzy deemed them too slow - see post #12. Of curse, the spacial setup controlling influence of ambient light plays a great role for the reliable working of LDRs.

    Unfortunately most of the US meters for water, electricity and gas don't have such 'close access' - with good ambient light control - to the LED, if they even have a LED. A focusing photo diode or transistor could be the answer there, or a cheap scanner that goes after the dial(s) or display.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for allObjects

    Kind of surprised that the timeout in line 19 has to be so long. Without logging I would expect that none should be needed, since ._sent() is a callback after all.

    I expect this to work:

    ,   _send: function(c) {
           kb.tap(kb.KEY[c],0,this._sent.bind(this)­);
        }
    
  • in Puck.js, Pixl.js and MDBT42
    Avatar for allObjects

    Look pretty internal to me... I tried to do the loop as close as possible, may be too close. Give this variation a shot:

    ,   _send: function(c) {
            console.log("About to send char",c);
            setTimeout(function(_){
                kb.tap(kb.KEY[c],0,_._sent.bind(_)); },1,this);
        }
    

    What it does: It decouples the sending form 'current JS thread'. @Gordon may know if this does matter or not regarding breaking the 'call-chain'.

Actions