-
Notifications
You must be signed in to change notification settings - Fork 0
u8x8setupcpp
U8x8lib is the direct write, zero RAM, text only library part of U8g2lib. To setup u8x8, use the correct constructur for your display. The constructor name defines display and communication protocol. The arguments of the constructor defines how the display is connected to the Arduino board. This is the "Hello World" example for the Arduino C++ interface:
#include <Arduino.h>
#include <SPI.h>
#include <U8x8lib.h>
/* Constructor */
U8X8_SSD1306_128X64_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
/* u8x8.begin() is required and will sent the setup/init sequence to the display */
void setup(void)
{
u8x8.begin();
}
void loop(void)
{
u8x8.setFont(u8x8_font_chroma48medium8_r);
u8x8.drawString(0,0,"Hello World!");
delay(1000);
}
setFont() and drawString() are described in the u8x8 reference manual.
The name of the Arduino C++ constructor has the following parts:
| No | Description | Example |
|---|---|---|
| 1 | Prefix | U8X8 |
| 2 | Display Controller | UC1701 |
| 3 | Display Name | DOGS102 |
| 4 | Communication | 4W_SW_SPI |
These parts are connect with _. The full construcor name for the example will be U8X8_UC1701_DOGS102_4W_SW_SPI.
All available construcor names are listed in the reference section below.
The main difference between U8x8 and U8g2 is the local memory. U8x8 directly writes to the display and does not require any additional buffer or RAM.
The communication protocol is part of the constructor name (see above). The following communication protocolls are supported:
| Communication | Description |
|---|---|
4W_SW_SPI |
4-wire (clock, data, cs and dc) software emulated SPI |
4W_HW_SPI |
4-wire (clock, data, cs and dc) hardware SPI (based on Arduino SPI library) |
3W_SW_SPI |
3-wire (clock, data and cs) software emulated SPI |
SW_I2C |
Software emulated I2C/TWI |
6800 |
8-bit parallel interface, 6800 protocol |
8080 |
8-bit parallel interface, 8080 protocol |
| Pin Argument | Description | Datasheet Names |
|---|---|---|
| clock | SPI or I2C clock line | SCL, SCLK, ... |
| data | SPI or I2C data line | SDA, MOSI, SDIN, ... |
| d0 ... d7 | Data lines of the parallel interface | D0 ... D7 |
| cs | Chip select line | CS |
| dc | Data/command selection line (register select) | D/C, A0, RS, ... |
| enable | "Write" for the 8080 interface, "enable" for the 6800 interface | 8080: WR, 6800: E |
| reset | Reset line |
| Controller "ssd1306", Display "128x64_noname" |
|---|
| U8X8_SSD1306_128X64_NONAME_4W_SW_SPI(clock, data, cs, dc [, reset]) |
| U8X8_SSD1306_128X64_NONAME_4W_HW_SPI(cs, dc [, reset]) |
| U8X8_SSD1306_128X64_NONAME_3W_SW_SPI(clock, data, cs [, reset]) |
| U8X8_SSD1306_128X64_NONAME_6800(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| U8X8_SSD1306_128X64_NONAME_8080(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| Controller "ssd1306", Display "128x64_noname" |
|---|
| U8X8_SSD1306_128X64_NONAME_SW_I2C(clock, data [, reset]) |
| U8X8_SSD1306_128X64_NONAME_HW_I2C([reset]) |
| Controller "sh1106", Display "128x64_noname" |
|---|
| U8X8_SH1106_128X64_NONAME_4W_SW_SPI(clock, data, cs, dc [, reset]) |
| U8X8_SH1106_128X64_NONAME_4W_HW_SPI(cs, dc [, reset]) |
| U8X8_SH1106_128X64_NONAME_3W_SW_SPI(clock, data, cs [, reset]) |
| U8X8_SH1106_128X64_NONAME_6800(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| U8X8_SH1106_128X64_NONAME_8080(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| Controller "sh1106", Display "128x64_noname" |
|---|
| U8X8_SH1106_128X64_NONAME_SW_I2C(clock, data [, reset]) |
| U8X8_SH1106_128X64_NONAME_HW_I2C([reset]) |
| Controller "ssd1306", Display "128x32_univision" |
|---|
| U8X8_SSD1306_128X32_UNIVISION_4W_SW_SPI(clock, data, cs, dc [, reset]) |
| U8X8_SSD1306_128X32_UNIVISION_4W_HW_SPI(cs, dc [, reset]) |
| U8X8_SSD1306_128X32_UNIVISION_3W_SW_SPI(clock, data, cs [, reset]) |
| U8X8_SSD1306_128X32_UNIVISION_6800(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| U8X8_SSD1306_128X32_UNIVISION_8080(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| Controller "ssd1306", Display "128x32_univision" |
|---|
| U8X8_SSD1306_128X32_UNIVISION_SW_I2C(clock, data [, reset]) |
| U8X8_SSD1306_128X32_UNIVISION_HW_I2C([reset]) |
| Controller "uc1701", Display "ea_dogs102" |
|---|
| U8X8_UC1701_EA_DOGS102_4W_SW_SPI(clock, data, cs, dc [, reset]) |
| U8X8_UC1701_EA_DOGS102_4W_HW_SPI(cs, dc [, reset]) |
| U8X8_UC1701_EA_DOGS102_3W_SW_SPI(clock, data, cs [, reset]) |
| U8X8_UC1701_EA_DOGS102_6800(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| U8X8_UC1701_EA_DOGS102_8080(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| Controller "uc1701", Display "mini12864" |
|---|
| U8X8_UC1701_MINI12864_4W_SW_SPI(clock, data, cs, dc [, reset]) |
| U8X8_UC1701_MINI12864_4W_HW_SPI(cs, dc [, reset]) |
| U8X8_UC1701_MINI12864_3W_SW_SPI(clock, data, cs [, reset]) |
| U8X8_UC1701_MINI12864_6800(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| U8X8_UC1701_MINI12864_8080(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| Controller "st7565", Display "ea_dogm128" |
|---|
| U8X8_ST7565_EA_DOGM128_4W_SW_SPI(clock, data, cs, dc [, reset]) |
| U8X8_ST7565_EA_DOGM128_4W_HW_SPI(cs, dc [, reset]) |
| U8X8_ST7565_EA_DOGM128_3W_SW_SPI(clock, data, cs [, reset]) |
| U8X8_ST7565_EA_DOGM128_6800(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| U8X8_ST7565_EA_DOGM128_8080(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| Controller "st7565", Display "nhd_c12832" |
|---|
| U8X8_ST7565_NHD_C12832_4W_SW_SPI(clock, data, cs, dc [, reset]) |
| U8X8_ST7565_NHD_C12832_4W_HW_SPI(cs, dc [, reset]) |
| U8X8_ST7565_NHD_C12832_3W_SW_SPI(clock, data, cs [, reset]) |
| U8X8_ST7565_NHD_C12832_6800(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
| U8X8_ST7565_NHD_C12832_8080(d0, d1, d2, d3, d4, d5, d6, d7, enable, cs, dc [, reset]) |
