Biblio­thek u8g2

Lese­zeit: 11 Minu­ten

Die Biblio­thek u8g2 kann eine Viel­zahl von OLED-Dis­plays ansteuern.

Typ­be­zeich­nungOLED 0,96 Zoll SSD1306OLED 1,3 Zoll SH1106OLED 2,42 Zoll SSD1309
AnschlussI2CI2CSPI

Pin­be­le­gung eines OLED-Dis­plays mit I2C am Arduino

Pin­be­le­gung eines OLED mit SPI

GND -> GND
VCC -> 5V
SCK -> 13
SDA -> 11
RS  ->  8
DC  ->  9
CS  -> 10

Benö­tig­te Bibliothek:

Die ver­schie­de­nen OLEDs müs­sen je nach Typ unter­schied­lich initia­li­siert werden:

0,96 Zoll mit I2C-Ansteue­rung (SSD1306)
U8G2_SSD1306_128X64_NONAME_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

1,3 Zoll mit I2C-Ansteue­rung (SH1106)
U8G2_SH1106_128X64_NONAME_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

2,42 Zoll mit SPI-Ansteue­rung (SSD1309)
U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI oled(U8G2_R0, 10, 9, 8);

Biblio­thek ein­bin­den und Dis­play initialisieren
# include "U8g2lib.h"

// 1,3 Zoll SH1106
U8G2_SH1106_128X64_NONAME_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

// 0,96 Zoll SSD1306
// U8G2_SSD1306_128X64_NONAME_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

// 2,42 Zoll SSD1309
U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI oled(U8G2_R0, 10, 9, 8);
Ansteue­rung

Hier sol­len die Dis­plays mit den Chip­sät­zen SSD1306 und SH1106 und I2C betrach­tet wer­den.
Die Biblio­thek kennt zwei ver­schie­de­ne Modi den Bild­schirm anzusprechen:

Page buf­fer mode: lang­sam, wenig Speicherbedarf

Full screen buf­fer mode schnell, sehr hoher Spei­cher­be­darf mit dem Hin­weis Spei­cher­platz- und Sta­bi­li­täts­pro­ble­me beim UNO R3

Sie unter­schei­den sich in der Initia­li­sie­rung und in der Programmierung:

Page buf­fer mode (1 hin­ter NONAME)

/*
  Typbezeichnung mit Bildschirmgröße in Pixeln
  1 = page buffer mode, F = full screen buffer mode 
  Hardware I2C/Hardware SPI
  Name des OLEDs
  Rotation R0 (keine)
*/
// 0,96 Zoll SSD1306
U8G2_SSD1306_128X64_NONAME_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

// 1,3 Zoll SH1106
// U8G2_SH1106_128X64_NONAME_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

// 2,42 Zoll SSD1309
// U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI oled(U8G2_R0, 10, 9, 8);

Full screen buf­fer mode (F hin­ter NONAME)

// 0,96 Zoll SSD1306
U8G2_SSD1306_128X64_NONAME_F_HW_I2C oled(U8G2_R0,  U8X8_PIN_NONE);

// 1,3 Zoll SH1106
// U8G2_SH1106_128X64_NONAME_F_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

// 2,42 Zoll SSD1309
// U8G2_SSD1309_128X64_NONAME2_F_4W_HW_SPI oled(U8G2_R0, 10, 9, 8);
Dar­stel­lung der Inhalte

Page buf­fer mode:

# include "U8g2lib.h"

/*
  Typbezeichnung mit Bildschirmgröße in Pixeln
  1 = page buffer mode, F = full screen buffer mode 
  Hardware I2C/Hardware SPI
  Name des OLEDs
  Rotation R0 (keine)
*/
// 0,96 Zoll SSD1306
U8G2_SSD1306_128X64_NONAME_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

// 1,3 Zoll SH1106
// U8G2_SH1106_128X64_NONAME_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

// 2,42 Zoll SSD1309
// U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI oled(U8G2_R0, 10, 9, 8);

void setup() 
{
  oled.begin();
}

void loop() 
{
  // Farbe weiß
  oled.setDrawColor(1);

  oled.firstPage();
  do 
  {
    // Rahmen mit abgerundeten Ecken an den Bildschirmrändern zeichnen
    oled.drawRFrame(0, 0, 128, 64, 5);
  } 
  while (oled.nextPage());
}

Full screen buf­fer mode:

# include "U8g2lib.h"

/*
  Typbezeichnung mit Bildschirmgröße in Pixeln
  1 = page buffer mode, F = full screen buffer mode 
  Hardware I2C/Hardware SPI
  Name des OLEDs
  Rotation R0 (keine)
*/
// 0,96 Zoll SSD1306
U8G2_SSD1306_128X64_NONAME_F_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

// 1,3 Zoll SH1106
// U8G2_SH1106_128X64_NONAME_F_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

// 2,42 Zoll SSD1309
// U8G2_SSD1309_128X64_NONAME2_F_4W_HW_SPI oled(U8G2_R0, 10, 9, 8);

void setup() 
{
  oled.begin();
}

void loop() 
{
  // Farbe weiß
  oled.setDrawColor(1);

  oled.clearBuffer();

  // Rahmen mit abgerundeten Ecken an den Bildschirmrändern zeichnen
  oled.drawRFrame(0, 0, 128, 64, 5);

  oled.sendBuffer();
}

Funk­tio­nen der Biblio­thek u8g2

Schlüs­sel­wortPara­me­terAkti­on
begin();OLED star­ten
get­Dis­play­Width();Bild­schirm­brei­te feststellen
get­Dis­play­H­eight();Bild­schirm­hö­he feststellen
cle­ar­Dis­play();Bild­schirm dun­kel schalten
setdrawColor(Parameter)0 → schwarz
1 → weiß
Zei­chen­far­be festlegen
setContrast(Parameter)0 ... 255Kon­trast einstellen
setDisplayRotation(U8G2_R*);U8G2_R0 → 0 Grad
U8G2_R1 → 90 Grad
U8G2_R2 → 180 Grad
U8G2_R3 → 270 Grad
Anzei­ge drehen
flipMode(Parameter);0 → nor­ma­le Ausrichtung
1 → 180 Grad drehen
wirk­sam erst bei einer Rotation
Anzei­ge spie­geln (180 Grad)
home();Cur­sor in die lin­ke obe­re Ecke setzen
drawPixel(x-Achse, y-Ach­se)ein­zel­nen Pixel zeichnen
drawLine(StartX, StartX, End­eX, EndeY);Linie zeich­nen
drawHLine(StartX, Star­tY, Länge);hori­zon­ta­le Linie zeichnen
drawVLine(StartX, Star­tY, Länge);ver­ti­ka­le Linie zeichnen
drawFrame(StartX, Star­tY,, Brei­te, Höhe);Recht­eck zeichnen
drawRFrame(StartX, Star­tY, Brei­te, Höhe, Eckenradius);abge­run­de­tes Recht­eck zeichnen
drawBox(StartX, Star­tY, Brei­te, Höhe);aus­ge­füll­tes Recht­eck zeichnen
drawCircle(MittelpunkX, Mit­tel­punk­tY, Radi­us, Kreisausschnitt);U8G2_DRAW_UPPER_RIGHT
U8G2_DRAW_UPPER_LEFT
U8G2_DRAW_LOWER_RIGHT
U8G2_DRAW_LOWER_LEFT
U8G2_DRAW_ALL
Kreis zeich­nen
Vier­tel­kreis oben rechts
Vier­tel­kreis oben links
Vier­tel­kreis unten rechts
Vier­tel­kreis unten links
vol­ler Kreis
drawDisc(MittelpunkX, Mit­tel­punk­tY, Radius);Aus­ge­füll­ten Kreis zeichnen
drawEllipse(StartX, Star­tY, Radi­usX, RadiusY);Ellip­se zeichnen
drawXBM(StartX, Star­tY, Brei­te, Höhe, Array_Bilddatei);XBM-Bild anzei­gen
setCursor(x-Achse, y-Ach­se);Cur­sor setzen
setFont(Schriftart)Bei­spie­le für funk­tio­nie­ren­de Schriftarten:
Schrift­hö­he in Pixeln (px)
6px: u8g2_font_5x7_tr
7px: u8g2_font_torussansbold8_8r 
8px: u8g2_font_ncenB08_tr
10px: u8g2_font_t0_15b_me 
12px: u8g2_font_helvB12_tf 
13px: u8g2_font_t0_22_te
14px: u8g2_font_helvB14_tf
17px: u8g2_font_timB18_tf
18px: u8g2_font_lubB18_tr
20px: u8g2_font_courB24_tf
23px: u8g2_font_timB24_tf
25px: u8g2_font_helvR24_tf
32px: u8g2_font_logisoso32_tf
42px: u8g2_font_fub42_tf
58px: u8g2_font_logisoso58_tf
62px: u8g2_font_logisoso62_tn
Schrift­art
print("Text");
drawStr(StartX, Star­tY ,"Text");
Text schrei­ben
setFontDirection(Wert);0 → nor­mal ausgerichtet
1 → 90 ° gedreht
2 → 180 ° gedreht
3 → 270 ° gedreht
Schreib­rich­tung

Quel­le: 🔗https://​git​hub​.com/​o​l​i​k​r​a​u​s​/​u​8​g​2​/​w​i​k​i​/​u​8​g​2​r​e​f​e​r​e​n​cel

wei­te­re Schrift­ar­ten: 🔗https://​git​hub​.com/​o​l​i​k​r​a​u​s​/​u​8​g​2​/​w​i​k​i​/​f​n​t​l​i​s​t​all (abge­ru­fen am 9.12.22)
Du musst aus­pro­bie­ren, wel­che Schrift­ar­ten dar­ge­stellt wer­den können!

Gra­fik
draw(XBM();draw­Disc();draw­Cir­cle();draw­Li­ne();

So sieht es auf dem 0,96 Zoll OLED aus:

So sieht es auf dem 2,42 Zoll OLED aus:

XBM-Datei mit GIMP erstellen

# include "U8g2lib.h"

// 0,96 Zoll SSD1306
U8G2_SSD1306_128X64_NONAME_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

// 1,3 Zoll SH1106
// U8G2_SH1106_128X64_NONAME_1_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

// 2,42 Zoll SSD1309
// U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI oled(U8G2_R0, 10, 9, 8);

// Bildschirmgröße
int BildschirmBreite = oled.getDisplayWidth();
int BildschirmHoehe = oled.getDisplayHeight();

// Smiley XBM erstellt mit GIMP
# define SmileyBreite 46
# define SmileyHoehe 45
static unsigned char Smiley[] =
{
   0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x00,
   0x00, 0xf0, 0x07, 0xf8, 0x03, 0x00, 0x00, 0xfc, 0x00, 0xc0, 0x0f, 0x00,
   0x00, 0x3e, 0x00, 0x00, 0x1f, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x7c, 0x00,
   0xc0, 0x07, 0x00, 0x00, 0xf8, 0x00, 0xe0, 0x01, 0x00, 0x00, 0xe0, 0x01,
   0xf0, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x70, 0x00, 0x00, 0x00, 0x80, 0x03,
   0x38, 0x7e, 0x00, 0x80, 0x1f, 0x07, 0x38, 0xff, 0x00, 0xc0, 0x3f, 0x07,
   0x9c, 0xff, 0x01, 0xc0, 0x3f, 0x0e, 0x9c, 0xe7, 0x01, 0xc0, 0x39, 0x0e,
   0x8e, 0xc3, 0x01, 0xc0, 0x30, 0x1c, 0x8e, 0xe3, 0x01, 0xc0, 0x31, 0x1c,
   0x86, 0xf7, 0x01, 0xc0, 0x3b, 0x18, 0x87, 0xff, 0x01, 0xc0, 0x3f, 0x38,
   0x07, 0xff, 0x00, 0x80, 0x3f, 0x38, 0x03, 0x7e, 0x00, 0x80, 0x1f, 0x30,
   0x03, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x00, 0x30,
   0x03, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x00, 0x30,
   0x03, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x00, 0x30,
   0x07, 0x00, 0x00, 0x00, 0x00, 0x38, 0x07, 0x20, 0x00, 0x00, 0x01, 0x38,
   0x06, 0x70, 0x00, 0x80, 0x03, 0x18, 0x0e, 0xf0, 0x00, 0xc0, 0x01, 0x1c,
   0x0e, 0xe0, 0x03, 0xf0, 0x01, 0x1c, 0x1c, 0xc0, 0x3f, 0xfc, 0x00, 0x0e,
   0x1c, 0x80, 0xff, 0x7f, 0x00, 0x0e, 0x38, 0x00, 0xfc, 0x1f, 0x00, 0x07,
   0x38, 0x00, 0xc0, 0x03, 0x00, 0x07, 0x70, 0x00, 0x00, 0x00, 0x80, 0x03,
   0xf0, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xe0, 0x01, 0x00, 0x00, 0xe0, 0x01,
   0xc0, 0x07, 0x00, 0x00, 0xf8, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x7c, 0x00,
   0x00, 0x3e, 0x00, 0x00, 0x1f, 0x00, 0x00, 0xfc, 0x00, 0xc0, 0x0f, 0x00,
   0x00, 0xf0, 0x07, 0xf8, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x00,
   0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00
};

// Schneemann XBM erstellt mit GIMP
# define SchneemannBreite 28
# define SchneemannHoehe 62
static unsigned char Schneemann[] =
{
   0x00, 0xf0, 0x01, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0x0e, 0x06, 0x00,
   0x00, 0x06, 0x0c, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x03, 0x18, 0x00,
   0x00, 0x03, 0x18, 0x00, 0x00, 0x03, 0x18, 0x00, 0x00, 0x03, 0x38, 0x00,
   0xe0, 0xff, 0xff, 0x03, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0x0f, 0x1e, 0x00,
   0x80, 0x03, 0x1c, 0x00, 0x80, 0x01, 0x38, 0x00, 0xc0, 0x19, 0x37, 0x00,
   0xc0, 0x1c, 0x37, 0x00, 0xc0, 0x18, 0x27, 0x00, 0xc0, 0x00, 0x20, 0x00,
   0xc0, 0x08, 0x21, 0x00, 0xc0, 0xf9, 0x31, 0x00, 0xc0, 0xf1, 0x38, 0x00,
   0x80, 0x03, 0x38, 0x00, 0x80, 0x07, 0x1c, 0x00, 0x00, 0x1f, 0x0f, 0x00,
   0x00, 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x03, 0x04, 0x00, 0xff, 0x0f, 0x06,
   0x80, 0x07, 0x1e, 0x06, 0xc0, 0x03, 0x3c, 0x03, 0xe0, 0x00, 0x70, 0x03,
   0xf0, 0x00, 0xf0, 0x01, 0x70, 0x00, 0xe0, 0x00, 0x38, 0x00, 0xc0, 0x01,
   0x38, 0xf0, 0xc0, 0x01, 0x18, 0xf0, 0xe0, 0x01, 0x18, 0xf0, 0xb0, 0x01,
   0x0c, 0x70, 0x30, 0x03, 0x0c, 0x00, 0x18, 0x03, 0x0c, 0x00, 0x18, 0x03,
   0x0e, 0x00, 0x08, 0x07, 0x06, 0x00, 0x0f, 0x06, 0x06, 0x00, 0x0f, 0x06,
   0x06, 0x30, 0x06, 0x06, 0x06, 0x70, 0x00, 0x06, 0x06, 0xf0, 0x00, 0x06,
   0x06, 0xf0, 0x00, 0x06, 0x0e, 0x60, 0x00, 0x07, 0x0c, 0x00, 0x00, 0x03,
   0x0c, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x03,
   0x18, 0x00, 0x80, 0x01, 0x38, 0x60, 0xc0, 0x01, 0x38, 0xf0, 0xc0, 0x01,
   0x78, 0xf0, 0xe0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0x00, 0x70, 0x00,
   0xe0, 0x03, 0x7c, 0x00, 0xe0, 0x07, 0x3e, 0x00, 0xe0, 0xff, 0x3f, 0x00,
   0xc0, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00
};

void setup()
{
  // Zufallsgenerator starten
  randomSeed(A0);

  // Display starten
  oled.begin();

  // Kontrast maximal 255
  oled.setContrast(200);
}

void loop()
{
  // Farbe weiß
  oled.setDrawColor(1);

  // Smiley
  oled.firstPage();
  do
  {
    oled.drawXBM(40, 10, SmileyBreite, SmileyHoehe, Smiley);
  }
  while (oled.nextPage());
  delay(2000);

  // Schneemann
  oled.firstPage();
  do
  {
    oled.drawXBM(50, 1, SchneemannBreite, SchneemannHoehe, Schneemann);
  }
  while (oled.nextPage());
  delay(2000);

  // Pixelmuster
  oled.firstPage();
  do
  {
    for (int i = 0; i < 500; i ++)
    {
      int x = random(1, BildschirmBreite);
      int y = random(1, BildschirmHoehe);
      oled.drawPixel(x, y);
    }
  }
  while (oled.nextPage());
  delay(2000);

  oled.setFont(u8g2_font_unifont_t_symbols);

  // Text horizontal
  oled.firstPage();
  do
  {
    oled.setFontDirection(0);
    oled.setCursor(2, BildschirmHoehe / 2);
    oled.print("Text");
  }
  while (oled.nextPage());
  delay(2000);

  // Text 90 Grad gedreht
  oled.firstPage();
  do
  {
    oled.setFontDirection(1);
    oled.setCursor(BildschirmBreite / 2, 2);
    oled.print("Text");
  }
  while (oled.nextPage());
  delay(2000);

  // Text 180 Grad gedreht
  oled.firstPage();
  do
  {
    oled.setFontDirection(2);
    oled.setCursor(BildschirmBreite - 2, BildschirmHoehe / 2);
    oled.print("Text");
  }
  while (oled.nextPage());
  delay(2000);

  // Text 270 Grad gedreht
  oled.firstPage();
  do
  {
    oled.setFontDirection(3);
    oled.setCursor(BildschirmBreite / 2,  BildschirmHoehe - 2);
    oled.print("Text");
  }
  while (oled.nextPage());
  delay(2000);

  // Kreise
  oled.firstPage();
  do
  {
    for (int i = 2; i < BildschirmHoehe / 2; i += 3)
    {
      oled.drawCircle(BildschirmBreite / 2, BildschirmHoehe / 2, i);
    }
  }
  while (oled.nextPage());
  delay(2000);

  // Rahmen
  oled.firstPage();
  do
  {
    for (int i = 2; i < BildschirmHoehe; i += 4)
    {
      oled.drawFrame(0, 0, i, i);
    }
  }
  while (oled.nextPage());
  delay(2000);

  // vertikale Linie
  oled.firstPage();
  do
  {
    for (int i = 0; i < BildschirmBreite; i += 4)
    {
      oled.drawVLine(i, 0, BildschirmBreite - 1);
    }
  }
  while (oled.nextPage());
  delay(2000);

  // horizontale Linie
  oled.firstPage();
  do
  {
    for (int i = 0; i < BildschirmHoehe; i += 4)
    {
      oled.drawHLine(0, i, BildschirmBreite - 1);
    }
  }
  while (oled.nextPage());
  delay(2000);

  // ausgefüllte Kreise
  oled.firstPage();
  do
  {
    int Radius = 5;
    int StartX = 10;
    int StartY = 10;
    while (StartX < BildschirmBreite - Radius)
    {
      for (int i = StartY; i < BildschirmBreite - Radius; i += 20)
      {
        oled.drawDisc(StartX, i, Radius);
      }
      StartX += 10;
    }
  }
  while (oled.nextPage());
  delay(2000);

  // Linien
  oled.firstPage();
  do
  {
    for (int i = 0; i < BildschirmBreite; i += 5)
    {
      oled.drawLine(0, i, 128, 64);
    }
    for (int i = BildschirmBreite; i > 0; i -= 5)
    {
      oled.drawLine(BildschirmBreite, i, 0, 0);
    }
  }
  while (oled.nextPage());
  delay(2000);
}
Bild­schirm drehen

Bei­spiel

# include "U8g2lib.h"

// 0,96 Zoll SSD1306
U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

// 1,3 Zoll SH1106
// U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

// 2,42 Zoll SSD1309
// U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI oled(U8G2_R0, 10, 9, 8);

int BildschirmBreite = u8g2.getDisplayWidth();
int BildschirmHoehe = u8g2.getDisplayHeight();

// Smiley
# define SmileyBreite 46
# define SmileyHoehe 45
static unsigned char Smiley[] = 
{
  0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x00,
  0x00, 0xf0, 0x07, 0xf8, 0x03, 0x00, 0x00, 0xfc, 0x00, 0xc0, 0x0f, 0x00,
  0x00, 0x3e, 0x00, 0x00, 0x1f, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x7c, 0x00,
  0xc0, 0x07, 0x00, 0x00, 0xf8, 0x00, 0xe0, 0x01, 0x00, 0x00, 0xe0, 0x01,
  0xf0, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x70, 0x00, 0x00, 0x00, 0x80, 0x03,
  0x38, 0x7e, 0x00, 0x80, 0x1f, 0x07, 0x38, 0xff, 0x00, 0xc0, 0x3f, 0x07,
  0x9c, 0xff, 0x01, 0xc0, 0x3f, 0x0e, 0x9c, 0xe7, 0x01, 0xc0, 0x39, 0x0e,
  0x8e, 0xc3, 0x01, 0xc0, 0x30, 0x1c, 0x8e, 0xe3, 0x01, 0xc0, 0x31, 0x1c,
  0x86, 0xf7, 0x01, 0xc0, 0x3b, 0x18, 0x87, 0xff, 0x01, 0xc0, 0x3f, 0x38,
  0x07, 0xff, 0x00, 0x80, 0x3f, 0x38, 0x03, 0x7e, 0x00, 0x80, 0x1f, 0x30,
  0x03, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x00, 0x30,
  0x03, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x00, 0x30,
  0x03, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x00, 0x30,
  0x07, 0x00, 0x00, 0x00, 0x00, 0x38, 0x07, 0x20, 0x00, 0x00, 0x01, 0x38,
  0x06, 0x70, 0x00, 0x80, 0x03, 0x18, 0x0e, 0xf0, 0x00, 0xc0, 0x01, 0x1c,
  0x0e, 0xe0, 0x03, 0xf0, 0x01, 0x1c, 0x1c, 0xc0, 0x3f, 0xfc, 0x00, 0x0e,
  0x1c, 0x80, 0xff, 0x7f, 0x00, 0x0e, 0x38, 0x00, 0xfc, 0x1f, 0x00, 0x07,
  0x38, 0x00, 0xc0, 0x03, 0x00, 0x07, 0x70, 0x00, 0x00, 0x00, 0x80, 0x03,
  0xf0, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xe0, 0x01, 0x00, 0x00, 0xe0, 0x01,
  0xc0, 0x07, 0x00, 0x00, 0xf8, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x7c, 0x00,
  0x00, 0x3e, 0x00, 0x00, 0x1f, 0x00, 0x00, 0xfc, 0x00, 0xc0, 0x0f, 0x00,
  0x00, 0xf0, 0x07, 0xf8, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x00,
  0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00
};

void setup()
{
  // Display starten
  u8g2.begin();

  // Farbe weiß
  u8g2.setDrawColor(1);
}

void loop()
{
  // Position 0 Grad
  u8g2.clearDisplay();
  u8g2.setDisplayRotation(U8G2_R0);
  u8g2.firstPage();
  do
  {
    u8g2.drawXBM(40, 10, SmileyBreite, SmileyHoehe, Smiley);
  }
  while (u8g2.nextPage());
  delay(2000);

  // Position 90 Grad
  u8g2.clearDisplay();
  u8g2.setDisplayRotation(U8G2_R1);
  u8g2.firstPage();
  do
  {
    u8g2.drawXBM(10, 30, SmileyBreite, SmileyHoehe, Smiley);
  }
  while (u8g2.nextPage());
  delay(2000);

  // Position 180 Grad
  u8g2.clearDisplay();
  u8g2.setDisplayRotation(U8G2_R2);
  u8g2.firstPage();
  do
  {
    u8g2.drawXBM(40, 10, SmileyBreite, SmileyHoehe, Smiley);
  }
  while (u8g2.nextPage());
  delay(2000);

  // Position 270 Grad
  u8g2.clearDisplay();
  u8g2.setDisplayRotation(U8G2_R3);
  u8g2.firstPage();
  do
  {
    u8g2.drawXBM(10, 30, SmileyBreite, SmileyHoehe, Smiley);
  }
  while (u8g2.nextPage());
  delay(2000);
}

Letzte Aktualisierung: 29. Mrz 2024 @ 10:42