For a long time it's been bothering me that nobody seems to use the
simulator. Could it be that having to compile it (on Linux, of course)
is already too much of a hassle ?

If the simulator could just run in a Web browser, this would remove
the barrier. But the simulator and the Anelok firmware it uses are
written in C, not the sort of languages browsers tend to run.

A few days ago it ocurred to me that it may not be all that difficult
to compile C to something Web-friendly. I was thinking of Java
bytecode at the time. So I did a bit of searching ... and found
emscripten:
http://kripken.github.io/emscripten-site/

Emscripted takes the idea one step further and generates JavaScript.
Even better, it supports SDL for graphical output.

My first attempts with the emscripten package that comes with Ubuntu
didn't go too well, but once I built it from sources, making it all
work was remarkably easy:
https://gitlab.com/anelok/anelok/commit/374be26dde063459e2fa3f1bb31121c125ffcdd1

Build instructions (section "Building with emscripten") are at the
end of
https://gitlab.com/anelok/anelok/blob/master/sim/README


The automatically generated Web page looks horrible, but the
simulator in there works almost perfectly:
https://anelok.com/sim/

The only issue I noticed is that the (simulated) LED doesn't want to
blink. It will turn on and off fine enough, but not blink.

To use the simulator:

- load https://anelok.com/sim/ in a browser that supports WebGL

- click and hold in the middle of the small black rectangle (the
  big rectangle is the console), until the Anelok logo appears,
  then release the mouse button.

- enter the PIN, a V shape: top, middle, bottom, middle, top.
  ("Top" means to click in the upper third of the simulator screen,
  etc.)

- click in the bottom position and hold. Release when the "Enter"
  icon highlights.

- etc.

This worked with Firefox without further ado, but Chromium insisted
that the "Web page was not allowed to create a WebGL context". It
turns out that there are a great many ways to make Chrome and
Chromium not support WebGL, though it will do so quite merrily if
asked persistently enough.

Very useful instructions for talking Chrome into allowing WebGL:
https://superuser.com/questions/836832/how-can-i-enable-webgl-in-my-browser

Note: if changing settings requires a browser restart, it seems that
just restarting from within the browser may not be enough, but one
has to exit it completely, then run it again.

- Werner

_______________________________________________
Qi Hardware Discussion List
Mail to list (members only): [email protected]
Subscribe or Unsubscribe: 
http://lists.en.qi-hardware.com/mailman/listinfo/discussion

Reply via email to