#include <LiquidCrystal_I2C.h>
#include <IRremote.h>
#include <Adafruit_NeoPixel.h>
//Joystick button codes
#define JOYSTICK_UP 1
#define JOYSTICK_CENTER 2
#define JOYSTICK_LEFT 3
#define JOYSTICK_DOWN 4
#define JOYSTICK_RIGHT 5
//IR remote button codes 
#define IRButton_1 1
#define IRButton_2 2
#define IRButton_3 3
#define IRButton_4 4
#define IRButton_5 5
#define IRButton_6 6
#define IRButton_7 7
#define IRButton_8 8
#define IRButton_9 9
#define IRButton_STAR 10 //*
#define IRButton_0 11 
#define IRButton_SHARP 12 //#
#define IRButton_UP 13
#define IRButton_LEFT 14 
#define IRButton_OK 15 
#define IRButton_RIGHT 16 
#define IRButton_DOWN 17 

LiquidCrystal_I2C lcd(0x20, 16, 2);

void setup() {
  
  Joystick_Init();
  Pot_Init();
  Photosensor_Init();
  IR_Init();
  RGB_Init();
  LCD_Init(&lcd);

  Serial.begin(115200);
  Serial.println("Start");
  pinMode(13, OUTPUT);
}

void loop() {
    IR_Check();
    Joystick_Check();

    //IR-digit read example
    lcd.setCursor(0,0);
    lcd.print("IR digit=");
    int8_t a = IR_isDigitPressed();
    if (a != -1) lcd.print(a);

    //IR-button read and RGB example
    if (IR_isButtonPressed(IRButton_OK)) RGB_SetColor(0, 0, 50);

    //joystick read and RGB example
    if (Joystick_isButtonPressed(JOYSTICK_CENTER)) RGB_SetColor(50, 0, 0);

    //photo read example
    lcd.setCursor(0,1);
    lcd.print("Photo=");
    lcd.print(Photosensor_Read());
    lcd.print("   ");

    //lamp show off state example
    lcd.setCursor(15,1);
    lcd.write(0);

    delay(1);
}
