 // 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)

unsigned long lastBlink = 0;
const unsigned long blinkInterval = 500;

// throttle control
int lastThrottleValue = 0;
int throttleValue = 0;
int throttleMin = 1023;
int throttleMax = 0;
#define THROTTLE_THRESHOLD 2
#define SERIAL_SPEED 9600

void setup() {

  lastBlink = millis();
}

void updateAnalogPin(uint8_t id) {
	// read in analog value
	aValue[id] = analogRead(aPins[id]);
	// map to the range of the analog out
	aValue[id] = map(aValue[id], 0, 1023, 0, 255);
	// is it different enough from the last reading?
	if (abs(aValue[id]-lastAValue[id])>aThreshold[id]) {
		if (aValue[id]<aThreshold[id]) {
			aValue[id] = 0;
		}
		if (aValue[id]>255-aThreshold[id]) {
			aValue[id] = 255;
		}
    // dump status
	Serial.print("P");
	Serial.print(id);
	Serial.print("=");
	Serial.println(aValue[id],HEX);
	lastAValue[id] = aValue[id];
  }
}

void updateAnalogs() {
	for (uint8_t i=0; i<nAPins; i++) {
		updateAnalogPin(i);
	}
}

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