/*********
Complete project details at https://randomnerdtutorials.com
This is an example for our Monochrome OLEDs based on SSD1306 drivers. Pick one up today in the adafruit shop! ------> http://www.adafruit.com/category/63_98
This example is for a 128x32 pixel display using I2C to communicate 3 pins are required to interface (two I2C and one reset).
Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries, with contributions from the open source community. BSD license, check license.txt for more information All text above, and the splash screen below must be included in any redistribution.
*********/
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <U8g2_for_Adafruit_GFX.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);
U8G2_FOR_ADAFRUIT_GFX u8g2_for_adafruit_gfx;
#define NUMFLAKES 10 // Number of snowflakes in the animation example
#define LOGO_HEIGHT 16
#define LOGO_WIDTH 16
#define LINE_HEIGHT 9
#define FONT_HEIGHT 6
static uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8];
void setup() {
// 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
}
u8g2_for_adafruit_gfx.begin(display);
// Show initial display buffer contents on the screen --
// the library initializes this with an Adafruit splash screen.
display.clearDisplay();
// Draw a single pixel in white
//display.drawPixel(10, 10, WHITE);
// Show the display buffer on the screen. You MUST call display() after
// drawing commands to make them visible on screen!
//display.display();
//delay(2000); // Pause for 2 seconds
}
int lineNumber(int ln) {
int result ;
result = LINE_HEIGHT * ln + FONT_HEIGHT ;
return result ;
}
void loop() {
display.clearDisplay();
u8g2_for_adafruit_gfx.setFontMode(1); // use u8g2 transparent mode (this is default)
u8g2_for_adafruit_gfx.setFontDirection(0); // left to right (this is default)
u8g2_for_adafruit_gfx.setForegroundColor(WHITE); // apply Adafruit GFX color
u8g2_for_adafruit_gfx.setFont(u8g2_font_5x7_tf); // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall
//u8g2_for_adafruit_gfx.setFont(u8g2_font_tinytim_tf); // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall
//u8g2_for_adafruit_gfx.setFont(u8g2_font_helvR14_tf); // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall
u8g2_for_adafruit_gfx.setCursor(0,lineNumber(0)); // start writing at this position
u8g2_for_adafruit_gfx.print(F("Eingangsdaten:"));
u8g2_for_adafruit_gfx.setCursor(0,lineNumber(1));
u8g2_for_adafruit_gfx.print(F("V1: 39%"));
u8g2_for_adafruit_gfx.setCursor(0,lineNumber(2));
u8g2_for_adafruit_gfx.print(F("V2: 71%"));
u8g2_for_adafruit_gfx.setCursor(0,lineNumber(3));
u8g2_for_adafruit_gfx.print(F("V3: 62%"));
display.display(); // make everything visible
delay(2000);
}