innovationOUtside / nbev3devsim

Ev3DevSim ipywidget in Jupyter notebooks
Apache License 2.0
5 stars 0 forks source link

Improve semantics of data logging #32

Open psychemedia opened 4 years ago

psychemedia commented 4 years ago

At the moment the data logging and charting is handled by using a print() statement to print sensor log values to the the display window using statements of the form print('Light_left: ' + str(colorLeft.reflected_light_intensity)).

These values are then used to update:

It might be more convenient to define a Skulpt function that we can use to log sensors rather more formally and naturally. For example, in something like a Skulpt src/lib/simlogger.js. Does the following provide a start? (I'm not sure how best to define either the py interface, or the Javascript function that handles it.)



function datalog (channel, obj) {
    //obj.$jsstr()
    //???
  }

var $builtinmodule = function(name)
{
    var mod = {};

    mod.datalog = new Sk.builtin.func(function(channel, obj){
        datalog(channel, obj);
        return new Sk.builtin.none;
    })

    return mod;
}

//from simlogger import datalog
//Maybe something like:
//datalog("left_light", colorLeft.reflected_light_intensity)