Created
December 7, 2017 06:29
-
-
Save deladriere/9c5669f359ae4551fb08ffa6b980d181 to your computer and use it in GitHub Desktop.
Adafruit SSD1306 I2C text speed test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <Wire.h> | |
#include <Adafruit_GFX.h> | |
#include <Adafruit_SSD1306.h> | |
#define OLED_RESET 4 | |
Adafruit_SSD1306 display(OLED_RESET); | |
long I2C_clock=250000; | |
long pot; | |
unsigned long thisMicros = 0; | |
unsigned long lastMicros = 0; | |
void setup() { | |
// Serial.begin(9600); | |
Wire.begin(); | |
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); | |
display.display(); | |
display.clearDisplay(); | |
display.setTextSize(2); | |
display.setTextColor(WHITE); | |
} | |
void loop() | |
{ | |
pot=analogRead(5);// pot on A5 to play with the I2C clock | |
I2C_clock=map(pot,1023,0,100L,4000L); | |
I2C_clock=I2C_clock*1000L; | |
Wire.setClock(I2C_clock); | |
thisMicros = micros(); | |
display.clearDisplay(); | |
display.setCursor(0,0); | |
display.print(thisMicros - lastMicros); | |
display.setCursor(0,20); | |
display.print(I2C_clock); | |
display.setCursor(0,40); | |
display.print(pot); | |
display.display(); | |
lastMicros = thisMicros; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment