var five = require("johnny-five");
var board = new five.Board();

board.on("ready", function() {
  var count = 0;
  var l = new five.LCD({
    controller: "PCF8574",
    address: 0x20
  });

  l.home();
  l.clear();

  l.print("012345678901");

  setInterval(function() {
    count++;

    if (count === 1) {
      l.clear();
      l.cursor(0, 0).print("0123456789012345");
    }

    if (count === 2) {
      l.clear();
      l.cursor(0, 0).print("0123456789012345");
      l.cursor(1, 0).print("0123456789012345");
    }

    if (count === 3) {
      l.clear();
      l.useChar("heart");
      l.cursor(0, 0).print("hello :heart:");
      l.blink();
      l.cursor(1, 0).print("Blinking? ");
    }

    if (count === 4) {
      l.clear();
      l.cursor(0, 0).print(" ".repeat(16));
      l.cursor(1, 0).print(" ".repeat(16));
    }

    if (count === 5) {
      l.clear();
      l.cursor(0, 0).print("*".repeat(16));
      l.cursor(1, 0).print("*".repeat(16));
    }

  }, 1000);

  this.repl.inject({
    clear: function() {
      l.clear();
      l.cursor(0, 0).print("cleared!");
    }
  });
});
