#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define MAX_DEVICES 1 // DEFINE THE MAXIMUM NUMBER OF DISPLAY
#define CLK_PIN 21 // CLK FOR ARUDINO MEGA 
#define DATA_PIN 20 // DATA  pin for arudino mega

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define NUMFLAKES     10 // Number of snowflakes in the animation example

#define LOGO_HEIGHT   16
#define LOGO_WIDTH    16

int value = 0;

static const unsigned char PROGMEM logo_bmp[] =
{ B00000000, B11000000,
  B00000001, B11000000,
  B00000001, B11000000,
  B00000011, B11100000,
  B11110011, B11100000,
  B11111110, B11111000,
  B01111110, B11111111,
  B00110011, B10011111,
  B00011111, B11111100,
  B00001101, B01110000,
  B00011011, B10100000,
  B00111111, B11100000,
  B00111111, B11110000,
  B01111100, B11110000,
  B01110000, B01110000,
  B00000000, B00110000 };

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200); // setup serial
  attachInterrupt(0,displaymic,RISING); //start the int.0   // opton 1 to configure hardware/external interupt
  //attachInterrupt(digitalPinToInterrupt(20), displaymic,RISING); // option 2 
 if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
  display.display();
  delay(2000);
  display.clearDisplay();
}

//ISR - external interupt
void displaymic(){
  value =1;
}

void loop() {
  // put your main code here, to run repeatedly:
  // turn on/off LED\
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.drawPixel(10, 10, SSD1306_WHITE);
  display.setCursor(2,20);

  
  if (value ==1){
    display.clearDisplay();
    display.setCursor(2,20);
    display.print("Rosario");
    display.display();
    delay(1000);
    value=0;
  }
  else{
    display.clearDisplay();
    display.setCursor(2,20);
    display.print("I LOVE SWINBURNE");
    display.display();
    delay(1000);
    
  }

  delay(100);
  display.clearDisplay(); 

}