#author("2023-01-29T13:20:34+08:00","default:Admin","Admin") #author("2023-01-29T17:43:33+08:00","default:Admin","Admin") [[ESP32]] &color(red){※This article is based on esp-idf 4.0}; #contents * 下载 [#q6a28356] https://github.com/olikraus/u8g2 * 安装 [#t435b07f] + Create a directory called components in your main project directory. + Change into the components directory. + Run git clone https://github.com/mkfrey/u8g2-hal-esp-idf.git to bring in the latest copy of this library. + Run git clone https://github.com/olikraus/u8g2.git to bring in a the latest copy of u8g2 library. * IIC接口 [#e4033cf5] ESP32 的硬件IIC默认的接口 #codeprettify{{ // SDA - GPIO21 #define PIN_SDA 21 // SCL - GPIO22 #define PIN_SCL 22 }} 参考: https://blog.csdn.net/quangui666/article/details/81483645 * 显示 [#x0a9f047] 官方的函数的一览 https://github.com/olikraus/u8g2/wiki/u8g2reference#begin ** u8g2中文字库参考 [#c3d700e0] #codeprettify{{ u8g2_SetFont(&u8g2, u8g2_font_wqy12_t_gb2312); //设置使用哪个汉字库 u8g2_DrawUTF8(&u8g2,65,40,"你好world"); }} https://github.com/larryli/u8g2_wqy ** 英文字库 [#ld9a1546] https://github.com/olikraus/u8g2/wiki/fntlistall ** u8g2自定义图片显示 [#g1206603] 把png、jpg等图片格式裁剪到合适大小,裁剪后统一保存成位图格式。然后使用PCtoLCD2002软件,生成位图数组,再写入u8g2显示。 OLED是128x64的像素尺寸,一般裁剪成30x20大小较为合适。 方法二:可以使用如下工具进行图片到数组的转换: https://tools.clz.me/image-to-bitmap-array ** u8g2_font_unifont_t_symbols [#i0397350] 显示符号函数 #codeprettify{{ //设置字体 u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols); u8g2_DrawGlyph(&u8g2, x, y, 0x2665); //输出♥ }} &ref(u8g2_symbol.png); * 问题 [#w802624e] ** 编译错误 [#z4a66043] #codeprettify{{ 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(ZigBee_体系结构.png); #hr(); コメント: #comment_kcaptcha