   m_lastLedState = nval;
 }
 
-void digitalPin::updateLed(const bool blink) const {
+void digitalPin::updateLed(const bool blink) {
   uint8_t nstate;
-  if (m_pinOn>0) {
-    nstate = (m_lastLedState & 0x01) ? HIGH : LOW;
-    if (nstate==HIGH && (m_lastLedState & 0x02) && blink) {
-      nstate = !digitalRead(m_pinOn);
-    }
-//Serial.print("L"); Serial.print(gPin); Serial.print(nstate);
-    digitalWrite(m_pinOn,nstate);
-  }
-  if (m_pinOff>0) {
-    nstate = (m_lastLedState & 0x10) ? HIGH : LOW;
-    if (nstate==HIGH && (m_lastLedState & 0x20) && blink) {
-      nstate = !digitalRead(m_pinOff);
-    }
-//Serial.print("R"); Serial.print(rPin); Serial.print(nstate);
-    digitalWrite(m_pinOff,nstate);
-  }
-}
-
-class analogInPin {
-  public:
-    analogInPin(const uint8_t id, const uint8_t pin, const int threshold);
-    void update();
-  private:
-    const uint8_t m_id, m_pin;
-    const int m_threshold;
-    int m_lastAValue { 0 };
-};
-
-analogInPin analogInPins[] = {
-  analogInPin(0,A0,2),  // throttle
-  analogInPin(1,A1,2)	  // timewarp
-};
-
-analogInPin::analogInPin(const uint8_t id, const uint8_t pin, const int threshold) :
-	m_id(id), m_pin(pin), m_threshold(threshold)
-{
-}
-
-void analogInPin::update() {
-	// map to the range of the analog out
-	int aValue = map(analogRead(m_pin), 0, 1023, 0, 255);
-	// is it different enough from the last reading?
-	if (abs(aValue-m_lastAValue)>m_threshold) {
-		if (aValue<m_threshold) {
-			aValue = 0;
-		}
-		if (aValue>255-m_threshold) {
-			aValue = 255;
-		}
-    // dump status
-	Serial.print("P");
-	Serial.print(m_id);
-	Serial.print("=");
-	Serial.println(aValue,HEX);
-	m_lastAValue = aValue;
-  }
-}
-
-class analogOutPin {
-  public:
-    analogOutPin(const uint8_t id, const uint8_t pin);
-    void updateState(const uint8_t val) const ;
-    const uint8_t getId() const { return(m_id); }
-  private:
-    const uint8_t m_id, m_pin;
-};
-
-analogOutPin::analogOutPin(const uint8_t id, const uint8_t pin) :
-	m_id(id), m_pin(pin)
-{
-}
-
-void analogOutPin::updateState(const uint8_t val) const {
-	analogWrite(m_pin,val);
-}
-
-analogOutPin analogOutPins[] = {
-  analogOutPin(0,10),	// g-force
-  analogOutPin(0,11)  // electrical power
-};
+  nstate = (m_lastLedState & 0x01) ? HIGH : LOW;
+  if (nstate==HIGH && (m_lastLedState & 0x02) && blink) {
+    nstate = !m_OnLed;
+  }
+  m_OnLed = nstate;
+  if (m_pinOn>0 && m_pinOn<128) {
+    digitalWrite(m_pinOn,m_OnLed);
+  }
+
+  nstate = (m_lastLedState & 0x10) ? HIGH : LOW;
+  if (nstate==HIGH && (m_lastLedState & 0x20) && blink) {
+    nstate = !m_OffLed;
+  }
+  m_OffLed = nstate;
+  if (m_pinOff>0 && m_pinOff<128) {
+    digitalWrite(m_pinOff,m_OffLed);
+  }
+}
+
+const uint8_t digitalPin::getOnOffBits() const {
+  uint8_t nstate = 0;
+  if (m_pinOn>=128 && m_OnLed) {
+    nstate |= 1 << (m_pinOn & 0x07);
+  }
+  if (m_pinOff>=128 && m_OffLed) {
+    nstate |= 1 << (m_pinOff & 0x07);
+  }
+  return(nstate);
+}
 
 // blinker control
 unsigned long lastBlink = 0;
 const unsigned long blinkInterval = 500;
 
-// Set the pins on the I2C chip used for LCD connections:
-//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
-LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
+void serialShiftWrite(uint8_t data) {
+  digitalWrite(latchPin, LOW);
+  delayMicroseconds(100);
+  // shift the bytes out:
+  shiftOut(dataPin, clockPin, MSBFIRST, data);
+  delayMicroseconds(100);
+  digitalWrite(latchPin, HIGH);
+}
 
 // serial port
 #define SERIAL_SPEED 115200
 
 void setup() {
+  //set pins to output so you can control the shift register
+  pinMode(latchPin, OUTPUT);
+  pinMode(clockPin, OUTPUT);
+  pinMode(dataPin, OUTPUT);
   // initialize serial communications at 9600 bps:
   Serial.begin(SERIAL_SPEED);
   // set timeout to 200ms

  Serial.println("I");
  // start blink counter
  lastBlink = millis();
  lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight
  lcd.setCursor(0,0);
  lcd.print("KSP-Gegi");
  lcd.setCursor(0,1);
  lcd.print("Ready for action");
}

void updateAnalogs() {
  for (auto &p : analogInPins) {
    p.update();
  }
}

void updatePins() {
  const unsigned long currentMillis = millis();
  bool blink = false;
  // is it time for tick?
  if (((unsigned long)(currentMillis - lastBlink) >= blinkInterval)) {
    blink = true;

  if (m_pinSwitch>0) {
    pinMode(m_pinSwitch,INPUT_PULLUP);
  }
  if (m_pinOn>0 && m_pinOn<128) {
    pinMode(m_pinOn,OUTPUT);
    digitalWrite(m_pinOn,LOW);
  }
  if (m_pinOff>0 && m_pinOn<128) {
    pinMode(m_pinOff,OUTPUT);
    digitalWrite(m_pinOff,LOW);
  }
