Mirror with some correction

Dependencies:   mbed FastIO FastPWM USBDevice

Revision:
53:9b2611964afc
Parent:
52:8298b2a73eb2
Child:
55:4db125cd11a0
--- a/cfgVarMsgMap.h	Sat Mar 05 00:16:52 2016 +0000
+++ b/cfgVarMsgMap.h	Fri Apr 22 17:58:35 2016 +0000
@@ -28,6 +28,14 @@
 {
     switch (data[1])
     {
+        // ********** DESCRIBE CONFIGURATION VARIABLES **********
+    case 0:
+        v_byte_ro(15, 2);       // number of SCALAR variables
+        v_byte_ro(2, 3);        // number of ARRAY variables
+        break;
+        
+        // ********** SCALAR VARIABLES **********
+        
     case 1:
         // USB identification (Vendor ID, Product ID)
         v_ui16(usbVendorID, 2);
@@ -57,60 +65,107 @@
         
     case 6:
         // Plunger sensor pin assignments
-        v_pin(plunger.sensorPin[0], 2);
-        v_pin(plunger.sensorPin[1], 3);
-        v_pin(plunger.sensorPin[2], 4);
-        v_pin(plunger.sensorPin[3], 5);
+        v_byte(plunger.sensorPin[0], 2);
+        v_byte(plunger.sensorPin[1], 3);
+        v_byte(plunger.sensorPin[2], 4);
+        v_byte(plunger.sensorPin[3], 5);
         break;
         
     case 7:
         // Plunger calibration button and indicator light pin assignments
-        v_pin(plunger.cal.btn, 2);
-        v_pin(plunger.cal.led, 3);
+        v_byte(plunger.cal.btn, 2);
+        v_byte(plunger.cal.led, 3);
         break;
         
     case 8:
         // ZB Launch Ball setup
         v_byte(plunger.zbLaunchBall.port, 2);
-        v_byte(plunger.zbLaunchBall.btn, 3);
-        v_ui16(plunger.zbLaunchBall.pushDistance, 4);
+        v_byte(plunger.zbLaunchBall.keytype, 3);
+        v_byte(plunger.zbLaunchBall.keycode, 4);
+        v_ui16(plunger.zbLaunchBall.pushDistance, 5);
         break;
         
     case 9:
         // TV ON setup
-        v_pin(TVON.statusPin, 2);
-        v_pin(TVON.latchPin, 3);
-        v_pin(TVON.relayPin, 4);
+        v_byte(TVON.statusPin, 2);
+        v_byte(TVON.latchPin, 3);
+        v_byte(TVON.relayPin, 4);
         v_ui16(TVON.delayTime, 5);
         break;
         
     case 10:
         // TLC5940NT PWM controller chip setup
         v_byte(tlc5940.nchips, 2);
-        v_pin(tlc5940.sin, 3);
-        v_pin(tlc5940.sclk, 4);
-        v_pin(tlc5940.xlat, 5);
-        v_pin(tlc5940.blank, 6);
-        v_pin(tlc5940.gsclk, 7);
+        v_byte(tlc5940.sin, 3);
+        v_byte(tlc5940.sclk, 4);
+        v_byte(tlc5940.xlat, 5);
+        v_byte(tlc5940.blank, 6);
+        v_byte(tlc5940.gsclk, 7);
         break;
         
     case 11:
         // 74HC595 shift register chip setup
         v_byte(hc595.nchips, 2);
-        v_pin(hc595.sin, 3);
-        v_pin(hc595.sclk, 4);
-        v_pin(hc595.latch, 5);
-        v_pin(hc595.ena, 6);
+        v_byte(hc595.sin, 3);
+        v_byte(hc595.sclk, 4);
+        v_byte(hc595.latch, 5);
+        v_byte(hc595.ena, 6);
         break;
         
     case 12:
+        // Disconnect reboot timeout
+        v_byte(disconnectRebootTimeout, 2);
+        break;
+        
+    case 13:
+        // plunger calibration
+        v_ui16(plunger.cal.zero, 2);
+        v_ui16(plunger.cal.max, 4);
+        v_byte(plunger.cal.tRelease, 6);
+        break;
+        
+    case 14:
+        // expansion board configuration
+        v_byte(expan.typ, 2);
+        v_byte(expan.vsn, 3);
+        v_byte(expan.ext[0], 4);
+        v_byte(expan.ext[1], 5);
+        v_byte(expan.ext[2], 6);
+        break;
+        
+    case 15:
+        // night mode configuration
+        v_byte(nightMode.btn, 2);
+        v_byte(nightMode.flags, 3);
+        v_byte(nightMode.port, 4);
+        break;
+        
+       
+    // case n: // new scalar variable
+    //
+    // ATTENTION!
+    // UPDATE CASE 0 ABOVE WHEN ADDING A NEW VARIABLE!!!
+        
+        // ********** ARRAY VARIABLES **********
+
+    // case n: // new array variable
+    //
+    // ATTENTION!
+    // UPDATE CASE 0 ABOVE WHEN ADDING A NEW ARRAY VARIABLE!!!
+        
+    case 254:
         // button setup
         {
             // get the button number
             int idx = data[2];
             
             // if it's in range, set the button data
-            if (idx > 0 && idx <= MAX_BUTTONS)
+            if (idx == 0)
+            {
+                // index 0 on query retrieves number of slots
+                v_byte_ro(MAX_EXT_BUTTONS, 3);
+            }
+            else if (idx > 0 && idx <= MAX_EXT_BUTTONS)
             {
                 // adjust to an array index
                 --idx;
@@ -124,14 +179,19 @@
         }
         break;
         
-    case 13:
+    case 255:
         // LedWiz output port setup
         {
             // get the port number
             int idx = data[2];
             
             // if it's in range, set the port data
-            if (idx > 0 && idx <= MAX_OUT_PORTS)
+            if (idx == 0)
+            {
+                // index 0 on query retrieves number of slots
+                v_byte_ro(MAX_OUT_PORTS, 3);
+            }
+            else if (idx > 0 && idx <= MAX_OUT_PORTS)
             {
                 // adjust to an array index
                 --idx;
@@ -141,35 +201,8 @@
                 v_byte(outPort[idx].pin, 4);
                 v_byte(outPort[idx].flags, 5);
             }
-            else if (idx == 254)
-            {
-                // special ports
-                idx -= 254;
-                v_byte(specialPort[idx].typ, 3);
-                v_byte(specialPort[idx].pin, 4);
-                v_byte(specialPort[idx].flags, 5);
-            }
         }
         break;
-        
-    case 14:
-        // Disconnect reboot timeout
-        v_byte(disconnectRebootTimeout, 2);
-        break;
-        
-    case 15:
-        // plunger calibration
-        v_ui16(plunger.cal.zero, 2);
-        v_ui16(plunger.cal.max, 4);
-        v_byte(plunger.cal.tRelease, 6);
-        break;
-        
-    case 16:
-        // expansion board configuration
-        v_byte(expan.nMain, 2);
-        v_byte(expan.nPower, 3);
-        v_byte(expan.nChime, 4);
-        break;
     }
 }