 #define DIR_MAX 2000
 #define DIR_MIN -DIR_MAX
 
+// helper stuff for helm / shorthand
 #define PITCH_STICK digitalRead(PIN_PITCH_S)
 #define ROLL_STICK digitalRead(PIN_ROLL_S)
 #define YAW_STICK digitalRead(PIN_YAW_S)


// op control variables
// state == 0 to DELAY_OP-1 -> off / debounce, state == DELAY_OP -> on
uint8_t opState[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// operation pins set to zero are skipped
uint8_t opPin[] = // this will hold bitmasks for i/o expander
{
  0,             // null
  0,             // action group 1
  0,             // '' 2
  PIN_OP_ACG3,   // '' 3
  0,             // '' 4
  PIN_OP_ACG5,   // '' 5
  0,             // '' 6
  0,             // '' 7
  0,             // '' 8
  0,             // '' 9
  0,             // '' 10
  PIN_OP_LAUNCH, //
  PIN_OP_STAGE   //
};

// this controls whether the python script closes or not, 1 == run
boolean state = 1;

// specialized control functions



//// helper functions
//

int16_t getAdjustment(uint8_t pinH, uint8_t pinL, int8_t adj) // get control input
{
  switch (digitalRead(pinH) ? HIGH : (digitalRead(pinL) ? LOW : NEUTRAL))
  {
    case HIGH:
      if (adj++ > RAMP_MAX)
        adj = RAMP_MAX;
      break;

    case LOW:
      if (adj-- < RAMP_MIN)
        adj = RAMP_MIN;
      break;

    case NEUTRAL:
    default:
      adj = 0;
  }

  uint8_t ops = 0;
  uint8_t index = 0;

  if (requestDevice(IO_DEV_OPS) == I2C_SUCCESS) // send start, skip if failure
  {
    if (requestData(IO_DEV_OPS)) // ask for data, skip if failure
    {
      uint16_t data = readData(); // finally get the 2 byte data packet
      
      for (index = 0; index < OPS; index++) // scan through ops 1-16 (everything but sas)
      {
        if (opState[index] > 0) // check for debounce on current pin
        {
          opState[index]--; // decrement debounce counter for current state
        }
        else // if not we can check to see if it's triggered
        {
          opState[index] =  ((1 << index) & data) ? DELAY_OP : 0;
          ops++;
        }
      }
    }
  }

