#include <LiquidCrystal_I2C.h>
#include <timeObj.h>
#include <blinker.h>


LiquidCrystal_I2C lcd(0x27,16,2);  // Set the LCD address to 0x27 for a 16 chars and 2 line display
timeObj flashTimer(1000);
bool    labelOn;
blinker ourBlinker;


void setup() {

  lcd.init();                       // initialize the lcd
  lcd.backlight();                  // Do the backlight thing.
  lcd.setCursor(2,0);               // Move cursor position.
  lcd.print("Hello, world!");       // Spit out message at cursor position.
  labelOn = false;                  // Set blinking state. (Not showing)
  ourBlinker.setOnOff(true);
}


void loop() {
  
  idle();                               // Let background tasks, like the LED blinker, run.
  if (flashTimer.ding()) {              // If our timer expires..
    lcd.setCursor(0,1);                 // Set our cursor position.
    if (labelOn) {                      // If the text is showing..
      lcd.print("                ");    // Blank out the line. (16 spaces)
    } else {                            // Else the text is NOT showing..
      lcd.print("   Blink me!");        // Print the text.
    }                                   //
    labelOn = !labelOn;                 // Swap the state if the text.
    flashTimer.start();                 // restart the timer.
  }
}