 #define BUTTON_BACK 1
 #define BUTTON_ENTER 8
 
+short rtiStep;
+
+SoftwareSerial rtiSerial(RTI_RX_PIN, RTI_TX_PIN);
+
 LinFrame frame = LinFrame();
 
-unsigned long currentMillis, lastHeartbeat, lastBackDown, lastEnterDown, lastMouseDown;
+unsigned long currentMillis, lastHeartbeat, lastBackDown, lastEnterDown, lastMouseDown, lastRtiWrite;
 int mouseSpeed = MOUSE_BASE_SPEED;
+short state = STATE_OFF;
 
 void setup() {
   pinMode(RX_LED, OUTPUT);
-  
+
   pinMode(CS_PIN, OUTPUT);
   digitalWrite(CS_PIN, HIGH);
 
-  Serial.begin(9600);
+//  Serial.begin(9600);
   Serial1.begin(9600);
+  rtiSerial.begin(2400);
 
   Mouse.begin();
   Keyboard.begin();
+
+  pinMode(MOBILE_CHARGER_PIN, OUTPUT);
+  analogWrite(MOBILE_CHARGER_PIN, 0);
 }
 
 void loop() {
   currentMillis = millis();
-  
+
   if (Serial1.available())
     read_lin_bus();
 
   release_keys();
   check_ignition_key();
+  rti();
 }
 
 void read_lin_bus() {

    case JOYSTICK_RIGHT:
      move_mouse(1, 0);
      break;
  }  
}

void handle_buttons() {
  switch (frame.get_byte(2)) {
    case BUTTON_BACK:
      if (!lastBackDown) 
        Keyboard.press(KEY_ESC); 
       
      lastBackDown = currentMillis;
      break;
      
    case BUTTON_ENTER:
      if (!lastEnterDown)
        Mouse.press(); 
      
      lastEnterDown = currentMillis;
      break;
  }
}

void move_mouse(int dx, int dy) {
  Mouse.move(dx * mouseSpeed, dy * mouseSpeed, 0); 
  lastMouseDown = currentMillis;
  mouseSpeed += MOUSE_SPEEDUP;
}

void release_keys() {
  if (lastEnterDown && currentMillis - lastEnterDown > CLICK_TIMEOUT) {
    Mouse.release();
    lastEnterDown = 0;
  }
  
  if (lastBackDown && currentMillis - lastBackDown > CLICK_TIMEOUT) {
    Keyboard.release(KEY_ESC);
    lastBackDown = 0;
  }

  if (lastMouseDown && currentMillis - lastMouseDown > CLICK_TIMEOUT) { 
    lastMouseDown = 0;
    mouseSpeed = MOUSE_BASE_SPEED;
  }
}

void check_ignition_key() {
   if (lastHeartbeat && currentMillis - lastHeartbeat > HEARTBEAT_TIMEOUT) {
     lastHeartbeat = 0;
     turn_off();
   }
}

void turn_off() {
  Serial.println("TURN OFF");
}

// -- debugging


  if (b == SYN_FIELD && n > 2 && frame.get_byte(n - 1) == 0) {
    digitalWrite(RX_LED, LOW);

    frame.pop_byte();
    handle_swm_frame();
    frame.reset();

    digitalWrite(RX_LED, HIGH);
  } else if (n == LinFrame::kMaxBytes) {
    frame.reset();
