ESP32

※This article is based on esp-idf 4.0

下载 [edit]

https://github.com/olikraus/u8g2

安装 [edit]

  1. Create a directory called components in your main project directory.
  2. Change into the components directory.
  3. Run git clone https://github.com/mkfrey/u8g2-hal-esp-idf.git to bring in the latest copy of this library.
  4. Run git clone https://github.com/olikraus/u8g2.git to bring in a the latest copy of u8g2 library.

IIC接口 [edit]

ESP32 的硬件IIC默认的接口

// SDA - GPIO21
#define PIN_SDA 21

// SCL - GPIO22
#define PIN_SCL 22

参考:

https://blog.csdn.net/quangui666/article/details/81483645

显示 [edit]

官方的函数的一览

https://github.com/olikraus/u8g2/wiki/u8g2reference#begin

u8g2中文字库参考 [edit]

u8g2_SetFont(&u8g2, u8g2_font_wqy12_t_gb2312); //设置使用哪个汉字库

u8g2_DrawUTF8(&u8g2,65,40,"你好world");
https://github.com/larryli/u8g2_wqy

u8g2自定义图片显示 [edit]

把png、jpg等图片格式裁剪到合适大小,裁剪后统一保存成位图格式。然后使用PCtoLCD2002软件,生成位图数组,再写入u8g2显示。

OLED是128x64的像素尺寸,一般裁剪成30x20大小较为合适。

方法二:可以使用如下工具进行图片到数组的转换:

https://tools.clz.me/image-to-bitmap-array

u8g2_font_unifont_t_symbols [edit]

显示符号函数

//设置字体
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, x, y, 0x2665);
//输出♥

u8g2_symbol.png

问题 [edit]

编译错误 [edit]

components/u8g2/csrc/u8x8_d_ssd1320.c:339:22: error: 'u8x8_d_ssd1320_cs1_160x132_init_seq' defined but not used [-Werror=unused-const-variable=]
 static const uint8_t u8x8_d_ssd1320_cs1_160x132_init_seq[] = {
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

&ref(): File not found: "ZigBee_体系结构.png" at page "+ESP32+OLED屏";


コメント:



(画像の文字列を入力して下さい)

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS