Running KotlinJS on Bangle.js OpenSource Smartwach

I’ve founded the open source smart watch Bangle.js on Kickstarter.
It would be awesome to use my favorite program ming language on this device and i have no JavaScript experience. Can somebody give advice how create an Intellij project that is capable to produce code that is executable on the Espruino JavaScript interpreter on this watch?
I’ve tried the code produced by the browser and Nodejs target without success.
It is needed to create a new KotlinJs target?

You can try the everything in the Bangle.js emulator


  • Gradle project that produces JavaScript code that is executable on Bangle.js

I don’t think it can work because when kotlin is compiled into javascript it needs a (5MB?) library, and this library is too big for a bangle.js. (Or am I wrong? I’m inexperienced with kotlin so sorry if everything I say is wrong)
However if you don’t want to use javascript you can try coffeescript, this language compile directly into javascript and is really easy to learn.

After compiling kotlin to js you should run a dce tool to reduce the size of the resulting js file. That should remove all functions from the standard library that you aren’t using. That way your final size should be much smaller. There is a gradle plugin to do that.

Sadly I don’t have any experience with kotlin/JS so I can’t help you with specifics, but a short google search for kotlin js dce should help with that. And I’m sure others here are willing to help too :wink:

1 Like

I’ve spent a lot of time on this and i’ve been successful. Here is my sample Code:
There is still a lot of room for improvement. I’ve written down some todos in the, help is appreciated.

For quick run copy this: and paste it into the emulator: