• Hi, I appreciate some information how to get prompt window when working with espruino by the console.
    In JS is possible to write some input using prompt, would like to use it in espruino too.

  • Tue 2019.09.17

    re: 'how to get prompt window when working with espruino by the console'

    Are you asking how to create a modal dialog for user input when using the Espruino WebIDE Left-Hand console to enter Javascript commands?

    As a suggestion, what about a menu based list with a single key press input?

    'write some input using prompt'

    What specific input is being suggested here?

    Would you elaborate @bigplik please. . . .

  • If you are after something equivalent to window.prompt then there isn't anything built in to Espruino at the moment, however you might find this forum post does what you want:

    http://forum.espruino.com/conversations/329366/

  • Are you asking for something like:

    When Espruino board is connected to Espruino Web IDE and sending something to console, the IDE should open a prompt so you can enter some data that then is read by Espruino board and processed?

    If that is so, you would have to customize the Espruino Web IDE - which, of course - written in JavaScript. @JumJum's Testing module is already doing something like that: capturing information that Espruino is sending to the IDE (console).

    You get the Espruino Web IDE source onto your computer and load it from there instead of from Web. Then you begin to modify the code until it does what you want... ;-)

  • @allObjects yes this is what I am looking for

  • Interesting. So you would expect it to work only if WebIDE is connected to the device? This is just for prototyping and debugging? And if you disconnect IDE you don't expect to have any alternative for the input?

    It could work i similar way like the Graphics.dump() so that it could print some specific stuff to output that WebIDE would act upon and present a dialog and then trigger callback with the result via pasting some code into console (like e.g. setTimeout(callback,10)).

    Maybe even some generic way that would call into WebIDE browser runtime so you could really call the real window.prompt() yourself and get the result via some callback.

  • I can imagine being able to type something in code like WEBIDE_PROMPT('What's your name?') and having the IDE process that and pop up a window at upload-time.

    That'd get really tiring after the 3rd time though :)

    The other thing is there's Web Bluetooth (or Web Serial in 'beta' Chrome builds). If you want something custom that asks the user for info at upload time then you could use that, and get something that looks really good.

    I actually have a Web Serial+Bluetooth version of the puck.js Web Bluetooth library that makes the whole process much easier. If there's demand for that I can polish it and release it sooner rather than later...

  • Oh so you already have something similar for the puck.js that would interact with web page and WebIDE could be such web page too?

    Oh what an interesting concept in general. So I could e.g. have page on the web that would easily work as a frontend to my espruino based smart watch so I could e.g. set time or alarms or change watch face from my computer via the page instead of using the phone.

  • Oh so you already have something similar for the puck.js

    Yes, totally - for example: https://www.espruino.com/Web+Bluetooth

    So something like this is totally valid to do right now on a Bluetooth device:

    <html>
     <head>
     </head>
     <body>
      <script src="https://www.puck-js.com/puck.js"></script>
      <script>
    function ask() {
      var n = window.query("What's your name?");
      Puck.write('NAME='+JSON.stringify(name)+';\n');
    }
      </script>
      <button onclick="ask();">go()</button>
     </body>
    </html>
    

    And with Web Serial and the new library it'll be the same, just with some name other than Puck.

    So I could e.g. have page on the web that would easily work as a frontend to my espruino based smart watch

    Yes, and you can do that right now :) You could also look at https://www.espruino.com/Web+Bluetooth+Dashboard

  • Wow, great. So does it make sense to integrate it into WebIDE so you could reuse same connection and develop/debug such web page together with the code? Or maybe even just provide UI for prototyping like asked in this topic? Maybe the testing plugin is something similar?

  • So you would expect it to work only if WebIDE is connected to the
    device? This is just for prototyping and debugging?

    Yes, when I do something in JavaScript, I often check if this code is working also on Espruino ;)

  • Take a look at the Testing feature within Espruino IDE... it is by default disabled. Enable it, watch some youtube movies about it. @JumJum has contributed that... it is a very cool thing... I'd call the feature more a Monitor when connected that also can be used for testing. It writes even logs if you wish to have it do.

  • @allObjects could you drop some link about it?

  • WebIDE >> Settings >> Testing >> check enable box

    Web link there also

  • thank you

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

What command to use in Espruino instead of prompt from JavaScript ?

Posted by Avatar for bigplik @bigplik

Actions