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

Adafruit_SH1107 display = Adafruit_SH1107(64, 128, &Wire);

String textBuffer = "OFIR HOTEL OFIR HOTEL";
int nextCahrPos = 0;
int logoTextSize = 11;
int textSize = 5;
int startPos = 127;

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("\nserial port is available.");
  Serial.println("Initializes the display.");
  delay(250); // wait for the OLED to power up
  display.begin(0x3C, true); // Address 0x3C default
  delay(250);
  Serial.println("OLED begun");
  Serial.println("Show image buffer on the display hardware.");
  display.display();
  delay(1000);
  Serial.println("Sets the display parameters.");
  display.setRotation(0);
  display.setTextSize(textSize);
  display.setTextColor(SH110X_WHITE);
  display.setCursor(0,0);
  display.clearDisplay();
  display.display();
  delay(10);
  Serial.println("Display setup has been completed successfully.");
}

void loop() {
  for (int y = startPos; y >= -41; y--) {
    display.clearDisplay();
    for (int i = 0; i < 5; i++) {
      display.setCursor(20, y + (i * 42));
      display.print(textBuffer.charAt(i + nextCahrPos));
    }
    //delay(1);
    yield();
    display.display();
  }
  startPos = 0;
  nextCahrPos++;
  if (nextCahrPos > 10) nextCahrPos = 0;
}