#define SDA 22
#define SCL 14
#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 -1 // 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 16
#define LOGO_WIDTH 16
static const unsigned char PROGMEM logo_bmp[] =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000 };
static const unsigned char name[] = {
0x10, 0x00, 0x00, 0x40, 0x04, 0x10,
0x10, 0x00, 0x22, 0x40, 0x84, 0x10,
0x23, 0xf8, 0x12, 0x40, 0x44, 0x28,
0x20, 0x08, 0x13, 0xfc, 0x1f, 0x44,
0x48, 0x08, 0x84, 0x40, 0x84, 0x82,
0xf0, 0x08, 0x48, 0x40, 0x5f, 0x00,
0x10, 0x08, 0x40, 0x40, 0x51, 0xee,
0x23, 0xf8, 0x17, 0xfe, 0x1f, 0x22,
0x42, 0x08, 0x10, 0x00, 0x31, 0xaa,
0xfa, 0x00, 0x20, 0x00, 0x5f, 0x66,
0x42, 0x00, 0xe3, 0xf8, 0xc4, 0x22,
0x02, 0x02, 0x22, 0x08, 0x5f, 0x66,
0x1a, 0x02, 0x22, 0x08, 0x44, 0xaa,
0xe2, 0x02, 0x22, 0x08, 0x44, 0x22,
0x41, 0xfe, 0x23, 0xf8, 0x44, 0xaa,
0x00, 0x00, 0x02, 0x08, 0x04, 0x44
};
void setup() {
Serial.begin(115200);
Wire.begin(/*SDA*/SDA,/*SCL*/SCL);
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// Show initial display buffer contents on the screen --
// the library initializes this with an Adafruit splash screen.
display.display();
delay(2000); // Pause for 2 seconds
// display.display() is NOT necessary after every single drawing command,
// unless that's what you want...rather, you can batch up a bunch of
// drawing operations and then update the screen all at once by calling
// display.display(). These examples demonstrate both approaches...
// testdrawchar(); // Draw characters of the default font
testdrawname();
}
void loop() {
}
void testdrawname(void){
display.clearDisplay();
// display.drawBitmap(0, 0, name, 128, 64, 1);
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(28,28);
display.println("jhh");
display.setCursor(52,28);
display.println("&&");
display.setCursor(70,28);
display.println("zsm");
display.display();
}
void testdrawchar(void) {
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(0, 0); // Start at top-left corner
display.cp437(true); // Use full 256 char 'Code Page 437' font
// Not all the characters will fit on the display. This is normal.
// Library will draw what it can and the rest will be clipped.
for(int16_t i=0; i<256; i++) {
if(i == '\n') display.write(' ');
else display.write(i);
}
display.display();
delay(2000);
}