39 lines
932 B
C++
39 lines
932 B
C++
// Simple I2C test for ebay 128x64 oled.
|
|
|
|
#include <Wire.h>
|
|
#include "SSD1306Ascii.h"
|
|
#include "SSD1306AsciiWire.h"
|
|
|
|
// 0X3C+SA0 - 0x3C or 0x3D
|
|
#define I2C_ADDRESS 0x3C
|
|
|
|
// Define proper RST_PIN if required.
|
|
#define RST_PIN -1
|
|
|
|
SSD1306AsciiWire oled;
|
|
//------------------------------------------------------------------------------
|
|
void setup() {
|
|
Wire.begin();
|
|
Wire.setClock(400000L);
|
|
|
|
#if RST_PIN >= 0
|
|
oled.begin(&Adafruit128x64, I2C_ADDRESS, RST_PIN);
|
|
#else // RST_PIN >= 0
|
|
oled.begin(&Adafruit128x64, I2C_ADDRESS);
|
|
#endif // RST_PIN >= 0
|
|
|
|
oled.setFont(Adafruit5x7);
|
|
|
|
uint32_t m = micros();
|
|
oled.clear();
|
|
oled.println("Hello world!");
|
|
oled.println("A long line may be truncated");
|
|
oled.println();
|
|
oled.set2X();
|
|
oled.println("2X demo");
|
|
oled.set1X();
|
|
oled.print("\nmicros: ");
|
|
oled.print(micros() - m);
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
void loop() {}
|