#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
/* Uncomment the initialize the I2C address , uncomment only one, If you get a totally blank screen try the other*/
#define i2c_Address 0x3c //initialize with the I2C addr 0x3C Typically eBay OLED's
//#define i2c_Address 0x3d //initialize with the I2C addr 0x3D Typically Adafruit OLED's
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // QT-PY / XIAO
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
Serial.begin(9600);
display.begin(i2c_Address, true); // Address 0x3C default
//display.setContrast (0); // dim display
// Clear the buffer.
display.clearDisplay();
}
void loop(){
// draw many lines
testdrawline();
display.display();
delay(2000);
display.clearDisplay();
}
void testdrawline() {
for (int16_t i = 0; i < display.width(); i += 4) {
display.drawLine(0, 0, i, display.height() - 1, SH110X_WHITE);
display.display();
delay(1);
}
for (int16_t i = 0; i < display.height(); i += 4) {
display.drawLine(0, 0, display.width() - 1, i, SH110X_WHITE);
display.display();
delay(1);
}
delay(250);
}