ESP8266 capturing 4 Infra Red dots/markers using WiiMote camera

Test rig :- 4 IRs dangling from space

Its basically a Nintendo WiiMote camera which is able to track 4 infra red leds/laser giving XY coordinates and also the size of the blob seen.

The WiiMote camera is an i2c devise however its a little dum as you have to kickstart it with a separate 25mhz clock. (deadbug style coz its easier to solder)

In this current application I am sending the received Blobs via a parsed SVG packet to the web site....which inturn sends me back a neat SVG graphic which is displayed to my phone via webpage.

Here below is the juicy part of the code:-

  String out = "";
  char temp[200];
  out += "<svg xmlns=\"\" version=\"1.1\" width=\"1000\" height=\"800\">\n";
  out += "<g >\n";               // Start our data string          

  sprintf(temp, "<circle cx=\"%d\" cy=\"%d\" r=\"%d\" stroke=\"black\" />\n" ,ircam.Blob1.X,ircam.Blob1.Y,ircam.Blob1.Size*5); out +=temp;
  sprintf(temp, "<circle cx=\"%d\" cy=\"%d\" r=\"%d\" stroke=\"red\"   />\n"  ,ircam.Blob2.X,ircam.Blob2.Y,ircam.Blob2.Size*5); out +=temp;
  sprintf(temp, "<circle cx=\"%d\" cy=\"%d\" r=\"%d\" stroke=\"green\" />\n",ircam.Blob3.X,ircam.Blob3.Y,ircam.Blob3.Size*5); out +=temp;
  sprintf(temp, "<circle cx=\"%d\" cy=\"%d\" r=\"%d\" stroke=\"blue\"  />\n" ,ircam.Blob4.X,ircam.Blob4.Y,ircam.Blob4.Size*5); out +=temp;
  out += "</g>\n</svg>\n";                   // close the SVG wrapper
  server.send ( 200, "image/svg+xml", out);  // and send it to\
  delay(100); //If you have a Sizable graphic then allow time for the response from before polling the site again (else things will break)

After a shoutbox exchange Kwatters gave me additional input on how to calculate angles between vectors.

link :-

Update 20160221 .... a few days later :-

Here is the resulting code that appears to work, please note result is given in radians (so multiply by 57.2958 to get the degrees)

  p1x=ircam.Blob1.X;  p1y=ircam.Blob1.Y;
  p2x=ircam.Blob2.X;  p2y=ircam.Blob2.Y;
  p3x=ircam.Blob3.X;  p3y=ircam.Blob3.Y;

 angle=atan2(p2y - p1y, p2x - p1x) - atan2(p3y - p1y, p3x - p1x);

This has been tested with a makeshift array of 3 IR leds on a bread board, now time to attach it to linkage mechanism or magnetic IR markers to attach to my shoulder elbow and hand......