You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • Got called to special home cooked lunch... that's about the only thing that creates an interrupt of higher priority... ;)... back to business.

    Developing with Espruino the way you do in a browser gets you straight into out-of-memory hell... or, what happened to me using the module folder with google closure compiler service 'too many compiles'.

    There are several ways code can be loaded to Espruino: either direct in code or as module using require. With require you stick your code as a module into the modules folder as definable in the Web IDE. The advantage there is that code is (more) optimized when uploaded and uses much less memory... Also Espruino is different from any other JS virtual machine (VM) runtime environment in the way that it runs of the source: there is no Just In Time compilation into some internal VM (byte) code for execution... (therefore keep comments outside of functions... i like inline comments..., makes the code meta-readable). Anyway.

    I would not make to much changes in your code... I would think of the canvas / context as a facade/adapter of either Espruino's Graphic library or as the controller board you intend to by by. I do not know which hardware you already have... Display? Controler? I'm sure though you have an Espruino 1.3b or 1.4 board that you run with Espruino 1v71 firmware, do you?

    In the development process you start with the code in the Web IDE editor emulating a module and with very small buffers - just to get the algorithms going - and then, when it runs satisfactorily, you put it as module into the module folder and use the full buffers. This way you can develop and test nicely, and later run optimally in speed and as much application data memory as possible.

    Btw, have you ever heard of require.js? It is a way of develop javascript application in a similar modular way with dependencies as java or c/c++. What language other than javascript are you familiar with?

    Since we do not have an html page in Espruino, we quasi emulate the html page... I run the code from your ip address and looked at the html document. It is very simple: it is a single DOM node with the id canvas in which you create the canvas objects and... In the end you will will have exactly the same js files that you have now as modules and you load them with

    instead of 
    

    <srcipt src="scriptFile.js"...```
    (moduleName == scriptFile).

    To emulate the DOM / document and Canvas, you crate two extra modules where you stick the objects and methods into so you can run exactly the same code that you run in the browser.

    As a first step, we have you get going on require.js... to load your js files with require. Then we
    run it in the browser and do step by step develop the facade/adapter to the hardware you already
    have.

About

Avatar for allObjects @allObjects started