What command to use in Espruino instead of prompt from JavaScript ? #6190
Replies: 1 comment
-
Posted at 2019-09-18 by Robin Tue 2019.09.17
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?
What specific input is being suggested here? Would you elaborate @bigplik please. . . . Posted at 2019-09-18 by @gfwilliams If you are after something equivalent to http://forum.espruino.com/conversations/329366/ Posted at 2019-09-18 by @allObjects 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... ;-) Posted at 2019-09-18 by bigplik @allObjects yes this is what I am looking for Posted at 2019-09-18 by @fanoush 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. Posted at 2019-09-18 by @gfwilliams I can imagine being able to type something in code like 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 Posted at 2019-09-18 by @fanoush 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. Posted at 2019-09-19 by @gfwilliams
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
Yes, and you can do that right now :) You could also look at https://www.espruino.com/Web+Bluetooth+Dashboard Posted at 2019-09-19 by @fanoush 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? Posted at 2019-09-19 by bigplik
Yes, when I do something in JavaScript, I often check if this code is working also on Espruino ;) Posted at 2019-09-20 by @allObjects 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. Posted at 2019-09-23 by bigplik @allObjects could you drop some link about it? Posted at 2019-09-23 by Robin WebIDE >> Settings >> Testing >> check enable box Web link there also Posted at 2019-09-23 by bigplik thank you |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2019-09-17 by bigplik
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.
Beta Was this translation helpful? Give feedback.
All reactions