user157902
Member since Apr 2024 • Last active Apr 2024Most recent activity
-
Thank you for the ideas, Gordon! :-)
I actually looked into the minified file fist, but found the renamed functions rather confusing. Checking out the map file attached didn't make this smoother, at least not at first glance.
I also searched for "semi-minified" options, to minify but keep function names, but could not find such a tool yet.
-
- 8 comments
- 616 views
-
Hi Gordon, thanks a lot! I will work through the examples. :-)
Just for understanding: How would I disable the built-in Tensorflow module, if it becomes necessary?
Running only the DSP code (and using Espruino's built-in Tensorflow module) would be an option that I would also prefer. However, the DSP code from EI uses libraries, partly with C++. I could not figure out yet if it would be possible to "inline" lenghty C/C++ code into Espruino and if Espruino compiler can compile C++ code, too? Maybe merge the code from EI into one file beforehand (as per https://www.reddit.com/r/cpp/comments/j2hg59/tool_to_merge_multiple_cc_files_into_a_single/ )?
-
Thank you, that worked really well! 🙂
In case anybody else is looking for it, here is what I did:
- Download UMD file for the npm module in question. E.g. https://cdn.jsdelivr.net/npm/discrete-wavelets@5/dist/discrete-wavelets.umd.js
- (I learnt: UMD = Universal Module Definition, patterns for JavaScript modules that work everywhere.)
- For testing, store this file in Flash on the watch in Device Storage, using the Web IDE.
- In Web IDE, create a sample code file to the right, referencing this module file and using its functionality. Run that.
Example for the above module:
// Upload discrete-wavelets.umd.js to Bangle local storage Number.isInteger = it => isFinite(it) && Math.floor(it) === it; // To replace missing Number class in Espruino var wt = require("discrete-wavelets.umd.js"); // load from local storage var coeffs = wt.dwt([1, 2, 3, 4], 'haar'); console.log(coeffs); // expected output: Array [[2.1213203435596425, 4.9497474683058326], [-0.7071067811865475, -0.7071067811865475]]
When using the library with a real-world sample of 250 values (not just [1,2,3,4]), I seem to get a timeout problem ("Prompt not detected - upload failed"). But I look into solving this using the advice from https://forum.espruino.com/conversations/289212/ .
- Download UMD file for the npm module in question. E.g. https://cdn.jsdelivr.net/npm/discrete-wavelets@5/dist/discrete-wavelets.umd.js
-
I think I found what you meant. The npm website for the package mentions a CDN option (https://cdn.jsdelivr.net/npm/discrete-wavelets@5/dist/discrete-wavelets.umd.min.js) which seems to be the minified, single-file version of that module. :-)
I will try to get this running as described by you.
-
Thanks a lot!
How would I find "the unified version" and which CDN would I use? Also, how would I fetch the library as a single JS file? Sorry, I am a bit of a newbie with this ...
I noticed that my library in question (https://www.npmjs.com/package/discrete-wavelets) also contains TS code. In another post (https://forum.espruino.com/conversations/341987/) it was mentioned that TS needs to be built/compiled before uploading it to Bangle. I am wondering what would be the easiest way to achieve that?
-
For a project I would like to run a discrete wavelets tranform on my Bangle.js 2 watch.
Because of that, I am wondering if it is possible to install an existing npm package (namely https://www.npmjs.com/package/discrete-wavelets ) in Espruino, to make its functionality available within my JS project.
Concrete questions I am pondering about:
- Is it possible at all to install an npm package in Espruino?
- Which npm package size is okay for the Bangle.js 2 watch - especially when it comes to memory?
- Can the code of the npm package be stored in and run from the Bangle.js 2 flash memory, instead of RAM? How would I achieve this (or prevent that it moves to RAM for execution)?
- Could I precompile the npm JS code (to C, to binary), to make it run faster?
Thanks in advance for any help and hints! :-)
- Is it possible at all to install an npm package in Espruino?
-
I was inspired by this (https://www.espruino.com/Bangle.js+EdgeImpulse) project, running tflite models from Edge Impulse on my Bangle.js 2 watch.
I would like to take this a step further and also run preprocessing code that can be added to Edge Impulse projects ("DSP block"), not just the tflite model. Edge Impulse offers to export the complete inference code (DSP and model processing) as a C++ library - optimised for embedded devices. Details see https://docs.edgeimpulse.com/docs/run-inference/cpp-library/deploy-your-model-as-a-c-library .
My question is: What is the easiest way to make a C/C++ library available in Espruino? I read in the Espruino docs that Inline C is available, also recompiling the firmware, but somehow I do not understand what the steps are (or if it is even feasible). Maybe there is an example of how to add a custom C/C++ library to Espruino that I could follow?
I am also not sure how to call functions/methods exposed by such a library. Using Inline C, or do I need to write a JS wrapper?
Any thoughts are highly appreciated! :-)
Hi Fanoush, thanks a lot for the very helpful explanations and background information. :-)
I suppose for a start I will focus on extending the firmware (following the examples Gordon sent) as that seems to be (as you also wrote) the more straightforward approach. It is great to know that C++ as part of the libraries I need to embed is no hurdle. :-)