 	}
 }
 
+void updateAnalogs() {
+  for (auto &p : analogInPins) {
+    p.update();
+	// map to joystick axes
+  }
+}
+
+void updatePins() {
+  for (auto &p : digiPins) {
+    p.updateSwitch();
+	// remember state so analog axes are updated accordingly
+	if (p.getId()==10) {
+		joy1switch = p.getSwitchState();
+	}
+	if (p.getId()==11) {
+		joy2switch = p.getSwitchState();
+	}
+  }
+}
+
 void loop() {
   checkSerialInputUSBtoUART();
   checkSerialInputUARTtoUSB();
-  Joystick.sendState();
-  delay(200);
-}
-
+  updatePins();
+  updateAnalogs();
+  delay(50);
+}

  analogOutPin(0,9),	// g-force
  analogOutPin(1,10)    // electrical power
};

// Stage/Abort status (on=stage, off=abort
uint8_t stageabort = 1;

// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol

  lcd.setCursor(0,1);
  lcd.print("Ready for action");
  // joystick setup
  Joystick.begin(true);	// do auto send state
  // request status update
  Serial.println("I");
}
