Mike R / Mbed 2 deprecated Pinscape_Controller_v1

Dependencies:   FastIO FastPWM SimpleDMA mbed

Fork of Pinscape_Controller by Mike R

Revision:
25:e22b88bd783a
Parent:
21:5048e16cc9ef
Child:
29:582472d0bc57
--- a/USBJoystick/USBJoystick.cpp	Wed Jun 03 18:52:22 2015 +0000
+++ b/USBJoystick/USBJoystick.cpp	Tue Sep 01 04:27:15 2015 +0000
@@ -71,10 +71,20 @@
     // low 11 bits are the current pixel index.
     uint16_t s = idx | 0x8000;
     put(0, s);
+    
+    // start at the second byte
+    int ofs = 2;
+    
+    // in the first report, add the total pixel count as the next two bytes
+    if (idx == 0)
+    {
+        put(ofs, npix);
+        ofs += 2;
+    }
         
     // now fill out the remaining words with exposure values
     report.length = reportLen;
-    for (int ofs = 2 ; ofs + 1 < report.length ; ofs += 2)
+    for ( ; ofs + 1 < report.length ; ofs += 2)
     {
         uint16_t p = (idx < npix ? pix[idx++] : 0);
         put(ofs, p);