 // to: oraz array.size() zamiast nPins http://hackaday.com/2015/11/13/code-craft-embedding-c-timing-virtual-functions/
 //   ok jeśli będzie niedużo gorsze od 5104 bajtów
 
-const int throttlePin = A0;  // P0
-
+// digital control (switch, red, green)
 const uint8_t nPins = 7; // długość tabel poniżej
 const uint8_t switchPins[] = {4,  5, 8, 12, 0, 0,  0};	// Dx: stage, RCS, SAS, gear switch, overheat, lowpower, lowfuel
 const uint8_t onPins[] =     {0, 13, 9,  0, 0, 0,  0};	// Gx: stage, RCS, SAS, overheat, lowpower, lowfuel ON (green)

  lastBlink = millis();
}

void updateThrottle() {
  // read the analog in value:
  throttleValue = analogRead(throttlePin);
  // auto calibrate
  if (throttleValue>throttleMax) { throttleMax=throttleValue; }
  if (throttleValue<throttleMin) { throttleMin=throttleValue; }
  // map it to the range of the analog out:
  throttleValue = map(throttleValue, throttleMin, throttleMax, 0, 255);
  // is it different enough from last reading?
  if (abs(throttleValue-lastThrottleValue)>THROTTLE_THRESHOLD) {
    if (throttleValue<THROTTLE_THRESHOLD) {
      throttleValue = 0;
    }
    if (throttleValue>255-THROTTLE_THRESHOLD) {
      throttleValue = 255;
    }
    // dump status
    Serial.print("P0=");
    Serial.println(throttleValue,HEX);
    lastThrottleValue = throttleValue;
  }
}

uint8_t updateButton(int pin, int id, uint8_t lastState) {

}

void loop() {
  updateAnalogs();
  updatePins();
  checkSerialInput();
  updateLeds();
