-
Now test with this code :
function Test() { this.p1 = {x:0, y:80}; this.p2 = {x:240, y:80}; } Test.prototype.draw = _=> { g.clear(); g.drawLine(0,80,240,80); return true; }; var t= new Test(); if (t.draw()) { g.drawLine(0,160,240,160); }
It works in the emulator but not on Bangle, only the first line is drawn and an error message appear on console ( see screen copy )
I have tested on Pico with this similar code :
function Test() { this.p1 = {x:0, y:80}; this.p2 = {x:240, y:80}; } Test.prototype.draw = _=> { // g.clear(); // g.drawLine(0,80,240,80); console.log('line1'); return true; }; var t= new Test(); if (t.draw()) { // g.drawLine(0,160,240,160); console.log('line2'); }
same problem , with this message error :
| |_ ___ ___ _ ||___ ___
| |_ -| . | _| | | | | . |
||_| || |_|||_|_||_| espruino.com
2v04 (c) 2019 G.Williams
line1
Uncaught SyntaxError: BREAK statement outside of SWITCH, FOR or WHILE loop
at line 4 col 22
console.log('line1');return true;
^
in function "draw" called from line 7 col 10
if(t.draw()){console.log('line2');(test are made without minification)
Strange ! -
-
-
Good morning,
Look at this code, it draws 2 horizontal lines on the Bangle screen
function Test(){ this.p1 = {x:0, y:80}; this.p2 = {x:240, y:80}; } Test.prototype.draw = _=> { g.clear(); g.drawLine(0,80,240,80); }; var t= new Test(); t.draw(); g.drawLine(0,160,240,160);
When it is sent to the emulator, it works well.
When it is sent to the Bangle, it does not work properly, only the second line is drawn.
A dump to the console shows that the function draw() is not properly loadeddump()
function Test() {this.p1={x:0,y:80},this.p2={x:240,y:80};}
Test.prototype.draw = function (undefined) {return g.clear()};
var t = Object.create(Test["prototype"]);
t.p1 = { "x": 0, "y": 80 };
t.p2 = { "x": 240, "y": 80 };
E.setFlags({ "deepSleep": 0, "pretokenise": 1, "unsafeFlash": 0, "unsyncFiles": 0 });If I type this code in REPL mode with Bangle connected, it works well.
Where's the error ?
-
-
-
-
Here is the result of my tests with 2 IDEs: WEB IDE 0.72.1 and Espruino Native IDE 0.72.1
I use the same hardware based on PICO, with the following code:I2C3.setup({scl:A8, sda:B4, bitrate:100000}); const MPU = require("MPU6050").connect(I2C3); // 2nd parameter is the fifoRate. The DMP output frequency = 200Hz / (1 + fifoRate) const DMP = require("MPU6050_DMP").create(MPU, 3); function pidLoop(args) { var data = DMP.getData(); if(data !== undefined) console.log(DMP.getYawPitchRoll(data)); } setWatch(pidLoop, B5, { repeat:true, edge:'rising' });
We see:
1 - WEB IDE without Minification
An error LOW_MEMORY2 - Espruino Native IDE without Minification
No error, Upload ok, working ok3 - WEB IDE with Minification (Esprima Offline)
"TypeError" errors on MPU6050 module but not on MPU6050_DM module whose size is 31561 bytes
A syntax error ...4 - Espruino Native IDE with Minification (Esprima Offline)
No error, Upload ok, the size of the module MPU6050_DM = 17182 bytes
Operation ok
It's strange the modules do not have the same size.
Apparently the 2 IDEs do not use the same modules. -
Yes Pico (and EspruinoWifi) works when I use IDE Native 0.69.0 (and 0.72.1) to transfert code.
Its just longer , about 1 mn forthis code :I2C3.setup({scl:A8, sda:B4, bitrate:100000}); const MPU = require("MPU6050").connect(I2C3); // 2nd parameter is the fifoRate. The DMP output frequency = 200Hz / (1 + fifoRate) const DMP = require("MPU6050_DMP").create(MPU, 3); function pidLoop(args) { var data = DMP.getData(); if(data !== undefined) console.log(DMP.getYawPitchRoll(data)); } setWatch(pidLoop, B5, { repeat:true, edge:'rising' });
No I didn't use the option "Module uploaded as functions". The code is uploaded in RAM .
When I was doing tests with different IDE, I noticed some strange things. I'm going to synthesize all this in a new post.
-
-
Hi AkosLukacs,
Turn off minification only deletes the message :
TypeError: Cannot read property 'length' of undefined
I have Web Ide 0.72.1
I have also a Espruino IDE Native version 0.69.0 for my MDBT42Q Bluetooth Module.
I made tests with it on Pico this morning, and COOL ! It works fine ?There are some issues with Web Ide 0.72.1
-
Here's the dump()
dump() var mpu = undefined; I2C1.setup({"scl":B6,"sda":B7}); pinMode(B6, "af_opendrain", true); pinMode(B7, "af_opendrain", true);
=undefinedmpu
=undefinedI put the minification off (the second red error message disappears).
I controlled the wiring well.
I made tests with firmware 1.97, 2.00, 2.02 & 2.04, without success.
Attached a copy of the console -
-
Thank you Robin for your response.
Good test with the HR-SR04 module :
https://www.espruino.com/HC-SR04Bad test with MPU6050 module :
https://www.espruino.com/MPU6050I did tests on PICO and ESPRUINOWIFI with the same problem.
(screenshot of tests with ESPRUINOWIFI). -
Hello ,
when I save this code on my Pico or EspruiniWiFi :*I2C1.setup({scl:B8,sda:B9}); var mpu=require(MPU6050);*
the console return :
``` TypeError: Cannot read property 'length' of undefined in MPU6050
TypeError: Cannot read property 'length' of undefined____ _ | |_ ___ ___ _ ||___ ___ | |_ -| . | _| | | | | . | ||_| || |_|||_|_|
|_| espruino.com 2v00 (c) 2018 G.Williams
Uncaught SyntaxError: Got '=' expected ',' at line 263 col 65 ...ction(bank, prefetchEnabled=false, userBank=false) {
^ ```
I tried other module successfully.
Is the MPU6050 module a problem?
Am I missing something?Thank you for your help
@Robin :
Thanks for the advice, I will no longer use this writing for prototypes. The problem still persists with the conventional form.
I'm not used to Github, but I'll try to do it.
@Gordon :
I'm a little ashamed. I didn't uncheck all options.
Obviously, it works on all devices. This reassures me, thank you.