51 lines
1.6 KiB
Markdown
51 lines
1.6 KiB
Markdown
|
---
|
|||
|
title: U8g2
|
|||
|
updated: 2022-01-13 09:11:53Z
|
|||
|
created: 2022-01-08 13:18:07Z
|
|||
|
tags:
|
|||
|
- u8g2
|
|||
|
---
|
|||
|
|
|||
|
# 硬件
|
|||
|
小屏为0.66寸的OLED,分辨率64x48,ssd1306通用驱动IC,4线SPI控制(内部BS1为0,不可改IIC),
|
|||
|
构造函数`u8g2_Setup_ssd1306_64x48_er_f`可直接驱动
|
|||
|
`drawGlyph` 绘制特殊文本图标,需联合特殊字体
|
|||
|
取模软件zimo221.exe配置为“横向取模,字节倒序”
|
|||
|
|
|||
|
|
|||
|
# 内存占用
|
|||
|
初步测试占用ROM约5k+
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
# 移植方法:
|
|||
|
1. 移植`u8g2_gpio_and_delay_stm32`
|
|||
|
1. 选择构造函数`u8g2_Setup_ssd1306_64x48_er_f`,后缀f为全屏缓存。**屏蔽其它构造函数**。(针对MDK,STM32cubeide不用屏蔽)
|
|||
|
1. 初始化`u8g2_InitDisplay(&u8g2)`; // send init sequence to the display, display is in sleep mode after this,
|
|||
|
1. 唤醒屏幕`u8g2_SetPowerSave(&u8g2, 0)`; // wake up display
|
|||
|
1. **屏蔽`u8g2_d_memory.c`**,根据报错打开相应函数(针对MDK,STM32cubeide不用屏蔽)
|
|||
|
1. 设置字体`u8g2_SetFont(&u8g2,u8g2_font_5x7_mr)`;//字体文件不用屏蔽
|
|||
|
1. 输出`u8g2_DrawStr(&u8g2,0,14,"123abcABC")`;
|
|||
|
1. 更新屏幕`u8g2_SendBuffer(&u8g2)`;
|
|||
|
# 函数详解
|
|||
|
`u8g2_SetDrawColor`参数详解
|
|||
|
|
|||
|
0-清像素模式,即0代表亮
|
|||
|
|
|||
|
1-写像素模式,即1代表亮
|
|||
|
|
|||
|
2-XOR模式,与当前像素点异或
|
|||
|
|
|||
|
灵活利用此参数可实现诸多功能
|
|||
|
|
|||
|
**局部清背景**,示例参见非等宽字体在固定坐标刷新 [0.91' OLED显示#刷新问题](../信号源/0.91_%20OLED显示.md#刷新问题)
|
|||
|
|
|||
|
**局部反显**,示例参见当前 [0.91' OLED显示#数字反显](../信号源/0.91_%20OLED显示.md#数字反显)
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#u8g2
|