#include <Adafruit_SSD1306.h>
#include <Wire.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define next 4
#define select 7
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
const int NUM_OPTIONS = 3;
const String options[NUM_OPTIONS] = {"Classical Mode", "Multiplayer Mode", "Memory Mode"};
int selectedOption = 0;
int cursorPosition = 0;
void setup() {
Serial.begin(9600);
pinMode(next, INPUT_PULLUP);
pinMode(select, INPUT_PULLUP);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
printMenu();
}
void loop() {
if(digitalRead(next) == LOW) {
Serial.println("Button pressed");
delay(50);
cursorPosition++;
if(cursorPosition >= NUM_OPTIONS) {
cursorPosition = 0;
}
selectedOption = cursorPosition;
printMenu();
}
else if(digitalRead(select) == LOW) {
delay(50);
switch(selectedOption) {
case 0:
break;
case 1:
// Multiplayer Mode code here
break;
case 2:
// Memory Mode code here
break;
}
printMenu();
}
}
void printMenu() {
display.clearDisplay();
for(int i = 0; i < NUM_OPTIONS; i++) {
if(i == selectedOption) {
display.setCursor(0, cursorPosition * 8);
display.print(">");
display.setCursor(8, cursorPosition * 8);
display.println(options[i].c_str());
}
else {
display.setCursor(0, i * 8);
display.println(options[i].c_str());
}
}
display.display();
}