u8g2 Software Package｜A monochrome graphics library for embedded devices. 
Published: 2020-08-03 08:40:56

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/coqcx641c3u2bjyq2u1z.png)

##**Introduction**
U8g2 is a monochrome graphics library for embedded devices. U8g2 supports Monochrome LCD, OLED, and eInk Library. Now it is ported on [RT-Thread](https://www.rt-thread.io/) to satisfy different development requirements.

**Game Development** (examples/games/space_trash)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/d4l2ocuzg74bazejvbk1.gif)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/yb44qbe8zeqbwcfc6zjv.gif)

**User Interface** (examples/page_buffer/icon_menu)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1krfyet926hjtmz1tcei.gif)

**Drawing** (examples/page_buffer/graphic_test)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/cdl7w5q1lap495ytslii.gif)

##**1、U8G2 Features**

**1.1 Supports Multi-screens, easy to Port.**

The advantage of using u8g2 is that it supports nearly 200 monochrome screens, and same code can run directly on different screens:

- Classic screen 128x64
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/u7728tbt1qvh11o0nrhx.gif)

- OLED SSD1306 I2C

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/yr0outo4qmbrci6o3osd.gif)

Click [HERE](https://github.com/olikraus/u8g2/wiki/gallery
) for a full list of supporting screens.

**1.2 Supports Many Fonts.**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/msxd9qqdo56kn1gq2zwv.jpg)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7bsosoa2uy99symhouwe.jpg)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/e9tce6oc1hsxhwe1zlum.jpg)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/eomnecpmk76evohhf8od.jpg)

**1.3 Supports Many Drawing Functions.**
Supports a variety of drawing functions, and comes with a variety of icons.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0vsa5vfh3ss3zo82aacs.gif)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/foyow82oc9cn7xgiat4p.gif)


**Summarize the features of u8g2:**

- Support for nearly 200 monochrome screens, making it easy to port.
- Supports a variety of drawing functions, images and non-operation, with user key detection.
- Unicode and utf8 are supported, with more than 100 fonts and over 100 icons.

##**2、Description**

**2.1 Catalog Structure**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2m3nlrojv3ft0cmeqj3g.png)

**2.2 License**

- The U8g2lib code (http://code.google.com/p/u8g2/) is licensed under the terms of the new-bsd license (two-clause bsd license).

(http://www.opensource.org/licenses/bsd-license.php)

- The repository and optionally the releases contain icons, which are derived from the WPZOOM Developer Icon Set. WPZOOM Developer Icon Set by WPZOOM is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

(http://www.wpzoom.com/wpzoom/new-freebie-wpzoom-developer-icon-set-154-free-icons/)

- Fonts are licensed under different conditions.for detailed information on the licensing conditions for each font.

(https://github.com/olikraus/u8g2/wiki/fntgrp)

Check Full LICENCE [HERE](https://github.com/wuhanstudio/rt-u8g2/blob/master/LICENSE).

**2.3 Dependence**

Note: If you need to use the I2C LCD screen you need to turn on the I2C, and use GPIO to simulate I2C.
- Using I2C device drivers
- Use GPIO to simulate I2C
Note: If you use the SPI LCD, you need to turn on the SPI.
- Using SPI Bus/Device device drivers

##**3、How to use U8G2?**

You will need to select u8g2 package on the RT-Thread package manager, the specific path is shown as follows:

```
RT-Thread online packages
    peripheral libraries and drivers --->
        [*] U8G2: a u8g2 package for rt-thread
            [*] Use hardware spi                                     
              (spi1)  spi bus name (NEW)              
              (spi10) spi device name (NEW)     
            [*] Use hardware i2c          
              (i2c2)  i2c device name
            U8G2 Examples  --->
```

Then, RT-Thread’s package manager will update automatically, or you can manually update the package to the BSP by entering the `pkgs-update` command.

There are 50 routines that you can see in the source docs directory. The default routines are using the software I2C, if you feel that the speed of software I2C is relatively slow you can use the hardware I2C.

##**4、 Notes**

- Use the BSP in the stm32 directory.
- Turned on -std=c99 when compiling.
- If you feel that the flash is not large enough when compiling, you can turn on the optimization option -O3 or refer to [HERE](https://github.com/olikraus/u8g2/wiki/u8g2optimization) to remove the extra word library.
- The full API manual can be accessed at this [LINK](https://github.com/olikraus/u8g2/wiki/u8g2).

**RT-Thread Contact Info:**

 [Website](https://www.rt-thread.io/)  |  [Github](https://github.com/RT-Thread)  | [Twitter](https://twitter.com/rt_thread) |  [Facebook](https://www.facebook.com/RT-Thread-IoT-OS-110395723808463)   |   [Youtube](https://www.youtube.com/channel/UCdDHtIfSYPq4002r27ffqPw
)