JavaScript to program IMP Wifi?

Any Chance of a JavaScript to program IMP Wifi?

Just using the blink codes in a browser window?

Technically possible if you can maintain an exact 60fps… I’ve not seen that work in a browser, though.

I did some experimentation with HTML5 frame rate a while ago for another project. You can get pretty close to a precise frame rate (and 60FPS should be no problem, a canvas with one or two objects can easily exceed 120 on a decent PC) - easily good enough for what I was doing at the time. However you need it completely consistent for flashing data and I suspect that would be a challenge.  I was seeing +/- 1FPS or so, usually minus when JS decided it just *had* to garbage collect right then.

This is a good tool to monitor what's going on:

https://github.com/mrdoob/stats.js

There are HTML5 canvas games that run at "60FPS" such as this one:

http://www.kevs3d.co.uk/dev/asteroids/

However if you'd care to share your protocol I'd be up for writing an Imp script to use Hannah to program other imps using her LED. Squirrel doesn't garbage collect as randomly as JS and as the ~17ms frame period is under the server contact threshold there would be no comms getting in the way.  Of course there's a chicken and egg element to this!

Rob
Fen Consultants, UK

It’s not the fps of the update, it’s that it has to be perfectly tied to the FPS of the display device. Anything that is saying it’s doing 120fps is an instant fail here, as it shouldn’t be able to go above the output device refresh rate.


Of course, you could use an arduino and an LED to do this too; I tried that previously and it worked but the code is not suitable for public consumption!

As I understand it window.requestAnimFrame is meant to be frame synced. However I just tried it and got (an extremely consistent) 62.5 fps.  So go figure.


Rob
Fen Consultants, UK

Maybe a imp with a LED can be used to program other imps?

Maybe a change to how blinkup works.  Count only the transitions, a=1 blink, b=2 blink, etc.  each letter followed by silence.   That would take longer to blink out but reduce your dependence on timing.   Also, I think manchester encoding helps with timing slips.   Just some thoughts …

Manchester coding doesn’t help with timing slips in our case I’m afraid, but we have another method which appears to work well in our testing and if all goes well will be released next week. Takes twice as long, but much better than the current frustration if your phone can’t keep up!


Implementing blinkup on an imp (a Hannah perhaps) is trivial, but ultimately not that useful…  I do have the Javascript attempt on my todo list (unless Hugo’s already on to it) but I have a feeling it’s going to be quite browser/system specific if it does work, and probably won’t work on a mobile device.


A fixed blinkup app would be great.

Rob
Fen Consultants, UK

Instead of Javascript, what about Flash or Silverlight?

I did think of a certain solution - progmatically create a “blinkup movie” with 60fps frame rate, then play it back using any decent movie player. It might even work on mobile devices. However I think all of this is going to become completely irrelevant when the Android app is fixed next week and Apple eventually deign to allow us to have the iOS version.


Rob
Fen Consultants, UK

it’s also a good question if blinking only one part of the screen (1cmx1cm) wouldn’t be much better for slower android phones. Now the whole screen is blinked which obviously is slower … Today I got a Motorola but that doesn’t works either - seems that <250$ Android phones are simply not strong enough for the current 60fps api which is kinda frustrating. And ofc apple still not moving with that api … grrrr :slight_smile: