#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);
#define NUMFLAKES 10 // Number of snowflakes in the animation example
#define LOGO_HEIGHT 31
#define LOGO_WIDTH 33
static const unsigned char PROGMEM logo_bmp[] =
{ 0xff, 0xff, 0xff, 0xff, 0x80, 0xff, 0xf8, 0x1f, 0xff, 0x80, 0xff, 0xc0, 0x03, 0xff, 0x80, 0xff,
0x00, 0x00, 0xff, 0x80, 0xfe, 0x00, 0x00, 0x7f, 0x80, 0xfc, 0x00, 0x00, 0x3f, 0x80, 0xf8, 0x00,
0x00, 0x1f, 0x80, 0xf0, 0xe0, 0x03, 0x0f, 0x80, 0xf0, 0xff, 0xef, 0x07, 0x80, 0xe0, 0xff, 0xff,
0x07, 0x80, 0xe0, 0xff, 0xff, 0x03, 0x80, 0xc0, 0xff, 0xff, 0x03, 0x80, 0xc1, 0xff, 0xff, 0x83,
0x80, 0xc1, 0xff, 0xff, 0x83, 0x80, 0xc1, 0xff, 0xff, 0x81, 0x80, 0xc1, 0xff, 0xff, 0x81, 0x80,
0xc1, 0xff, 0xff, 0x81, 0x80, 0xc1, 0xff, 0xff, 0x83, 0x80, 0xc1, 0xff, 0xff, 0x83, 0x80, 0xc0,
0xff, 0xff, 0x03, 0x80, 0xe0, 0x7f, 0xfe, 0x03, 0x80, 0xe2, 0x1f, 0xf8, 0x07, 0x80, 0xe1, 0x07,
0xe0, 0x07, 0x80, 0xf1, 0x8f, 0xf0, 0x0f, 0x80, 0xf8, 0xff, 0xf0, 0x0f, 0x80, 0xfc, 0x7f, 0xf0,
0x1f, 0x80, 0xfe, 0x0f, 0xf0, 0x3f, 0x80, 0xff, 0x0f, 0xf0, 0x7f, 0x80, 0xff, 0x8f, 0xf1, 0xff,
0x80, 0xff, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0x80};
void setup() {
Serial.begin(9600);
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c)) { // Address 0x3c for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// Clear the buffer
int16_t i;
for(i=0;i<display.width()-33;i+=3){
display.clearDisplay();
display.drawBitmap(i,20,logo_bmp,LOGO_WIDTH ,LOGO_HEIGHT,SSD1306_WHITE );
display.display();
delay(2000); // Pause for 2 seconds
}
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}
/*
display.clearDisplay();
display.setTextSize(1); // 設定文字大小
display.setTextColor(1); // 1:OLED預設的顏色(這個會依該OLED的顏色來決定)
display.setCursor(5,0); // 設定起始座標
display.print("Hello OLED"); // 要顯示的字串
display.setCursor(26,40); // 設定起始座標
display.print("STUST"); // 要顯示的字串
display.display(); */