Avatar for allObjects

allObjects

Member since Jul 2014 • Last active Jun 2019

Espruino makes IoT as easy as 123!

Most recent activity

  • in General
    Avatar for allObjects

    @barry_b_benson, take a look at this pub https://pub.tik.ee.ethz.ch/students/2013­-FS/GA-2013-03.pdf - also attached as pdf.

    What I notice is that many clap switches need two claps for one toggle. All switches use some kind of amplifier to create a sufficient voltage top get digital electronics triggered... (as @Robin points out). Attached schema seems quite simple - 3 resistors, 1 capacitor and a single transistor. The reference is found in the initial pub in the literature summary, and is http://embedded-lab.com/blog/making-a-si­mple-clap-switch/

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

    From 1.88 to 2.03 is not possible. You need to first upgrade to 1.95 and then 2.03.

    ...surprise to me... I see nothing mentioned in http://www.espruino.com/Puck.js#firmware­-updates

    So it must be that before attempting to update directly to 2.03 from 1.88, some application residuals have been left over... Did you do a reset(1) before attempting? But I'm almost certain that not even that is needed.

  • in ESP8266
    Avatar for allObjects

    @maze1980, yes, I would like to have blocklies with these names. Of course, they will use setTimeout() and setInterval(), and furthermore, return the handle, so they can be canceled: cancel(handle)... another blockly... and the wait I would retire, because it conveys the wrong concept: Scheduling is not waiting... but I see your point that "After n seconds do" and "Every n seconds do" already do that... missed it. The only thing they are missing is to be able to store the handle... and there is no cancel to use the handle... Introducing the concept of scheduling makes cancel understandable...

  • in ESP8266
    Avatar for allObjects

    This is a different wording of the facts @AkosLukacs points out in post #7.

    The problem is that blockly does not think event driven. Javascript is a single threaded executed... and wait - by constantly checking time until time arrives - just cannot exist in such an environment, and - worse - in Espruino, it hogs the processor until 'snippet' is completed. Never ever implement something like in second code block of #1 post. Even the while loop hogs the processor... it comes from the outdated main loop concept (erroneous reestablished and 'hardened' in the public mind by Arduino - so retro), a concept that was introduced in machine control with digital logic a good 50 years ago... derived from / emulating the even much older electro mechanical 'Schrittschaltwerk' - automatic stepping mechanism. The automatic stepping mechanism is a list of unconditioned and conditioned steps that are executed one after the other over and over again. It is easy to understand but extremely limited...

    (If you are using ESP8266, your processor reboots constantly... because the Wifi stack on it has an interrupt cycle of a given number of micro seconds to take care of urgent communication work, and when it does not get the control of the processor, it resets itself. This means in other words that the javascript executed on an even can only take so much that it still fits into this interrupt cycle window... From the total processor time only a percentage is available to other code / application code / Espruino code, and this code has to finish within a given number of microseconds. The other percentage is used by the Wifi stack).

    What actually happens in the blockly code is the following:

    • create the while loop with true executing this code:
      • crate an entry in the 'time table' - so to speak - that after 1 second execute the following code:
        • turn the led off
        • create an entry in the time table hat after 1 second executed the following code:
          • nothing

    Creating the entry in the time table takes practically no time -returns immediately - to executed next statement, and now y0u understand that the code creates tons of execution deferred pieces of code... until it rans out of space in the time table... (paraphrased), and never ever even 'gets the time' to work on these scheduled blocks of code...

    SetInterval and SetTimeout is not a waiting kind of thing but a scheduling thing scheduling a piece of code to be executed at scheduled time (now plus delay), is executed immediately with control returning immediately.

    Try something like that in blockly:

    • create a boolean variable b that you set to true.
    • create a function f that includes the following:
      • wait (blockly's incorrect notion of schedule following code to be executed after wait time
      • turn the led on / off
      • if query the boolean variable b, and if true:
        • invoke 'yourself' - the function f
    • invoke the function f - to get it all started

    Invoking the function f you even can - should - do with a wait, because you want to let the upload finish - because it is also a Javascript snippet(s) execution.

    • create a boolean variable b that you set to true.
    • create a function f that includes the following:
      • wait (blockly's incorrect notion of schedule following code to be executed after given time)
      • turn the led on / off
      • if query the boolean variable b, and if true:
        • invoke 'yourself' - the function f
    • wait (blockly's incorrect notion of schedule following code to be executed after given time)
    • invoke the function f - to get it all started (after upload completed)

    The sequence you create this logic in blockly is to create the function first, and then the other code:

    • create a function f - a named block of code - that includes the following:

      • wait (blockly's incorrect notion of schedule following code to be executed after given time)
      • turn the led on / off
      • if query the boolean variable b, and if true:
        • invoke 'yourself' - the function f

    • create a boolean variable b that you set to true.

    • wait (blockly's incorrect notion of schedule following code to be executed after given time)

    • invoke the function f - to get it all started (after upload completed)

    I'm sure you have some other logic that controls boolean variable b and as well some variable code that determines whether the led should be turned on or off...

    @Gordon, I guess it is time to thing of something more Espruino / JS / Event driven and 'ban' the (inferior and in reality never used concept of) wait (by killing processor cycles by just looping around and checking time)... for examle: scheduleOnce and scheduleRepeated as an (right hand) expression returning the handle and with the look of the while/for loop or if/else to make clear the block structure. (Something on your already tall pile... may be there are takers in the forum...). I wanted to use blockly in its current from, but it got so cumbersome that learning JS and coding in a language in text from is what just works better.

  • in General
    Avatar for allObjects

    Yes, could be an option. On the other hand, I have more the feeling that somehow the AD converter gets started but is not stopped or some other things like counters, muxes, etc. are running or set and keep drawing power because they are not reset. --- I have no clue what I'm talking about, but trying to understand hardware as can be seen at http://www.espruino.com/STM32+Peripheral­s makes me fish in that murky pond... I know that an NRF52 is not and STM32, but I expect similar 'intestines'; they are both ARMs after all.

  • in General
    Avatar for allObjects

    @Ollie, thanks for catching... great implementation, @Will. - That conversation slipped my watching eyes... or factual: ...sleepy eyes. :/

  • in General
    Avatar for allObjects

    @gl5, do not exactly understand what you are looking for... It all depends on your setup. From the example I take that you use your local / home Wifi network and that's where your Espruiono hooks onto and you also connect with you computer/tabled or phone to that Wifi network, from which Espruino Wifi connection gets its ip, the ip you have to enter into the browser on your computer /tablet or phone.

    You could go in a different way and start Espruino as access point first with its own SSID and password - like another Wifi network - its own. After connecting with your your computer /tablet or phone to that Espruino Wifi network, you would serve a (secure - SSL) page that asks for a the SSID and password of you home network, and Espruino would then stop its access point and connect to your local / home Wifi network - as it does now. If user id and password would fail, Espruino would return back as access point with its own SSID and password and you would have to start over.

    One challenge though still remains: you have to have Espruino's IP address so you can connect... (you can look it up on your modem/router). Since the IP address may change - it is DHCP after all - you may give your Wifi node a host name, and you would connect with that name instead of the IP - see http://www.espruino.com/Reference#t_l_Wi­fi_setHostname

  • in Other Boards
    Avatar for allObjects

    ESP8266 modules like to have a decent capacitor across GND and 3.3V as close as possible to catch power demand spikes, even with sufficient power supply for the average use. See post with picture in this conversation.

Actions