-
closure with simple optimizations gives
No errors in https://raw.githubusercontent.com/espruino/EspruinoDocs/master/devices/MPU6050_DMP.js. Minifying 34114 bytes to 8589 bytes No errors. Minified 14282 bytes to 13871 bytes. > ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v06 (c) 2019 G.Williams >Execution Interrupted New interpreter error: LOW_MEMORY,MEMORY >
-
Here's the code I'm using btw (the same as in the docs, just the I2C options and trigger changed)
I2C1.setup({scl:A5, sda:A4}); const MPU = require("MPU6050").connect(I2C1); // 2nd parameter is the fifoRate. The DMP output frequency = 200Hz / (1 + fifoRate) const DMP = require("https://raw.githubusercontent.com/espruino/EspruinoDocs/master/devices/MPU6050_DMP.js").create(MPU, 3); function pidLoop(args) { var data = DMP.getData(); if(data !== undefined) console.log(DMP.getYawPitchRoll(data)); } setWatch(pidLoop, D13, { repeat:true, edge:'rising' });
-
Ah the heatshrink technique is nice! :)
I'm still getting memory issues though.
>reset() =undefined ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v06 (c) 2019 G.Williams No errors in https://raw.githubusercontent.com/espruino/EspruinoDocs/master/devices/MPU6050_DMP.js. Minified 34114 bytes to 9872 bytes. No errors. Minified 15565 bytes to 15435 bytes. > ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v06 (c) 2019 G.Williams >Uncaught SyntaxError: Got EOF expected '}' at line 1 col 13307 ...etMemoryBank(b),this.setMem ^ Execution Interrupted New interpreter error: LOW_MEMORY,MEMORY >
and that's with the minification options Esprima(offline) for both modules and editor.
Enabling mangling gives me:
No errors in https://raw.githubusercontent.com/espruino/EspruinoDocs/master/devices/MPU6050_DMP.js. Minified 34114 bytes to 8640 bytes. No errors. Minified 14333 bytes to 13937 bytes. > ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v06 (c) 2019 G.Williams >Uncaught Error: Function "setClockSource" not found! at line 1 col 6 this.setClockSource(b.CLOCK_PLL_XGYRO),this.setFullScaleAcce... ^ in function "initialize" called from line 1 col 103 ...AD0_HIGH:a,this.initialize() ^ in function "a" called from line 1 col 10 new a(b,c) ^ in function "connect" called from line 1 col 13768 ...ire('MPU6050').connect(I2C1);const DMP=require('https://raw.... ^ New interpreter error: LOW_MEMORY,MEMORY
and turning on pretokenise:
No errors in https://raw.githubusercontent.com/espruino/EspruinoDocs/master/devices/MPU6050_DMP.js. Minified 34114 bytes to 8640 bytes. Error parsing JavaScript, but uploading anyway. SyntaxError: Unexpected token (1:126) Error: Line 1: Unexpected token { >
I'll try playing around with the closure minifiers as well
-
Hm I might be conflating RAM and Flash here. I'm guessing that variables would be related to RAM and the firmware size would be related to Flash.
And I'm guessing if I can somehow get the constants in that library be a lookup table located in storage, I should be able to free up more memory for actual code.
-
I'm trying to get https://www.espruino.com/MPU6050 working on my Pixl.js and I'm running into memory issues when doing the MPU6050_DMP example. Looking at https://www.espruino.com/modules/MPU6050_DMP.js and the minified version https://www.espruino.com/modules/MPU6050_DMP.min.js it seems that I'll need to cut down on the unnecessary libraries included in the firmware.
I've removed many of the libraries and only left BLUETOOTH and PIXLJS and have reduced the size of the DFU zip to just 312k but it looks like I also would need to adjust the
variables
section to actually make use of the freed space.How do I calculate the actual amount of variables I can set?
process.memory()
gives me this:>process.memory() ={ free: 1733, usage: 767, total: 2500, history: 8, gc: 0, gctime: 4.30297851562, blocksize: 16, "stackEndAddress": 536929600, flash_start: 0, "flash_binary_end": 444468, "flash_code_start": 446464, flash_length: 524288 }
so does that mean 524288 - 446464 = 77824 variables I can use for the
variables
section? (it was originally set to 2500) or should I just do a trial and error to find the thresholds? -
I think @AkosLukacs had a small project http://forum.espruino.com/conversations/339259/ that streamed energy usage of a device, maybe you can try it for the bangle?
-
-
They did, but I was powering off the breakout via the other vin pins as that would suit the design better (off to the side rather than at the top so it's lower profile) and I ran out of the female connector, which then set off the accident :D
Thanks for the link, I might be able to get a bunch via digikey or the local element14 :) If they really do break first on reverse polarity, that could be a cheap extra way to protect the more important and expensive portions of the circuit! :)
-
Found the datasheet as well https://my.mouser.com/datasheet/2/268/22049a-51817.pdf and I'm guessing the package on the breakout is 3-Pin SOT-23A
Nice to know about this regulator, didn't know about it before :)
-
I think I found something here: http://forum.espruino.com/comments/14796787/ the MCP1703T
Now I just need to find out where it is :D
-
It finally happened, I've accidentally plugged in the lipo connector backwards on the breakout. At first I thought the whole board died, but it looked like the regulator failed before reaching the chip itself, and so powering the breakout via the 3.3v pins still work.
For now I need to design in an external 3.3v regulator for my projects, but I was just wondering if I can replace the regulator myself? I looked at the pdf schematics but I can't seem to find where the regulator is, and I have no experience with eagle files.
I've also tried searching the forum to find out what kind of regulator it is and I couldn't seem to find any info on that.
-
I was trying out the i2cdetect script by @MaBe by using:
I2C1.setup({sda: SDA, scl: SCL})
and I was wondering why none of my I2C devices were being detected when I used the very same Pixl.js to develop the INA219 module.Then I copied the example code I used for that module which had this setup:
I2C1.setup({ sda: A4, scl: A5 });
I thought the
SCL
andSDA
constants were pointing to the wrong pins, and it looks like they are:| __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v06 (c) 2019 G.Williams >process.env ={ VERSION: "2v06", GIT_COMMIT: "21168a2b", BOARD: "PIXLJS", FLASH: 524288, STORAGE: 36864, RAM: 65536, SERIAL: "e29d7f50-21853912", CONSOLE: "Bluetooth", MODULES: "Flash,Storage,hea" ... "el,graphical_menu", EXPTR: 536882640 } >SDA =D4 >SCL =D5
D4
andD5
on the Pixl.js are digital pins. -
-
-
However, enabling the
Pretokenise code before upload (BETA)
option in minification gives a red toast message saying:Error parsing JavaScript, but uploading anyway. SyntaxError: Unexpected token (1:127) Error: Line 1: Unexpected token {
I'm not sure if being able to be pretokenised is a requirement for getting a module merged though. If so, I'd appreciate any hints on how to debug them (as copy-pasting the code on to the IDE seems to work just fine and I'm unable to reproduce the error)
-
-
I probably need help in fully converting this into a module.
Copy pasting into the left hand side as suggested in https://www.espruino.com/Writing+Modules works and I'm able to get the sample code working.
However, doing a
const ina219 = require("https://raw.githubusercontent.com/parasquid/EspruinoDocs/master/devices/INA219.js").connect(I2C1);
gives some tokenization errors depending on whether or not I have minification turned on.
Disabling all options for minification now gives me
Uncaught Error: Function "getBusRaw" not found! at line 1 col 25 const busVoltage = this.getBusRaw(); ^ in function "getBusMilliVolts" called from line 158 col 37 console.log(ina219.getBusMilliVolts() / 1000 + 'V'); ^
I'm not really sure where I'm tripping up :(
-
I had a small project in Arduino that used the INA219 and I thought I'd port it over to Espruino so I can more easily to prototype development.
I found that while there is a module for the INA226 there isn't for the INA219 so I thought I'd take a stab at making a module for it: https://github.com/espruino/EspruinoDocs/pull/562
It's my first time contributing an actual module to Espruino, so feedback would be greatly appreciated :)
Also big thanks to Ákos Lukács who apparently made the INA226 from which I took major inspiration from :)
-
I'm guessing because the battery widgets are calling https://www.espruino.com/Reference#l_E_getBattery
E.getBattery()
which returns the battery voltage.However, li-ion charging works in a two-phase process: constant current, and then constant voltage. It will try to start charging the battery until it reaches 4.2v and then stay charging at 4.2v while the charge current trickles down.
This is probably the reason why the watch may say 100% (which means the battery is at 4.2v) but can still continue charging as the second phase of the charge cycle isn't done yet.
-
-
I charged my M5StickC to full and flashed a blinky sketch. It's been working just fine (including console log of the time) for hours now.
Have you tried charging yours fully?
It would be nice to get some bindings with the AXP192 though, as it also controls the backlight of the LCD :P It's using the st7735 but without the backlight getting power, we can't see anything on the screen (or at least that's what I think; maybe I'm just using the lcd wrong).
Would also be nice if we can somehow get something like https://www.espruino.com/Reference#l_NRF_getBattery working through the power management chip :P
-
I charged the M5StickC overnight and ran the AXP192 sample sketch throughout. When the voltage reached around 4v I flashed Espruino and ran the blinky sketch. When I first ran the AXP182 sample sketch, I saw that the battery voltage was just around 3v.
It looks like things are stable now, so maybe it could be because Espruino was trying to use too much power that the power management IC tried to restart the mcu?
-
I've just flashed the same binary to my m5 atom matrix https://docs.m5stack.com/#/en/core/atom_matrix which also has a pico-d4 but this one is stable and has been running the neopixel code https://www.espruino.com/WS2811#software for about 10 minutes now.
I'm not sure what the difference between the two are, except that one has a battery and the other doesn't. For what it's worth, here's the product link for the m5stickc: https://docs.m5stack.com/#/en/core/m5stickc
-
setting both editor and module to closure simple optimizations works!
I guess it just barely gets it.
However, I'm planning to use this to stream accelerometer data over BLE so I'm afraid even if the example works, adding more of my own code might take me over the memory limit :(
I'll see what I can do in the meantime :) Thanks!