当前位置:网站首页>OLED显示如何理解 12*6、16*8、24*12等字符大小
OLED显示如何理解 12*6、16*8、24*12等字符大小
2022-07-17 10:03:00 【小飞侠123!】

上图设置的取模方式,在右上角的取模说明里面有。
即:从第一列开始向下每取 8 个点作为一个字节,如果最后不足 8 个点就补满 8 位。(重点!!!)
取模顺序是从高到低,即第一个点作为最高位。
如*-------取为 10000000。其实就是按如图 17.3.3 所示的这种方式:
从上到下,从左到右,高位在前。我们按这样的取模方式,然后把 ASCII 字符集按 12x6大小、 16x8 和 24x12 大小取模出来(对应汉字大小为 12x12、 16x16 和 24x24,字符的只有汉字的一半大!),保存在 oledfont.h 里面,每个 12x6 的字符占用 12 个字节(注意,由于都是按照字节写入,所有列方向的12个点按照16个点2个字节处理,所以 12x6字符占用2x6=12个字节),每个 16x8 的字符占用16 个字节, 每个 24x12 的字符占用 36 个字节。
下面分析一段代码:
//在指定位置显示一个字符,包括部分字符
//x:0~127
//y:0~63
//mode:0,反白显示;1,正常显示
//size:选择字体 12/16/24
void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 size,u8 mode)
{
u8 temp,t,t1;
u8 y0=y;
u8 csize=(size/8+((size%8)?1:0))*(size/2); //得到字体一个字符对应点阵集所占的字节数
chr=chr-' ';//得到偏移后的值
for(t=0;t<csize;t++)
{
if(size==12)
temp=asc2_1206[chr][t]; //调用1206字体
else
if(size==16)
temp=asc2_1608[chr][t]; //调用1608字体
else
if(size==24)
temp=asc2_2412[chr][t]; //调用2412字体
else
return; //没有的字库
for(t1=0;t1<8;t1++)
{
if(temp&0x80)
OLED_DrawPoint(x,y,mode);
else
OLED_DrawPoint(x,y,!mode);
temp<<=1;
y++;
if((y-y0)==size)
{
y=y0;
x++;
break;
}
}
}
}
假设打印12*6的字符,当size=12时,csize = 12。
if((y-y0)==size)
{
y=y0;
x++;
break;
}
虽然字符的高度占用2个字节16个点,但是这段代码限制了显示的高度为size,即显示的高度为12。
其他同理即可。
边栏推荐
猜你喜欢

How to build your own cloud database in docker

LDA分类器
![[troubleshooting] common problems and solutions when installing MySQL in Windows system](/img/45/339bda7ecf8879999d8ff128c1d3ab.png)
[troubleshooting] common problems and solutions when installing MySQL in Windows system

Tree array

【愚公系列】2022年7月 Go教学课程 012-强制类型转换

如何在docker里搭建自己的云数据库

Es conceptual model and basic faults

SSM implementation of one-to-one query detailed tutorial (1)

两个结构体 ifconf 和 ifreq

Google Play应用商店可能会删除应用权限概述 转而使用新的数据安全信息组合
随机推荐
【Flink】Flink 设置检查点失败一次就报错 setTolerableCheckpointFailureNumber 不起作用
C# 读写文本,生成二维码
Line Flow Based Simultaneous Localization and Mapping
Target detection model size calculation, model complexity (parameter conversion formula)
Programming in the novel [serial 14] the moon bends in the yuan universe
如何正确执行Jedis单元测试
OpenCV模板
How is MySQL data stored on disk?
[paper notes] Research on end positioning of grab manipulator based on multi-sensor data fusion
05---增透膜
Left connection query of Android database
C language compilation process
如何在监控主机上单独部署agent——WGCLOUD
Scope and lifecycle of beans
两个结构体 ifconf 和 ifreq
如何在docker里搭建自己的云数据库
焱融科技入选北京市 2022 年度“专精特新”,领航混合云文件存储
【虹科】GenICam协议入门
AnyControl Demo演示
代码随想录:刷题记录(更新中)