 #include <Wire.h>
+#include <RingBufCPP.h>
 #include "LCD.h"
 #include "Motor.h"
 
 #define I2C_ADDRESS 0x1A
 #define I2C_BUFFER_SIZE 32
+#define MAX_NUM_ELEMENTS 30
 #define LCD_TX_PIN 10
 #define LCD_ROWS 4
 #define LCD_COLUMNS 20

// L  :  0  5  5     F  :  0  5  5     R  :  0  5  5
void loop()
{
  lcd.set_cursor(1, 0);
  lcd.print("M1: %s", motor1.status());
  lcd.set_cursor(1, 9);
  lcd.print("M2: %s", motor2.status());
  lcd.set_cursor(3, 0);
  lcd.print("L:%03d F:%03d R:%03d", sensor_left, sensor_front, sensor_right);
  delay(1000);
}

void requestEvent()

  {
    return;
  }
  byte internal_address = Wire.read();

  if (internal_address == MOTOR1_ADDRESS || internal_address == MOTOR2_ADDRESS)
  {
    if (!Wire.available())
    {
      return;
    }
    byte direction = Wire.read();

    if (!Wire.available())
    {
      return;
    }
    byte speed = Wire.read();

    struct Event e;
    e.internal_address = internal_address;
    e.direction = direction;
    e.speed = speed;
    buf.add(e);
  }
}

void motor_event(Motor *motor, byte direction, byte speed)
{
  if (0x01 == direction)
  {
    motor->forward(speed);
