#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
// Display configuration
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128
#define OLED_RESET -1
#define i2c_Address 0x3C // I2C address (common for SH1107)
Adafruit_SH1107 display = Adafruit_SH1107(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// Button pins configuration
#define BUTTON_A 12
#define BUTTON_B 14
#define BUTTON_C 27
// Button states
bool buttonAState = HIGH;
bool buttonBState = HIGH;
bool buttonCState = HIGH;
bool lastButtonAState = HIGH;
bool lastButtonBState = HIGH;
bool lastButtonCState = HIGH;
// Debounce timing
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 50;
//Define FPS
byte FPS = 30;
void update() {
if(digitalRead(BUTTON_A) == LOW) {
buttonAState = LOW;
}
}
void updatePerFps(){
if(millis()%((int)1000/FPS)) {
}
}
void setup() {
Serial.begin(115200);
// Initialize display
if(!display.begin(i2c_Address, true)) {
Serial.println(F("SH1107 allocation failed"));
for(;;); // Don't proceed, loop forever
}
display.display();
delay(2000); // Pause for 2 seconds
display.clearDisplay();
display.display();
// Set up buttons with internal pullup
pinMode(BUTTON_A, INPUT_PULLUP);
pinMode(BUTTON_B, INPUT_PULLUP);
pinMode(BUTTON_C, INPUT_PULLUP);
// Set display parameters
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.println("test");
}
void loop() {
update();
updatePerFps();
}