#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
typedef enum {
START,
RUNNING,
GAMEOVER
} State;
typedef enum {
LEFT,
UP,
RIGHT,
DOWN
} Direction;
char message[] = "Hello World \x84\x94\x81 \x8E\x99\x9A \xe1 \x01 \x1A\x1B\x12 \x1A\x1B\x1D \x1e\x1f \x18\x19\x17 \xa9";
int x, minX;
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC);
Serial.println(message);
// display.setTextSize(2);
display.setTextSize(4);
display.setTextColor(WHITE);
display.setTextWrap(false);
x = display.width();
// minX = -12 * strlen(message); // 12 = 6 pixels/character * text size 2
minX = -24 * strlen(message); // 12 = 6 pixels/character * text size 2
}
void loop() {
Serial.println(x);
display.clearDisplay();
display.setCursor(x, 10);
display.print(message);
display.display();
if(--x < minX) x = display.width();
}