I wouldn't be happy with that code either...
TBH - what I'd do for something like this is have a single function getting called every 10 milliseconds with setinterval, set up like kind of like a state-machine, which determines if it needs to brighten, dim, or do nothing. Which feels slightly un-Espruino-ey... but I think it'll probably work better. I don't like a solution that's relying on two intervals staying in sync - that's not guaranteed.
© Espruino, powered by microcosm.
Report a problem