-
-
You where right @Gordon.
After I've updated the boot loader, the numbers are closer.Running the code:
> initial 694 1053 1053 1053 903 905 916
Running as an App
> initial 771 974 974 824 856 856
-
To give a bit of context: I would like the ability to list files present on the board.
I though it would be a small addition ton BangleApps to display such list, and allow to download them.I've mitigated the encoding issue:
// this is on the BangleApp: Puck.eval('require("Storage").list().map(encodeURIComponent)', (files,err) => { if (files===null) return reject(err || ""); files = files.map(decodeURIComponent) console.log("listFiles", files); resolve(files) });
-
Thanks for the clarification folks.
This final character makes
Puck.eval()
failing when transfering these strings:Puck.eval('require("Storage").list()')
will fail on:
Unable to decode "[\"+mclock\",\"-mclock\",\"*mclock\",\"+setting\",\"-setting\",\"=setting\",\"*setting\",\"+astroid\",\"-astroid\",\"*astroid\",\"+gpstime\",\"-gpstime\",\"*gpstime\",\"+compass\",\"-compass\",\"*compass\",\"+sbt\",\"=sbt\",\"+sbat\",\"=sbat\",\"+files\",\"-files\",\"*files\",\"+hrm\",\"-hrm\",\"*hrm\",\"+gpsinfo\",\"-gpsinfo\",\"*gpsinfo\",\".trishig\",\".bootcde\",\"+speedo\",\"-speedo\",\"*speedo\",\"@setting\",\"@activi\\1\",\"-activit\",\"+activit\",\"test\\1\"]\r", got SyntaxError: Unexpected number in JSON at position 357
Having chosen an octal escape sequence make it hard to (de)serialize.
-
Hi there!
Before opening a bug on the tracker, I wanted to double check this behaviour.
This code opens a file in append mode, and writes some text in it.const Storage = require('Storage') const name = 'test' Storage.erase(name) const file = Storage.open(name, 'a') console.log('-> files', Storage.list()) // file not in the list file.write('whatever') console.log('-> files', Storage.list()) // file exists, but has a \1 octal escape sequence appended to its name
this gives:
____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v04 (c) 2019 G.Williams >-> files [ "+mclock", "-mclock", "*mclock", "+setting", "-setting", "=setting", "*setting", "+sbt", "=sbt", "+sbat", "=sbat", "+files", "-files", "*files", ".trishig", ".bootcde", "@setting", ] -> files [ "+mclock", "-mclock", "*mclock", "+setting", "-setting", "=setting", "*setting", "+sbt", "=sbt", "+sbat", "=sbat", "+files", "-files", "*files", ".trishig", ".bootcde", "@setting", "test\1" ]
This
\1
at the end: is it expected? -
-
Hi Robin.
I've update the links above:
https://www.espruino.com/ide/?gist=9df129529bccc133f9f82bf7b39de48f&upload
will write the minified app (8485 characters) straight to your bangle and run it.
The very first instruction displays number of free blocks.Here is an example of a run (press button 2 to start, button 1 to pause, then button 3 to stop and reset):
>> initial 694 1053 1053 1053 1053 1053 1050 1050 1050 1050 1050 1050 902 932
Now, the same code, but saved in Storage under "activities" name:
https://www.espruino.com/ide/?gist=3fddc28e3188fd5f5cded6aa1d037cb0&uploadLong press Btn 3 to get the clock, then goes to settings, select "activities" and start/pause/stop
> initial 496 699 699 699 699 699 696 696 696 696 696 696 696 696 546
-
I've manage it with a better minification (thank you "terser's mangle" option!).
One thing I'd like to confirm.
With IDE minification disable, when I load my code straight to the bangle,process.memory().free
returns 1023 when the app starts.
When I store the exact same code on the bangle storage, and start the app with the launcher, the number of free blocks drops to 692.Is the difference due to the app launcher itself?
Is there some memory I could reclaim? -
So I'm a runner. And as I turn older, I started to run in hills and mountains.
2 years ago I spent 300€ for a Suunto smart watch, to guide me on tracks:
I really like it, but it could be improved in a lot of ways, in particular its software. At some point, it was possible to write custom screens with some sort of JavaScript :grin:
But the whole Suunto ecosystem is very closed, and their support is, for the least... not responsive.So when I learned about Bangle.js you can imagine how excited I was.
The plan is to mimic Suunto's sport mode:- start an activity
- cycle through several screens, showing metrics (current & average speed, distance, BPM, burnt calories, incline/decline, altitude, for the total activity or current lap)
- pause and stop
In my craziest dream, I'd love to write a navigation screen to guide you along some GPX track. But this may be too ambitious given the hardware.
Not surprisingly, writing such app is not in indoor activity. It depends too much on GPS to stay at home.
So yesterday, it was the première for my app: after work I took my bike (10km +200m) to meet my fellow runners and we went for a run across hills (11km +400m), a watch on each wrist.
It was night, raining and wind blowing.The Bangle behave very well!
The LCD was lit up all the way long (3h30), 10 FPS refresh rate, GPS and HR on, and it ate 60/70% of its battery (same as the Suunto!).GPS fix took a while compared to Suunto, but I think the accuracy is better (I'll perform more investigations). The lack of accuracy is my greatest complain. GPS Altitude (benchmarked against signs mentioning it) is very accurate, I suspect instant speed to be quite good as well.
No surprise: HRM gives terrible results (either 50 or 200 BPM). My skin is quite clear, and my veins very easy to spot. I was careful not wearing it on bones, and as it was night, the amount of light pollution was limited.
Despite this little issue I was amazed how good Bangle did, especially when you consider the hardware is 5 times cheaper! Amazon work @Gordon!
I'll continue crafting this sport mode, and share the code when it will be ready, would someone be interested to use Bangle for sport!
- start an activity
-
Hey folks!
Thanks for the quick answers.few takeaways:
splitting my app in chunks when writing it in storage is not a good idea: if it can not be saved in the first place, it means it won't fit in RAM when read
as I have my own pipeline to bundle and minify my app, I will disable IDE minification in the future. This way it will be easier to get consistent results between stored app & REPL app.
I've reached my limit as a web developer: the way I approached my app, with beautiful and reusable classes, icons as images, and intensive event usage, does not work in such constrained environment. I'll be more pragmatic now
@allObjects my source code is split in different modules, and I use rollup & babel to transpile and bundle them in one file. Is there a way to split the app on the Bangle itself, using different "files" in storage?
-
Hello there!
When I upload my code from the Web IDE to the watch, it runs as expected.
https://www.espruino.com/ide/?gist=9df129529bccc133f9f82bf7b39de48f&upload
(shows you current time and start message, until you press button 2 which stops everything)I am trying now to store it as an app.
The code string is big (18 156 chars), so it is split in chunks and writes gracefully in file.
https://www.espruino.com/ide/?gist=3fddc28e3188fd5f5cded6aa1d037cb0&uploadBut when I launch the app from the app launcher, I get:
Execution Interrupted during event processing.
New interpreter error: LOW_MEMORY,MEMORYAny hints on how I could troubleshoot this?
I have LOW_MEMORY issues when reading my app from storage.
The app is quite big: the code string is 18 156 characters long. -
-
-
-
-
-
Hello there, and sorry to re-open the discussion.
When I set my bangle in DFU mode (hold BTN1 + BTN2 until it reboot, and release before the === line is complete), I can see "DfuTarg" bluetooth device in my bluetooth discovery app (laptop and mobile).
When I select it, the watch displays "Connected", and a couple of seconds after, says "Disconnected".
On the laptop/mobile side, the bluetooth app says it could pairing was rejected.I am pretty annoyed, because my previous attempt to upload a new Firmware failed before completion, and the watch can not boot any more...
-
-
Hello folks!
First of all, thanks for this amazing job. For a runner like me, having a possibility to make my own sport mode is incredible.
I'm trying to get my heart rate, but
Bangle.setHRMPower()
function is undefined.
The only example I could find seems to read an analog port instead of listening to the'HRM'
event as the doc says.I am using the latest firmware (2.04), on the NodeConfEU watch.
-
-
I'm also having some issues, but not exactly the same as Sebi.
My (nodeconf) watch is in DFU started, the exact same screen as you shown, Gordon.On my Android phone, I select the latest firmware, then my bangle ECDB device, and I hit the upload button (see attached screenshot)
While uploading, nothing happens on the Bangle.
After a while, I'm receiving a notification on the phone (it's too quick to take a screen shot):Upload failed: GATT ERROR
Hello folks!
We may have a memory leak with
Module.removeAllCached()
, which is pretty ironic since I hoped to use it and free some memory ;PA bit of context. I'm trying various means to overtake the deadly 10000 character limit.
From the last month experiments, this is roughly the maximum number of symbols your application could have to fit in the Bangle's RAM.
I found a nice way to split my code into several chunks, each being a file.
My ES6 source code is leveraging dynamic imports, which instructs Rollup to produce several chunks.
A small Rollup plugin of mine turns the chunk into Bangle's files.
The app is written so screens are stored as files. Displaying a screen is simply requiring the relevant file, and calling the
build()
function it exposes.Here is the code,
and here is the minified, split output that you can run on your watch.
Now if you launch the app, and cycle through the various screens with middle button, at some point you should have a LOW_MEMORY error.
Since object returned by
require()
are cached, I've tried to callModule.removeAllCached()
after a screen was required, so it could claim the space from the previous screen.Here is the minified code, same as previously but with the call.
You'll be surprised to get the LOW_MEMORY error the very first time you load next screen.
Few more experiments makes me believe that
Module.getCached()
also have similar side effect.Could it be that listing cached modules (which
removeAllCached()
starts with) is eating more RAM that it should?