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

int pot1 = A0;
int pin1 = 2;

int potVal;

int menuVal = 0;

int buttonVal;
int oldButtonVal = -1;

long oldButtonTime = 0;

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3D
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


void setup() {
  pinMode(pot1, INPUT);
  pinMode(pin1, INPUT_PULLUP);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3c);
  display.clearDisplay();
  display.setTextSize(1);
  display.display();

}

void loop() {

  potVal = analogRead(pot1);
  buttonVal = digitalRead(pin1);

  long buttonTime = millis();

  if ((buttonVal == LOW) && ((buttonTime - oldButtonTime) > 500)){
    oldButtonTime = buttonTime;
    menuVal++;
  }

  if (menuVal == 2){
    menuVal = 0;
    oldButtonVal = -1;
  }

  if (menuVal == 0){
    homeScreen();
  }

  if (menuVal == 1){
    mainMenu();
  }
}

void homeScreen(){
  if (buttonVal != oldButtonVal){
    display.clearDisplay();
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println("Jake Smith");
    display.print("Technology");
    display.display();
  }
}

void mainMenu(){
  display.clearDisplay();
  display.display();
}