As @fanoush said, I think probably the best thing is to look at using jit if possible, but...
If you change:
g.setBgColor((bngl && (E.getBattery()<10))?63488:(g.theme.bg))
// to
g.setBgColor((bngl==true && (E.getBattery()<10))?63488:(g.theme.bg))
Then it looks like that'll fix it. It'll be some issue with the compiler having trouble figuring out the type of bngl - but as @fanoush says the focus is really on trying to get jit good now, so that may not end up getting fixed unless someone else wants to jump in and look at it (https://github.com/gfwilliams/EspruinoCompiler)
Right now as you mention jit doesn't handle &&. It got left out because it's non-trivial to do it right. I'm super busy this week so don't have time for it but I filed an issue for it at https://github.com/espruino/Espruino/issues/2313 - in the mean time you may just be able to use & instead.
Definitely just try and pull out only the bit of code that needs to run fast and jit/compile that, and don't do anything that doesn't need it. I know the temptation is just to slap jit/compile/ram on everything, but in reality that will use a bunch of RAM and can actually make things slower (especially first startup) if it works at all! It's best to be as targeted as you can be with it.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
That clock face looks amazing!
As @fanoush said, I think probably the best thing is to look at using
jit
if possible, but...If you change:
Then it looks like that'll fix it. It'll be some issue with the compiler having trouble figuring out the type of
bngl
- but as @fanoush says the focus is really on trying to get jit good now, so that may not end up getting fixed unless someone else wants to jump in and look at it (https://github.com/gfwilliams/EspruinoCompiler)Right now as you mention
jit
doesn't handle&&
. It got left out because it's non-trivial to do it right. I'm super busy this week so don't have time for it but I filed an issue for it at https://github.com/espruino/Espruino/issues/2313 - in the mean time you may just be able to use&
instead.Definitely just try and pull out only the bit of code that needs to run fast and jit/compile that, and don't do anything that doesn't need it. I know the temptation is just to slap
jit/compile/ram
on everything, but in reality that will use a bunch of RAM and can actually make things slower (especially first startup) if it works at all! It's best to be as targeted as you can be with it.