Mostlikely, your modules has some initialization that has to happen... and you try not to save active things (intervals, timeouts, watches, etc, even though @Gordon did a great job to restore them as good as possible). I'm also a bit puzzled about your use of const and var for the very same thing...
Place 'all active stuff' into a onInit() function - ESPECIALLY with Save on send setting and to avoid (heavy) things getting off on upload (starting heavy things on upload and writing to console in upload - level 0 / directly executed code messes even with the upload to not complete it or preventing Espruino to detect completion of upload. --- I expect this to solve the issues):
I2C1.setup({scl:D2, sda:D1, bitrate:100000});
var MPU, DMOP, iId;
function getData() {
var data = DMP.getData();
if(data !== undefined) console.log(data);
}
onInit() {
MPU = require("MPU6050").connect(I2C1);
DMP = require("MPU6050_DMP").create(MPU,3);
iId = setInterval(getData, 1000);
}
You may also be fine with:
I2C1.setup({scl:D2, sda:D1, bitrate:100000});
var mpu, mpuM = require("MPU6050")
, dmp, dmpM = require("MPU6050_DMP")
, iId;
function getData() {
var data = dmp.getData();
if(data !== undefined) console.log(data);
}
onInit() {
mpu = mpuM.connect(I2C1);
dmp = dmpM.create(mpu,3);
iId = setInterval(getData, 1000);
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Mostlikely, your modules has some initialization that has to happen... and you try not to save active things (intervals, timeouts, watches, etc, even though @Gordon did a great job to restore them as good as possible). I'm also a bit puzzled about your use of const and var for the very same thing...
Place 'all active stuff' into a onInit() function - ESPECIALLY with Save on send setting and to avoid (heavy) things getting off on upload (starting heavy things on upload and writing to console in upload - level 0 / directly executed code messes even with the upload to not complete it or preventing Espruino to detect completion of upload. --- I expect this to solve the issues):
You may also be fine with: