First experience on STM32F4Discovery

Posted on
  • Waiting for espruinos, I decoded to start first test on STM32F4Discovery.
    I had to spend some time get it running, as usualthe problem was in front of the keyboard.
    Anyway, these times are gone.
    First start was done with Chrome based IDE. A simple blinking started soon, perfect.
    Problem I found was the CPU load.
    Connecting to the COM-Port eats CPU like crazy.
    Usually Chrome takes 40%, on my AMD quad core with windows 64 and 8GB.
    Therefore a search started to compare against a simple terminal:
    Putty and others refused to connect to COM port, at the end I got Tera Term running.
    BTW, it does not take any remarkable power, so chrome does something strange.

    Next step was to write some short snippets.
    At that time I missed the IDE, so why not write my own ?
    Codemirror is a beautiful starting point, and together with some additional lines, a very, very, very first editor was born. http://www.jumware.com/espruino/espruino.html. Testing ran on FireFox only.
    Added are options to

    • load code from espruino Github
    • load examples from Github
    • load some first snippets
    • minify the code using Google closure compiler
      During testing I found that:
    • console.log takes logs one parameter only
    • arguments keyword is not supported
    • lint finds a lot of minor problems like missing ";"
    • binary format is often unknown in the big world of javascript
    • minify seems to work fine with WHITESPACE ONLY
    • minify my snippet for stepper with SIMPLE_OPTGIMIZATION does not work on Espruino. Syntax looks very strange to me, but all browsers took it.
    • example for stepper does not work with Microstepping, I had to use a different port. Espruino gave helpful error message. Somewhere in the background Espruino seems to have helpful information about ports.

    There are some COM-Plugins in the big wide world for Firefox, but I did not get any of them running. Copy & Paste was my solution to this problem. Hopefully the WebSerial API group, mentioned by Florian Bender will be succesful soon.
    Anyway, I would like to add some more functions to the editor. One is to give some help to select a board and get informations to choose available pins.
    There is a lot of information available in Espruino GitHub. My problem is 1st to understand and 2nd to download, since this would be a cross-Domain call. Easy solution (at least for me) would be a JSON file.
    As soon as I get more devices running more snippets will be added.

  • Hi,

    Thanks! This looks really interesting. I love the underlining and code completion.

    Chrome does seem to have some issues with CPU load for Serial ports (but only when connected). Even if this can't be sorted, the Web IDE could be modified to connect, write code, then disconnect, all in one go.

    The Web IDE already uses CodeMirror - rather than making your own Web IDE so that we have two competing ones, do you think you might be able to improve the existing one? https://github.com/espruino/EspruinoWebIDE

    I think it could be modified quite easily so that it would work inside a normal web browser too (without needing to be a Chrome Web App).

    • console.log takes logs one parameter only: This should be fixed in 'nightly' builds: https://espruino-nightly.noda.se/
    • arguments keyword is not supported: again, fixed already :)
    • lint finds a lot of minor problems like missing ";": Finding problems where? in the 'code' folder, or elsewhere? The 'code' folder was really just a dumping ground for random bits of JavaScript (mainly for me) so it's very likely there are huge issues in it
    • binary format is often unknown in the big world of javascript: Yes - this was added because it's just really handy for embedded software. I wonder if jslint could be modified to accept it as valid?
    • minify my snippet for stepper with SIMPLE_OPTGIMIZATION does not work on Espruino. Syntax looks very strange to me, but all browsers took it. Just looked at this and there are at least two issues that I have filed bugs for
    • example for stepper does not work with Microstepping, I had to use a different port. Espruino gave helpful error message. Somewhere in the background Espruino seems to have helpful information about ports. Yes, it knows what pins can do what. If you look at scripts/build_board_docs.py (which builds http://www.espruino.com/ReferenceSTM32F4DISCOVERY) you can get an idea of the data that is available. You could even add print(json.dumps(pins)) to dump everything to JSON

    Potentially I could dump that information to JSON files on the Espruino site. Note that for code competion/documentation there is already: http://www.espruino.com/js/keywords.js

    I notice you link to the files on EspruinoDocs. Did you know that these are used to generate pages on the Espruino site? For instance https://github.com/espruino/EspruinoDocs/blob/master/devices/Stepper%20Motors.md -> http://www.espruino.com/Stepper+Motors

    As well as build_board_docs.py, there's also build_docs.py which builds the whole Reference document up. This could export to JSON quite easily as well - and I wonder if the code completion could be extended with all the built-in functionality.

  • Hello Gordon,
    thanks for the detailled feedback. I did not check the changes you mentioned yet, but I followed your suggestion to add functions to your WEB IDE.
    There is a download for testing available at http://www.jumware.com/espruino/webapp/EspruinoWebIDE.zip
    Changes, you can find them by searching for comment with "juergen" in.

    1. added buttons for scripts, snippets and tutorials in main.html. All open a short form with a selectbox and a checkbox to switch between replace and append.
    2. added initialization of new buttons in terminal.js
    3. added a lot of plugins for codemirror in main.html
    4. added initialization for extensions in terminal.js
    5. added additional javascript to handle new buttons
    6. added a minify button in main.html. Opens a short form with selectbox for type of minify, a checkbox for sending directly to device, and a button to start minify
      I would like any feedback. If this is helpful, feel free to do whatever you want withit.
      Now lets go through other items:
    7. I would not automate connecting/disconnecting to COM. I like to send infos to console during debugging, which would not appear anymore. I would prefer to switch this manually.
    8. the "problems" found by lint are not important, missing semicolon or spaces at the end. Don't waste any time on that.
    9. binary format is not only a problem of lint, its also a problem for minify. As soon as more browser will support this, the problem will disappear sooner or later. Please take it as a hint only.
    10. extensions for code completing and for lint to match functions and syntax fo Espruino is a good direction. Right now my lack of knowledge is the main hurdle doing this.
    11. I am not familiar with python, therefore I would like to wait for you wasting some time for creating JSON files ;-)
      regards from Krefeld(Germany about 12 degrees celsius and rainy)
      Juergen
  • I tried to interprete Boards and Pins files in javascript.
    Its a new button in WEB IDE, which

    1. opens a selectbox for boards
    2. reads board-info
    3. reads pins-info according to that
    4. creates groups of devices
    5. adds a selectbox for groups of devices
    6. selecting an item opens a tooltip

    There are more options than on Espruino homepage.
    I checked STM32F4Discovery and found CAN and SD ports.
    On some pins I found more devices (e.g. PC10,PC11 are uart and usart)
    Any idea what I forgot to check ?

  • Hi JumJum,

    Thanks - this is really awesome! I've hacked around with jslint (js/codemirror/addon/jshint/jshint.js) so that it now allows binary numbers, and have uploaded it to:

    https://github.com/espruino/EspruinoWebIDE/tree/jumjum

    If you use git then you might find it easier to keep track of changes. I'll try and get your changes into a 'proper' release when I get a few free moments - and I'll see if I can dump out the documentation in json format too (but that might be a way off!).

    At the moment, I think having the buttons to select different bits of code (while cool) is a bit daunting to new users. I think maybe I should have a directory in EspruinoDocs called 'examples' which contains properly curated bits of example code (the stuff in 'code' is a mess and was basically only for my own testing :)

    I'm loving the minify + send to Espruino. It works amazingly well - it's staggering what 'advanced' does to your Blinker snippet! Perhaps a simple regular expression replace (something like /0b([01]+)/parseInt("\1")/) could be applied before sending the code to minify to fix the binary number issue. I should just change the example code though :)

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

First experience on STM32F4Discovery

Posted by Avatar for JumJum @JumJum

Actions