 };
 
 // this controls whether the python script closes or not, 1 == run
-byte state = 1;
+boolean state = 1;
+
+// specialized control functions
+
 
 
 //// helper functions
 //
 
-byte readDirection(byte pinH, byte pinL) // get control input
-{
-  return (digitalRead(pinH) ? FULL : (digitalRead(pinL) ? ZERO : HALF));
-}
-
-byte readThrottle(byte pin) // get throttle input
-{
-  return ((byte) (((float)analogRead(pin) * THOTTLE_MAX) / ANALOG_MAX));
+int8_t readDirection(uint8_t pinH, uint8_t pinL, int8_t adj) // get control input
+{
+  switch (digitalRead(pinH) ? full : (digitalRead(pinL) ? half : zero))
+  {
+    case full:
+      if (adj++ >= RAMP_MAX)
+        adj = RAMP_MAX;
+      break;
+      
+    case zero:
+      if (adj-- <= RAMP_MIN)
+        adj = RAMP_MIN;
+      break;
+
+    default:
+      adj = 0;
+  }
+  
+  return (adj);
+}
+
+int16_t setDirection(int16_t current, boolean stick, int8_t adj)
+{
+  current += adj;
+
+  if (!(adj || stick))
+    current = 0;
+
+  if (current > DIR_MAX)
+    current = DIR_MAX;
+
+  if (current < DIR_MIN)
+    current = DIR_MIN;
+
+  return (current);
+}
+
+uint8_t readThrottle(uint8_t pin) // get throttle input
+{
+  return ((uint8_t) (((float)analogRead(pin) * THOTTLE_MAX) / ANALOG_MAX));
 }
 
 

#define DELAY_OP 100

// misc
#define OPS (sizeof(opPin) / sizeof(byte))

#define ANALOG_MAX (float)1023 // these two are for converting 0-1023 to 0-100
#define THOTTLE_MAX (float)255


// helm control variables
byte pitch, yaw, roll, throttle;

// op control variables
// state == 0 to DELAY_OP-1 -> off / debounce, state == DELAY_OP -> on
byte opState[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// operation pins set to zero are skipped
byte opPin[] =
{
  0,             // null
  0,             // action group 1

#define PIN_YAW_R 7
#define PIN_THROTTLE A0 // analog read

// rotary pins
#define PIN_ROT_CLK 2
#define PIN_ROT_DATA A2
#define PIN_ROT_SW // no pin yet

// ops pins
#define PIN_OP_LAUNCH 0
#define PIN_OP_STAGE 0
#define PIN_OP_ACG3 0
#define PIN_OP_ACG5 0

// delays
#define DELAY_LOOP 15
