 #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

  {
    return;
  }

  byte internal_address = Wire.read();
  switch (internal_address)
  {
  case MOTOR1_ADDRESS:
    motor_event(&motor1, receive_size - 1);
    break;
  case MOTOR2_ADDRESS:
    motor_event(&motor2, receive_size - 1);
    break;
  default:
    return;
  }
}

void motor_event(Motor *motor, int receive_size)
{
  if (!Wire.available())
  {
    return;
  }
  byte direction = Wire.read();
  if (!Wire.available())
  {
    return;
  }
  byte speed = Wire.read();
  if (0x01 == direction)
  {
    motor->forward(speed);

// L  :  0  5  5     F  :  0  5  5     R  :  0  5  5
void loop()
{
  struct Event e;

  while (buf.pull(&e))
  {
    switch (e.internal_address)
    {
    case MOTOR1_ADDRESS:
      motor_event(&motor1, e.direction, e.speed);
      break;
    case MOTOR2_ADDRESS:
      motor_event(&motor2, e.direction, e.speed);
      break;
    }
  }
  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(2000);
}

void requestEvent()
