国产MCU-CW32F030开发学习-OLED模块
硬件平台
- CW32_48F大学计划板
- CW32_IOT_EVA物联网开发评估套件
- 0.96 IIC oled模块
软件平台
- Keil MDK 5.31
- IAR
- 串口调试助手
IIC总线
处理器和芯片间的通信可以形象的比喻成两个人讲话:1、你说的别人得能听懂:双方约定信号的协议。2、你的语速别人得能接受:双方满足时序要求。
一、IIC总线的信号类型
1、开始信号:处理器让SCL时钟保持高电平,然后让SDA数据信号由高变低就表示一个开始信号。同时IIC总线上的设备检测到这个开始信号它就知道处理器要发送数据了。
2、停止信号:处理器让SCL时钟保持高电平,然后让SDA数据信号由低变高就表示一个停止信号。同时IIC总线上的设备检测到这个停止信号它就知道处理器已经结束了数据传输,我们就可以各忙各个的了,如休眠等。
二、IIC数据传输过程
、
1、在数据传输时,SDA的数据在SCL为高电平时,必须保持稳定,SCL高电平器件完成数据的传输。在SCL低电平器件,可以任意改变SDA的数据。数据写入过程是从最好为开始,高位在前,低位在后,即MSB。
2、响应信号(ACK):接收器在接收到8位数据后,在第9个时钟周期,拉低SDA电平。即接收数据的IC在接收到8bit数据后,向发送数据的IC发出特定的低电平脉冲,表示已收到数据。CPU向受控单元发出一个信号后,等待受控单元发出一个应答信号,CPU接收到应答信号后,根据实际情况作出是否继续传递信号的判断。若未收到应答信号,由判断为受控单元出现故障。
3、数据写入的过程
首先发送一个开始信号,接着发送从机地址,OLED的从机地址前7位为地址,最后一位表示读(1)或者写(0)。应答ACK信号表示有这个从设备存在。在接收到应答信号后,发送控制位,来区分之后所发送的数据是控制命令还是显示相关的数据。在发送控制位后,等待应答信号。然后发送相应的控制命令或者数据。最后发送停止信号,表示数据传输完成。
OLED 显示函数支持
- OLED 显示字符、字符串 汉字
void OLED_ShowChar_06x08(uint8_t X, uint8_t Y, uint8_t Char);//显示字符函数
void OLED_ShowString_06x08(uint8_t X, uint8_t Y, uint8_t *String);//显示字符串函数
void OLED_ShowCHinese(uint8_t X,uint8_t Y,uint8_t Chinese);//显示汉字函数
void OLED_ShowChar_08x16(uint8_t X, uint8_t Y, uint8_t Char);//显示字符函数
void OLED_ShowString_16x16(uint8_t X, uint8_t Y, uint8_t *String);//显示字符串函数
- OLED 显示整型数字/浮点型数字/二进制数字/十六进制数字
void OLED_ShowNumber_SignedInteger_06x08(uint8_t X, uint8_t Y, int16_t IntegerNumber, uint8_t Count);//显示有符号整型数字函数
void OLED_ShowNumber_UnsignedInteger_06x08(uint8_t X, uint8_t Y, uint16_t IntegerNumber, uint8_t Count);//显显示无符号整型数字函数
void OLED_ShowNumber_Float_06x08(uint8_t X, uint8_t Y, float FloatNumber, uint8_t Count1, uint8_t Count2);//显示浮点数函数
void OLED_ShowNumber_Binary_06x08(uint8_t X, uint8_t Y, unsigned long BinaryNumber, uint8_t Count);//显示数组函数
void OLED_ShowNumber_Hex_06x08(uint8_t X, uint8_t Y, unsigned long BinaryNumber, uint8_t Count);//显示十六进制数字函数
- OLED 基本绘图函数
// OLED 绘制直线
void OLED_DrawLine(uint8_t X, uint8_t Y, uint8_t PointData);
// OLED 绘制图像
void OLED_RollDisplay(void);//设置水平左右移
void Draw_BMP(uint8_t x0,uint8_t y0,uint8_t x1,uint8_t y1,uint8_t BMP[]);
//画点函数
void OLED_DrawDot(uint8_t X,uint8_t Y,uint8_t T);
//画直线函数
void LCD_DrawLine(uint32_t X1, uint32_t Y1, uint32_t X2,uint32_t Y2);
//dot ==1 表示亮显示出来
void OLED_Fill_Draw_circle(uint8_t X0,uint8_t Y0,uint8_t r,uint8_t dot);
//ucFilled ==1 表示填充 //画直圆函数
void OLED_DrawCircle( uint16_t usX_Center, uint16_t usY_Center, uint16_t usRadius, uint8_t ucFilled );
//画矩形函数
void LCD_DrawRectangle(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2);
OLED.C
//--------------------------------------------------------------------------------------------------
// 包含的头文件 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//--------------------------------------------------------------------------------------------------
#include "main.h"
#include "oledfont.h"
//==================================================================================================
// 实现功能: OLED IIC 0.96 接线
// GND GND
// VCC 3.3/5V
// SDA PC15
// SCL PC14
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
//OLED的显存
//存放格式如下.
//[0]0 1 2 3 ... 127
//[1]0 1 2 3 ... 127
//[2]0 1 2 3 ... 127
//[3]0 1 2 3 ... 127
//[4]0 1 2 3 ... 127
//[5]0 1 2 3 ... 127
//[6]0 1 2 3 ... 127
//[7]0 1 2 3 ... 127
uint8_t OLED_GRAM[128][8];
uint8_t OLED_GRAM_TEMP[128][8];
//==================================================================================================
// 函数功能: IIC外设驱动函数部分
// 函数标记: IIC_Start
// 函数说明: 无
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void IIC_Start()
{
OLED_SCLK_Set() ;
OLED_SDIN_Set();
OLED_SDIN_Clr();
OLED_SCLK_Clr();
}
//==================================================================================================
// 函数功能: IIC外设驱动函数部分
// 函数标记: IIC_Stop
// 函数说明: 无
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void IIC_Stop()
{
OLED_SCLK_Set() ;
OLED_SDIN_Clr();
OLED_SDIN_Set();
}
//==================================================================================================
// 函数功能: IIC外设驱动函数部分
// 函数标记: IIC_Stop
// 函数说明: 无
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void IIC_Wait_Ack()
{
OLED_SCLK_Set() ;
OLED_SCLK_Clr();
}
//==================================================================================================
// 函数功能: IIC外设驱动函数部分
// 函数标记: Write_IIC_Byte
// 函数说明: 无
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void Write_IIC_Byte(uint8_t IIC_Byte)
{
uint8_t i;
uint8_t m,da;
da=IIC_Byte;
OLED_SCLK_Clr();
for(i=0;i<8;i++)
{
m=da;
// OLED_SCLK_Clr();
m=m&0x80;
if(m==0x80)
{
OLED_SDIN_Set();
}
else
OLED_SDIN_Clr();
da=da<<1;
OLED_SCLK_Set();
OLED_SCLK_Clr();
}
}
//==================================================================================================
// 函数功能: IIC外设驱动函数部分
// 函数标记: Write_IIC_Command
// 函数说明: 无
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void Write_IIC_Command(uint8_t IIC_Command)
{
IIC_Start();
Write_IIC_Byte(0x78); //Slave address,SA0=0
IIC_Wait_Ack();
Write_IIC_Byte(0x00); //write command
IIC_Wait_Ack();
Write_IIC_Byte(IIC_Command);
IIC_Wait_Ack();
IIC_Stop();
}
//==================================================================================================
// 函数功能: IIC外设驱动函数部分
// 函数标记: Write_IIC_Data
// 函数说明: 无
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void Write_IIC_Data(uint8_t IIC_Data)
{
IIC_Start();
Write_IIC_Byte(0x78); //D/C#=0; R/W#=0
IIC_Wait_Ack();
Write_IIC_Byte(0x40); //write data
IIC_Wait_Ack();
Write_IIC_Byte(IIC_Data);
IIC_Wait_Ack();
IIC_Stop();
}
//==================================================================================================
// 函数功能: OLED外设驱动函数部分
// 函数标记: OLED_WR_Byte
// 函数说明: 无
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_WR_Byte(unsigned dat,unsigned cmd)
{
if(cmd)
{
Write_IIC_Data(dat);
}
else
{
Write_IIC_Command(dat);
}
}
//==================================================================================================
// 函数功能: OLED外设驱动函数部分
// 函数标记: fill_picture
// 函数说明: 无
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void fill_picture(uint8_t fill_Data)
{
uint8_t m,n;
for(m=0;m<8;m++)
{
OLED_WR_Byte(0xb0+m,OLED_CMD); //page0-page1
OLED_WR_Byte(0x00,OLED_CMD); //low column start address
OLED_WR_Byte(0x10,OLED_CMD); //high column start address
for(n=0;n<128;n++)
{
OLED_WR_Byte(fill_Data,OLED_DATA);
}
}
}
//==================================================================================================
// 函数功能: IIC外设驱动函数部分
// 函数标记: Delay_ms
// 函数说明: 无
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
/***********************Delay****************************************/
void Delay_50ms(uint32_t Delay_50ms)
{
uint32_t count;
for(;Delay_50ms>0;Delay_50ms--)
for(count=6245;count>0;count--);
}
void Delay_1ms(uint32_t Delay_1ms)
{
uint8_t count;
while(Delay_1ms--)
{
for(count=0;count<123;count++);
}
}
//==================================================================================================
// 函数功能: OLED外设驱动函数部分
// 函数标记: OLED_Refresh_Gram
// 函数说明: 更新显存到LCD
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_Refresh_Gram(void)
{
uint8_t i,n;
for(i=0;i<8;i++)
{
OLED_WR_Byte (0xb0+i,OLED_CMD); //设置页地址(0~7)
OLED_WR_Byte (0x00,OLED_CMD); //设置显示位置―列低地址
OLED_WR_Byte (0x10,OLED_CMD); //设置显示位置―列高地址
for(n=0;n<128;n++)
OLED_WR_Byte(OLED_GRAM[n][i],OLED_DATA);
}
}
//==================================================================================================
// 函数功能: OLED 外设驱动函数部分
// 函数标记: OLED_Display_On
// 函数说明: 开启OLED显示
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_Display_On(void)
{
OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC命令
OLED_WR_Byte(0X14,OLED_CMD); //DCDC ON
OLED_WR_Byte(0XAF,OLED_CMD); //DISPLAY ON
}
//==================================================================================================
// 函数功能: OLED 外设驱动函数部分
// 函数标记: OLED_Display_Off
// 函数说明: 关闭OLED显示
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_Display_Off(void)
{
OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC命令
OLED_WR_Byte(0X10,OLED_CMD); //DCDC OFF
OLED_WR_Byte(0XAE,OLED_CMD); //DISPLAY OFF
}
//==================================================================================================
// 函数功能: OLED 外设驱动函数部分
// 函数标记: OLED_Clear
// 函数说明: 清屏函数,清完屏,整个屏幕是黑色的!和没点亮一样!!!
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_Clear(void)
{
uint8_t count,num;
for(count=0;count<8;count++)
{
OLED_WR_Byte (0xb0+count,OLED_CMD); //设置页地址(0~7)
OLED_WR_Byte (0x00,OLED_CMD); //设置显示位置—列低地址
OLED_WR_Byte (0x10,OLED_CMD); //设置显示位置—列高地址
for(num=0;num<128;num++)
OLED_WR_Byte(0x00,OLED_DATA);
} //更新显示
}
//==================================================================================================
// 函数功能: OLED 外设驱动函数部分
// 函数标记: OLED_On
// 函数说明:
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_On(void)
{
uint8_t count,num;
for(count=0;count<8;count++)
{
OLED_WR_Byte (0xb0+count,OLED_CMD); //设置页地址(0~7)
OLED_WR_Byte (0x00,OLED_CMD); //设置显示位置—列低地址
OLED_WR_Byte (0x10,OLED_CMD); //设置显示位置—列高地址
for(num=0;num<128;num++)
OLED_WR_Byte(0x01,OLED_DATA);
} //更新显示
}
//==================================================================================================
// 函数功能: OLED 外设驱动函数部分
// 函数标记: OLED_Fill
// 函数说明: OLED_Fill 填充整个屏幕 fill_Data:要填充的数据
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_Fill(uint8_t fill_Data)//全屏填充
{
uint8_t m,n;
for(m=0;m<8;m++)
{
OLED_WR_Byte(0xb0+m,OLED_CMD); //page0-page1
OLED_WR_Byte(0x00,OLED_CMD); //low column start address
OLED_WR_Byte(0x10,OLED_CMD); //high column start address
for(n=0;n<128;n++)
{
OLED_WR_Byte(fill_Data,OLED_DATA);
}
}
}
//==================================================================================================
// 函数功能: OLED 外设驱动函数部分
// 函数标记: OLED_Init
// 函数说明: 初始化函数配置
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
__RCC_GPIOC_CLK_ENABLE();
GPIO_InitStructure.Pins = OLED_SDA_GPIO_PIN|OLED_SCL_GPIO_PIN;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
GPIO_Init(OLED_GPIO_PORT, &GPIO_InitStructure);
GPIO_SetBits(OLED_GPIO_PORT,OLED_SDA_GPIO_PIN|OLED_SCL_GPIO_PIN);
delay_ms(200);
OLED_WR_Byte(0xAE,OLED_CMD);//--display off
OLED_WR_Byte(0x00,OLED_CMD);//---set low column address
OLED_WR_Byte(0x10,OLED_CMD);//---set high column address
OLED_WR_Byte(0x40,OLED_CMD);//--set start line address
OLED_WR_Byte(0xB0,OLED_CMD);//--set page address
OLED_WR_Byte(0x81,OLED_CMD); // contract control
OLED_WR_Byte(0xFF,OLED_CMD);//--128
OLED_WR_Byte(0xA1,OLED_CMD);//set segment remap
OLED_WR_Byte(0xA6,OLED_CMD);//--normal / reverse
OLED_WR_Byte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
OLED_WR_Byte(0x3F,OLED_CMD);//--1/32 duty
OLED_WR_Byte(0xC8,OLED_CMD);//Com scan direction
OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset
OLED_WR_Byte(0x00,OLED_CMD);//
OLED_WR_Byte(0xD5,OLED_CMD);//set osc division
OLED_WR_Byte(0x80,OLED_CMD);//
OLED_WR_Byte(0xD8,OLED_CMD);//set area color mode off
OLED_WR_Byte(0x05,OLED_CMD);//
OLED_WR_Byte(0xD9,OLED_CMD);//Set Pre-Charge Period
OLED_WR_Byte(0xF1,OLED_CMD);//
OLED_WR_Byte(0xDA,OLED_CMD);//set com pin configuartion
OLED_WR_Byte(0x12,OLED_CMD);//
OLED_WR_Byte(0xDB,OLED_CMD);//set Vcomh
OLED_WR_Byte(0x30,OLED_CMD);//
OLED_WR_Byte(0x8D,OLED_CMD);//set charge pump enable
OLED_WR_Byte(0x14,OLED_CMD);//
OLED_WR_Byte(0xAF,OLED_CMD);//--turn on oled panel
}
//==================================================================================================
// 函数功能: OLED函数部分
// 函数说明: OLED 显示函数
//-------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
//==================================================================================================
// 实现功能: OLED 显示汉字
// 函数标记: 外设驱动函数
// 函数说明: 无
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// Chinese - 待显示汉字 取值范围 - 单个汉字组成的字符串
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_ShowCHinese(uint8_t X,uint8_t Y,uint8_t Chinese)
{
uint8_t count,adder=0;
OLED_Set_Pos(X,Y);
for(count=0;count<16;count++)
{
OLED_WR_Byte(CHinese[2*Chinese][count],OLED_DATA);
adder+=1;
}
OLED_Set_Pos(X,Y+1);
for(count=0;count<16;count++)
{
OLED_WR_Byte(CHinese[2*Chinese+1][count],OLED_DATA);
adder+=1;
}
}
//==================================================================================================
// 实现功能: OLED_Set_Pos 定位光标
// 函数标记: 外设驱动函数
// 函数说明: 无
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_Set_Pos(uint8_t X, uint8_t Y)
{
OLED_WR_Byte(0xb0+Y,OLED_CMD);
OLED_WR_Byte(((X&0xf0)>>4)|0x10,OLED_CMD);
OLED_WR_Byte((X&0x0f),OLED_CMD);
}
//==================================================================================================
// 实现功能: OLED 清除屏幕区域内容
// 函数标记: 外设驱动函数
// 函数说明: 无
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// X_Size - X方向尺寸 取值范围 - 1~127
// Y_Size - Y方向尺寸 取值范围 - 1~ 7
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_AreaClear(uint8_t X, uint8_t Y, uint8_t X_Size, uint8_t Y_Size)
{
uint8_t i; // 定义局部变量 用于函数循环计数
uint8_t j; // 定义局部变量 用于函数循环计数
for(i=0; i<(Y_Size/8); i++) // 遍历每一行
{
OLED_Set_Pos(X, Y+i); // 设置显示坐标
for(j=0; j<X_Size; j++) // 遍历每一列
{
OLED_WR_Byte(0x00,OLED_DATA);
}
}
}
//==================================================================================================
// 实现功能: OLED 指定位置 显示字符 06x08像素
// 函数标记: 应用函数 已完成
// 函数说明: 1. 位置选取不恰当 可能造成字符串显示不完全
// 2. 如果字库不存在该文字则不显示
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// Char - 待写字符 取值范围 - ASCII字符
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_ShowChar_06x08(uint8_t X, uint8_t Y, uint8_t Char)
{
uint8_t i; // 定义局部变量 用于函数循环计数
uint8_t j; // 定义局部变量 用于函数循环计数
uint8_t FontCount; // 定义局部变量 用于记录字符字库个数
FontCount=sizeof(OLED_ASCII_06x08_FontCode)/sizeof(OLED_ASCII_06x08_FontCode[0]);
for(i=0; i<FontCount; i++) // 遍历每一字库
{
if(Char == OLED_ASCII_06x08_FontCode[i].Char)
{
OLED_Set_Pos(X,Y); // 设置显示坐标
for(j=0; j<6; j++) // 遍历每一列
{
OLED_WR_Byte(OLED_ASCII_06x08_FontCode[i].Code[j],OLED_DATA);
}
break;
}
}
}
//==================================================================================================
// 实现功能: OLED 指定位置 显示字符串 06x08像素
// 函数标记: 外设驱动函数
// 函数说明: 1. 位置选取不恰当 可能造成字符串显示不完全
// 2. 如果字库不存在该文字则不显示
// 3. 06x08像素不能显示汉字 只能显示ASCII字符
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// String - 待显示字符串 取值范围 - ASCII字符串
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_ShowString_06x08(uint8_t X, uint8_t Y, uint8_t *String)
{
while(*String) // 判断字符串是否为空
{
OLED_ShowChar_06x08(X, Y, *String); // 指定位置显示字符
String++; // 字符串指针移动下一个字节
X+=6; // X坐标移动下一个位置
}
}
//==================================================================================================
// 实现功能: OLED 指定位置 显示字符 08x16像素
// 函数标记: 应用函数 已完成
// 函数说明: 1. 位置选取不恰当 可能造成字符串显示不完全
// 2. 如果字库不存在该文字则不显示
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// Char - 待显示字符 取值范围 - ASCII字符
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_ShowChar_08x16(uint8_t X, uint8_t Y, uint8_t Char)
{
uint8_t i; // 定义局部变量 用于函数循环计数
uint8_t j; // 定义局部变量 用于函数循环计数
uint8_t FontCount; // 定义局部变量 用于记录字符字库个数
FontCount=sizeof(OLED_ASCII_08x16_FontCode)/sizeof(OLED_ASCII_08x16_FontCode[0]);
for(i=0; i<FontCount; i++) // 循环查询字符字模位置
{
if(Char == OLED_ASCII_08x16_FontCode[i].Char)
{
OLED_Set_Pos(X,Y); // 设置显示坐标 用于显示字符
for(j=0; j<8; j++)
{
OLED_WR_Byte(OLED_ASCII_08x16_FontCode[i].Code[j],OLED_DATA);
}
OLED_Set_Pos(X,Y+1); // 设置显示坐标 用于显示字符
for(j=8; j<16; j++)
{
OLED_WR_Byte(OLED_ASCII_08x16_FontCode[i].Code[j],OLED_DATA);
}
break;
}
}
}
//==================================================================================================
// 实现功能: OLED 指定位置 显示中英文混合字符串 08x16像素
// 函数标记: 外设驱动函数
// 函数说明: 1. 位置选取不恰当 可能造成字符串显示不完全
// 2. 目前能显示英文和汉字混合字符串
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// String - 待显示字符串 取值范围 - ASCII和汉字混合字符串
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_ShowString_16x16(uint8_t X, uint8_t Y, uint8_t *String)
{
uint8_t Position = 0; // 定义局部变量 用于标记字符串位置
while(*String)
{
// 判断字符串中的某字符的编码值是否小于0x80
// 如果小于0x80 即为ASCII字符
// 如果大于0x80 即为汉字字符串
if(*String < 0x80)
{
// 显示ASCII字符
OLED_ShowChar_08x16(X+Position*8, Y, *String);
String++; // 字符串指针移动下一个字节
Position++; // 字符串位置下一个位置
}
else
{
// // 显示汉字
// OLED_ShowChinese_16x16(X+Position*8, Y, (uint8_t*)String);
// String+=2; // 字符串指针移动下一个字节
// Position+=2; // 字符串位置下一个位置
}
}
}
void OLED_ShowArray_06x08(uint8_t X, uint8_t Y, uint8_t *Array, uint8_t Count)
{
uint8_t i; // 定义局部变量 用于函数循环计数
uint8_t j; // 定义局部变量 用于函数循环计数
uint8_t k; // 定义局部变量 用于函数循环计数
uint8_t FontCount; // 定义局部变量 用于记录字符字库个数
FontCount=sizeof(OLED_ASCII_06x08_FontCode)/sizeof(OLED_ASCII_06x08_FontCode[0]);
for(i=0; i<Count; i++)
{
for(j=0; j<FontCount; j++) // 循环查询字符字模位置
{
if(*Array == OLED_ASCII_06x08_FontCode[j].Char)
{
OLED_Set_Pos(X,Y); // 设置显示坐标 用于显示字符
for(k=0; k<6; k++)
{
OLED_WR_Byte(OLED_ASCII_06x08_FontCode[j].Code[k],OLED_DATA);
}
break;
}
}
Array++;
X += 6; // 数组位置下一个位置
}
}
//==================================================================================================
// 实现功能: OLED 指定位置 显示有符号整形数字
// 函数标记: 外设驱动函数
// 函数说明: 1.最大显示5位数字 位置选取不恰当 可能造成数字显示不完全
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// IntegerNumber - 待显示整型数字 取值范围 - -32767~+32768
// Count - 待显示整型数字长度 取值范围 - 0~5;
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_ShowNumber_SignedInteger_06x08(uint8_t X, uint8_t Y, signed short IntegerNumber, uint8_t Count)
{
uint8_t IntegerNumber_Array[5]={0}; // 定义局部数组 用于数组数据存储
// 判断 整型数字正负
if(IntegerNumber < 0)
{
IntegerNumber=0 - IntegerNumber;
OLED_ShowChar_06x08(X, Y, '-');
}
else
{
OLED_ShowChar_06x08(X, Y, '+');
}
// 计算各位数值的字符
if(Count>4) IntegerNumber_Array[0] = (IntegerNumber/10000) % 10 + 0x30;
if(Count>3) IntegerNumber_Array[1] = (IntegerNumber/1000 ) % 10 + 0x30;
if(Count>2) IntegerNumber_Array[2] = (IntegerNumber/100 ) % 10 + 0x30;
if(Count>1) IntegerNumber_Array[3] = (IntegerNumber/10 ) % 10 + 0x30;
if(Count>0) IntegerNumber_Array[4] = (IntegerNumber/1 ) % 10 + 0x30;
// 执行显示操作
OLED_ShowArray_06x08(X+6, Y, &IntegerNumber_Array[5-Count], Count);
}
//==================================================================================================
// 实现功能: OLED 指定位置 显示无符号整形数字
// 函数标记: 外设驱动函数
// 函数说明: 1.最大显示5位数字 位置选取不恰当 可能造成数字显示不完全
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// IntegerNumber - 待显示整型数字 取值范围 - -32767~+32768
// Count - 待显示整型数字长度 取值范围 - 0~5;
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_ShowNumber_UnsignedInteger_06x08(uint8_t X, uint8_t Y, uint16_t IntegerNumber, uint8_t Count)
{
uint8_t IntegerNumber_Array[5]={0}; // 定义局部数组 用于数组数据存储
// 计算各位数值的字符
if(Count>4) IntegerNumber_Array[0] = (IntegerNumber/10000) % 10 + 0x30;
if(Count>3) IntegerNumber_Array[1] = (IntegerNumber/1000 ) % 10 + 0x30;
if(Count>2) IntegerNumber_Array[2] = (IntegerNumber/100 ) % 10 + 0x30;
if(Count>1) IntegerNumber_Array[3] = (IntegerNumber/10 ) % 10 + 0x30;
if(Count>0) IntegerNumber_Array[4] = (IntegerNumber/1 ) % 10 + 0x30;
// 执行显示操作
OLED_ShowArray_06x08(X, Y, &IntegerNumber_Array[5-Count], Count);
}
//==================================================================================================
// 实现功能: OLED 指定位置 显示06x08大小的浮点数字
// 函数标记: 外设驱动函数
// 函数说明: float型数据有效数字显示7位 double型数据有效数字16位
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// FloatNumber - 待显示浮点型数字 取值范围 - -99999.99999~99999.99999
// Count1 - 整数显示位数 取值范围 - 0~5
// Count2 - 小数显示位数 取值范围 - 0~5
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_ShowNumber_Float_06x08(uint8_t X, uint8_t Y, float FloatNumber, uint8_t Count1, uint8_t Count2)
{
uint8_t Number_Integer_Array[5]; // 定义局部数组 用于存储整数位各位数据
uint8_t Number_Decimal_Array[5]; // 定义局部数组 用于存储小数位各位数据
unsigned long Number_Integer = 0; // 定义局部变量 表示浮点数的 整数部分
unsigned long Number_Decimal = 0; // 定义局部变量 表示浮点数的 小数部分
if(FloatNumber < 0)
{
FloatNumber= 0 - FloatNumber;
OLED_ShowChar_06x08(X,Y,'-');
}
else
{
OLED_ShowChar_06x08(X,Y,'+');
}
//----------------------------------------------------------------------------------------------
// 限制 显示字符数
//----------------------------------------------------------------------------------------------
// 由于由于float型的有效十进制数值最多为7位 即整数位 + 小数位 数量一定小于等于7
while((Count1 + Count2 > 7 ))
{
if((Count1 > 5) && (Count1 != 0))
{
--Count1;
}
else
{
--Count2;
}
}
Number_Integer = (unsigned long)(FloatNumber); // 取整数部分
Number_Decimal = (unsigned long)((FloatNumber - Number_Integer + 0.000005) * 1e5); // 取小数部分 1e5科学计数法
Number_Integer_Array[0] = Number_Integer/10000 % 10 + 0x30; // 计算整数部分
Number_Integer_Array[1] = Number_Integer/ 1000 % 10 + 0x30;
Number_Integer_Array[2] = Number_Integer/ 100 % 10 + 0x30;
Number_Integer_Array[3] = Number_Integer/ 10 % 10 + 0x30;
Number_Integer_Array[4] = Number_Integer/ 1 % 10 + 0x30;
Number_Decimal_Array[0] = Number_Decimal/10000 % 10 + 0x30; // 计算小数部分
Number_Decimal_Array[1] = Number_Decimal/ 1000 % 10 + 0x30;
Number_Decimal_Array[2] = Number_Decimal/ 100 % 10 + 0x30;
Number_Decimal_Array[3] = Number_Decimal/ 10 % 10 + 0x30;
Number_Decimal_Array[4] = Number_Decimal/ 1 % 10 + 0x30;
OLED_ShowArray_06x08(X+6, Y, &Number_Integer_Array[5-Count1], Count1); // 显示整数位
OLED_ShowChar_06x08( X+(1+Count1)*6, Y, '.'); // 显示小数点
OLED_ShowArray_06x08(X+(2+Count1)*6, Y, &Number_Decimal_Array[0], Count2); // 显示小数位
}
//==================================================================================================
// 实现功能: OLED 指定位置 显示06x08大小的二进制数字
// 函数标记: 外设驱动函数
// 函数说明: 1. 位置选取不恰当 可能造成字符串显示不完全
// 2. 显示8位二进制数字 主要作为寄存器数据显示
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// BinaryNumber - 待显示二进制数字 取值范围 - 0~4294967295
// Count - 二进制显示位数 取值范围 - 1~16
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_ShowNumber_Binary_06x08(uint8_t X, uint8_t Y, unsigned long BinaryNumber, uint8_t Count)
{
uint8_t i; // 定义局部变量 用于函数循环计数
for(i=Count; i>0; i--)
{
if(BinaryNumber & ( 1 << (Count-1) ))
{
OLED_ShowChar_06x08(X, Y, '1'); // 显示二进制字符'1'
}
else
{
OLED_ShowChar_06x08(X, Y, '0'); // 显示二进制字符'1'
}
BinaryNumber <<= 1; // 移位运算
X += 6; // 数组位置下一个位置
}
}
//==================================================================================================
// 实现功能: OLED 指定位置 显示06x08大小的十六进制数字
// 函数标记: 外设驱动函数
// 函数说明: 1. 位置选取不恰当 可能造成字符串显示不完全
// 2. 显示8位二进制数字 主要作为寄存器数据显示
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// BinaryNumber - 待显示二进制数字 取值范围 - 0~4294967295
// Count - 二进制显示位数 取值范围 - 1~8
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_ShowNumber_Hex_06x08(uint8_t X, uint8_t Y, unsigned long HexNumber, uint8_t Count)
{
uint8_t i; // 定义局部变量 用于函数循环计数
unsigned long Number; // 定义局部变量 用于装载数据
for(i=Count; i>0; i--)
{
Number = HexNumber>>(4*(i-1)) & 0x0000000F;
if(Number<10)
{
OLED_ShowChar_06x08(X, Y, '0'+Number);
}
else
{
OLED_ShowChar_06x08(X, Y, 'A'+(Number-10));
}
X += 6; // 数组位置下一个位置
}
}
//==================================================================================================
// 实现功能: OLED 指定位置 绘制直线数据
// 函数标记: 外设驱动函数
// 函数说明: 该点为8个像素的竖线 并非实际像素点
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// PointData - 直线数据 取值范围 - 0~255
// 输出参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_DrawLine(uint8_t X, uint8_t Y, uint8_t PointData)
{
OLED_WR_Byte(0xB0+Y,OLED_CMD);
OLED_WR_Byte(((X & 0xF0)>>4) | 0x10,OLED_CMD);
OLED_WR_Byte( (X & 0x0F) | 0x01,OLED_CMD);
OLED_WR_Byte(PointData,OLED_DATA);
}
//==================================================================================================
// 实现功能: OLED 指定位置 绘制图像 Draw_BMP
// 函数标记: 外设驱动函数
// 函数说明:
//--------------------------------------------------------------------------------------------------
// 输入参量: X - X方向坐标 取值范围 - 0~127
// Y - Y方向坐标 取值范围 - 0~ 7
// X_Size - X方向尺寸大小 取值范围 - 0~127
// Y_Size - Y方向尺寸大小 取值范围 - 0~7
// Image - 图像数据
// 输出参量: 无
/*功能描述:显示显示BMP图片128×64起始点坐标(x,y),x的范围0~127,y为页的范围0~7*****************/
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void Draw_BMP(uint8_t X0,uint8_t Y0,uint8_t X1,uint8_t Y1,uint8_t BMP[])
{
uint32_t j=0;
uint8_t x,y;
if(Y1%8==0) y=Y1/8;
else y=Y1/8+1;
for(y=Y0;y<Y1;y++)
{
OLED_Set_Pos(X0,y);
for(x=X0;x<X1;x++)
{
OLED_WR_Byte(BMP[j++],OLED_DATA);
}
}
}
//==================================================================================================
实现功能: OLED 指定位置 画点
函数标记: 外设驱动函数
函数说明:
--------------------------------------------------------------------------------------------------
输入参量: //画点
// //x:0~127
// //y:0~63
// //t:1 填充 0,清空
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_DrawDot(uint8_t X,uint8_t Y,uint8_t T)
{
uint8_t pos,bx,temp=0;
if(X>127||Y>63) return;
pos=(Y)/8;
bx=Y%8;
temp=1<<(bx);
if(T) OLED_GRAM[X][pos]|=temp;
else OLED_GRAM[X][pos]&=~temp;
OLED_Refresh_Gram();
}
//==================================================================================================
// 实现功能: OLED LCD_DrawLine画直线函数
// 函数标记: 外设驱动函数
// 函数说明:
//--------------------------------------------------------------------------------------------------
// 输入参量: uint32_t X1, 直线:俩点坐标(x1,y1 ,(x2,y2)
// uint32_t Y1,
// uint32_t X2,
// uint32_t Y2,
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void LCD_DrawLine(uint32_t X1, uint32_t Y1, uint32_t X2,uint32_t Y2)
{
uint32_t t;
int xerr=0,yerr=0,delta_x,delta_y,distance;
int incx,incy,uRow,uCol;
delta_x=X2-X1; //计算坐标增量
delta_y=Y2-Y1;
uRow=X1;
uCol=Y1;
if(delta_x>0)
{
incx=1; //设置单步方向
}
else if(delta_x==0)
{
incx=0;//垂直线
}
else
{
incx=-1;
delta_x=-delta_x;
}
if(delta_y>0)
incy=1;
else if(delta_y==0)
incy=0;//水平线
else
{
incy=-1;
delta_y=-delta_y;
}
if( delta_x>delta_y)
distance=delta_x; //选取基本增量坐标轴
else
distance=delta_y;
for(t=0;t<=distance+1;t++ )//画线输出
{
OLED_DrawDot(uRow,uCol,1);//画点
xerr+=delta_x ;
yerr+=delta_y ;
if(xerr>distance)
{
xerr-=distance;
uRow+=incx;
}
if(yerr>distance)
{
yerr-=distance;
uCol+=incy;
}
}
}
//==================================================================================================
///**
// * @brief 在 oled 显示器上使用 Bresenham 算法画圆
// * @param usX_Center :在特定扫描方向下圆心的X坐标
// * @param usY_Center :在特定扫描方向下圆心的Y坐标
// * @param usRadius:圆的半径(单位:像素)
// * @param ucFilled :选择是否填充该圆
// * 该参数为以下值之一:
// * @arg 0 :空心圆
// * @arg 1 :实心圆
// * @retval 无
// */
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_DrawCircle( uint16_t usX_Center, uint16_t usY_Center, uint16_t usRadius, uint8_t ucFilled )
{
int16_t sCurrentX, sCurrentY;
int16_t sError;
sCurrentX = 0; sCurrentY = usRadius;
sError = 3 - ( usRadius << 1 ); //判断下个点位置的标志
while ( sCurrentX <= sCurrentY )
{
int16_t sCountY;
if ( ucFilled )
for ( sCountY = sCurrentX; sCountY <= sCurrentY; sCountY ++ )
{
OLED_DrawDot ( usX_Center + sCurrentX, usY_Center + sCountY,OLED_DATA ); //1,研究对象
OLED_DrawDot ( usX_Center - sCurrentX, usY_Center + sCountY,OLED_DATA); //2
OLED_DrawDot ( usX_Center - sCountY, usY_Center + sCurrentX,OLED_DATA); //3
OLED_DrawDot ( usX_Center - sCountY, usY_Center - sCurrentX,OLED_DATA ); //4
OLED_DrawDot ( usX_Center - sCurrentX, usY_Center - sCountY,OLED_DATA ); //5
OLED_DrawDot ( usX_Center + sCurrentX, usY_Center - sCountY,OLED_DATA ); //6
OLED_DrawDot ( usX_Center + sCountY, usY_Center - sCurrentX,OLED_DATA ); //7
OLED_DrawDot ( usX_Center + sCountY, usY_Center + sCurrentX,OLED_DATA ); //0
}
else
{
OLED_DrawDot ( usX_Center + sCurrentX, usY_Center + sCurrentY,OLED_DATA ); //1,研究对象
OLED_DrawDot ( usX_Center - sCurrentX, usY_Center + sCurrentY,OLED_DATA ); //2
OLED_DrawDot ( usX_Center - sCurrentY, usY_Center + sCurrentX,OLED_DATA ); //3
OLED_DrawDot ( usX_Center - sCurrentY, usY_Center - sCurrentX,OLED_DATA ); //4
OLED_DrawDot ( usX_Center - sCurrentX, usY_Center - sCurrentY,OLED_DATA ); //5
OLED_DrawDot ( usX_Center + sCurrentX, usY_Center - sCurrentY,OLED_DATA); //6
OLED_DrawDot ( usX_Center + sCurrentY, usY_Center - sCurrentX,OLED_DATA); //7
OLED_DrawDot ( usX_Center + sCurrentY, usY_Center + sCurrentX,OLED_DATA ); //0
}
sCurrentX ++;
if ( sError < 0 )
sError += 4 * sCurrentX + 6;
else
{
sError += 10 + 4 * ( sCurrentX - sCurrentY );
sCurrentY --;
}
}
}
//==================================================================================================
// 实现功能: OLED LCD_DrawRectangle
// 函数标记: 外设驱动函数
// 函数说明:
//--------------------------------------------------------------------------------------------------
// 输入参量: uint32_t X1, 长度 宽度:俩点坐标(x1,y1 ,(x2,y2)
// uint32_t Y1,
// uint32_t X2,
// uint32_t Y2,
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void LCD_DrawRectangle(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2)
{
LCD_DrawLine(X1,Y1,X2,Y1);
LCD_DrawLine(X1,Y1,X1,Y2);
LCD_DrawLine(X1,Y2,X2,Y2);
LCD_DrawLine(X2,Y1,X2,Y2);
}
//==================================================================================================
// 实现功能: OLED OLED_Fill_Draw_circle //画圆填充
// 函数标记: 外设驱动函数
// 函数说明:
//--------------------------------------------------------------------------------------------------
// 输入参量: //写画实心圆心(x0,y0),半径r,dot=1填充,dot=0不填充
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_Fill_Draw_circle(uint8_t X0,uint8_t Y0,uint8_t r,uint8_t dot)
{
uint8_t x = 0,y = 0,R = 0;
for(x = X0-r;x <= X0+r;x++)
{
for(y = Y0-r; y <= Y0+r ;y++ )
{
R = sqrt(pow(r,2)-pow(x-X0,2))+Y0; //圆方程 x,y反置
if( (y >= Y0 && y <= R) || (y < Y0 && y >= 2*Y0-R )|| dot == 0 )
{ //点限制在 圆方程内
OLED_DrawDot(y,x,dot);
}
}
}
}
//==================================================================================================
// 实现功能: OLED_RollDisplay
// 函数标记: 外设驱动函数
// 函数说明: //水平滚动
// 函数完成情况:有问题
//--------------------------------------------------------------------------------------------------
// 输入参量: 无
//--------------------------------------------------------------------------------------------------
// | - | - | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//==================================================================================================
void OLED_RollDisplay(void)
{
OLED_WR_Byte(0x2E,OLED_CMD); //关闭滚动
OLED_WR_Byte(0x29,OLED_CMD); //水平向左或者右滚动 2A/29
OLED_WR_Byte(0x00,OLED_CMD); //虚拟字节
OLED_WR_Byte(0x00,OLED_CMD); //起始页 0
OLED_WR_Byte(0x07,OLED_CMD); //滚动时间间隔
OLED_WR_Byte(0x07,OLED_CMD); //终止页 7
OLED_WR_Byte(0x00,OLED_CMD); //虚拟字节
OLED_WR_Byte(0xFF,OLED_CMD); //虚拟字节
OLED_WR_Byte(0x2F,OLED_CMD); //开启滚动
}
OLED.H
#ifndef __OLED_H
#define __OLED_H
#include "main.h"
//--------------------------------------------------------------------------------------------------
// 宏自定义声明 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//--------------------------------------------------------------------------------------------------
#define OLED_MODE 0
#define SIZE 8
#define XLevelL 0x00
#define XLevelH 0x10
#define Max_Column 128
#define Max_Row 64
#define Brightness 0xFF
#define X_WIDTH 128
#define Y_WIDTH 64
//--------------------------------------------------------------------------------------------------
// 定义引用变量 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//--------------------------------------------------------------------------------------------------
#define OLED_SDA_GPIO_PIN GPIO_PIN_15
#define OLED_SCL_GPIO_PIN GPIO_PIN_14
#define OLED_GPIO_PORT CW_GPIOC
//--------------------------------------------------------------------------------------------------
// 硬件端口定义 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//--------------------------------------------------------------------------------------------------
//-----------------OLED IIC端口定义----------------
#define OLED_SCLK_Clr() GPIO_ResetBits(OLED_GPIO_PORT,GPIO_PIN_14)//SCL IIC接口的时钟信号
#define OLED_SCLK_Set() GPIO_SetBits(OLED_GPIO_PORT,GPIO_PIN_14)
#define OLED_SDIN_Clr() GPIO_ResetBits(OLED_GPIO_PORT,GPIO_PIN_15)//SDA IIC接口的数据信号
#define OLED_SDIN_Set() GPIO_SetBits(OLED_GPIO_PORT,GPIO_PIN_15)
#define OLED_CMD 0 //写命令
#define OLED_DATA 1 //写数据
//--------------------------------------------------------------------------------------------------
// 引用函数声明 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//--------------------------------------------------------------------------------------------------
//OLED控制用函数
void OLED_WR_Byte(unsigned dat,unsigned cmd);
void OLED_Display_On(void);
void OLED_Display_Off(void);
void OLED_Init(void);
void OLED_Clear(void);
//oled 延迟函数
void Delay_50ms(uint32_t Delay_50ms);
void Delay_1ms(uint32_t Delay_1ms);
//IIC控制函数
void IIC_Start(void);
void IIC_Stop(void);
void Write_IIC_Command(uint8_t IIC_Command);
void Write_IIC_Data(uint8_t IIC_Data);
void Write_IIC_Byte(uint8_t IIC_Byte);
void IIC_Wait_Ack(void);
//oled 操作函数
void OLED_Fill(uint8_t fill_Data); //全屏填充
void OLED_Refresh_Gram(void);
void OLED_Set_Pos(uint8_t X, uint8_t Y);
void OLED_AreaClear(uint8_t X, uint8_t Y, uint8_t X_Size, uint8_t Y_Size);
// OLED 显示字符、字符串 汉字
void OLED_ShowChar_06x08(uint8_t X, uint8_t Y, uint8_t Char);
void OLED_ShowString_06x08(uint8_t X, uint8_t Y, uint8_t *String);
void OLED_ShowCHinese(uint8_t X,uint8_t Y,uint8_t Chinese);//显示汉字函数
void OLED_ShowChar_08x16(uint8_t X, uint8_t Y, uint8_t Char);
//void OLED_ShowChinese_16x16(uint8_t X, uint8_t Y, uint8_t *Chinese);
void OLED_ShowString_16x16(uint8_t X, uint8_t Y, uint8_t *String);
void OLED_ShowArray_06x08(uint8_t X, uint8_t Y, uint8_t *Array, uint8_t Count);
// OLED 显示整型数字/浮点型数字/二进制数字/十六进制数字
void OLED_ShowNumber_SignedInteger_06x08(uint8_t X, uint8_t Y, int16_t IntegerNumber, uint8_t Count);
void OLED_ShowNumber_UnsignedInteger_06x08(uint8_t X, uint8_t Y, uint16_t IntegerNumber, uint8_t Count);
void OLED_ShowNumber_Float_06x08(uint8_t X, uint8_t Y, float FloatNumber, uint8_t Count1, uint8_t Count2);
void OLED_ShowNumber_Binary_06x08(uint8_t X, uint8_t Y, unsigned long BinaryNumber, uint8_t Count);
void OLED_ShowNumber_Hex_06x08(uint8_t X, uint8_t Y, unsigned long BinaryNumber, uint8_t Count);
// OLED 绘制直线
void OLED_DrawLine(uint8_t X, uint8_t Y, uint8_t PointData);
// OLED 绘制图像
void OLED_RollDisplay(void);//设置水平左右移
void Draw_BMP(uint8_t x0,uint8_t y0,uint8_t x1,uint8_t y1,uint8_t BMP[]);
//画点函数
void OLED_DrawDot(uint8_t X,uint8_t Y,uint8_t T);
//画直线函数
void LCD_DrawLine(uint32_t X1, uint32_t Y1, uint32_t X2,uint32_t Y2);
//dot ==1 表示亮显示出来
void OLED_Fill_Draw_circle(uint8_t X0,uint8_t Y0,uint8_t r,uint8_t dot);
//ucFilled ==1 表示填充 //画直圆函数
void OLED_DrawCircle( uint16_t usX_Center, uint16_t usY_Center, uint16_t usRadius, uint8_t ucFilled );
//画矩形函数
void LCD_DrawRectangle(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2);
#endif
Font.H
#ifndef __OLEDFONT_H
#define __OLEDFONT_H
//常用ASCII表
//偏移量32
//ASCII字符集
//偏移量32
//大小:12*6
/************************************6*8的点阵************************************/
const struct struct_OLED_ASCII_06x08 // 结构体定义
{
unsigned char Char; // 编码 ASCII字符由1个字节组成
unsigned char Code[6]; // 编码内容
} OLED_ASCII_06x08_FontCode[] =
{
' ',{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // (空格)
'!',{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 }, // !
'"',{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 }, // "
'#',{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 }, // #
'$',{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, // $
'%',{ 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 }, // %
'&',{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 }, // &
'\'',{ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 }, // '
'(',{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 }, // (
')',{ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 }, // )
'*',{ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, // *
'+',{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, // +
',',{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, // ,
'-',{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, // -
'.',{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, // .
'/',{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, // /
'0',{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E }, // 0
'1',{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 }, // 1
'2',{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 }, // 2
'3',{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 }, // 3
'4',{ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 }, // 4
'5',{ 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 }, // 5
'6',{ 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 }, // 6
'7',{ 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 }, // 7
'8',{ 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 }, // 8
'9',{ 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E }, // 9
':',{ 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 }, // :
';',{ 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 }, // ;
'<',{ 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 }, // <
'=',{ 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 }, // =
'>',{ 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 }, // >
'?',{ 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 }, // ?
'@',{ 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E }, // @
'A',{ 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C }, // A
'B',{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 }, // B
'C',{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 }, // C
'D',{ 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C }, // D
'E',{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 }, // E
'F',{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 }, // F
'G',{ 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A }, // G
'H',{ 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F }, // H
'I',{ 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 }, // I
'J',{ 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 }, // J
'K',{ 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 }, // K
'L',{ 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 }, // L
'M',{ 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F }, // M
'N',{ 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F }, // N
'O',{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E }, // O
'P',{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 }, // P
'Q',{ 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E }, // Q
'R',{ 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 }, // R
'S',{ 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 }, // S
'T',{ 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 }, // T
'U',{ 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F }, // U
'V',{ 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F }, // V
'W',{ 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F }, // W
'X',{ 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 }, // X
'Y',{ 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 }, // Y
'Z',{ 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 }, // Z
'[',{ 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 }, // [
']',{ 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 }, // ]
'^',{ 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 }, // ^
'_',{ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 }, // _
'`',{ 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 }, // `
'a',{ 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 }, // a
'b',{ 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 }, // b
'c',{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 }, // c
'd',{ 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F }, // d
'e',{ 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 }, // e
'f',{ 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 }, // f
'g',{ 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C }, // g
'h',{ 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 }, // h
'i',{ 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 }, // i
'j',{ 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 }, // j
'k',{ 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 }, // k
'l',{ 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 }, // l
'm',{ 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 }, // m
'n',{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 }, // n
'o',{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 }, // o
'p',{ 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 }, // p
'q',{ 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC }, // q
'r',{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 }, // r
's',{ 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 }, // s
't',{ 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 }, // t
'u',{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C }, // u
'v',{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C }, // v
'w',{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C }, // w
'x',{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 }, // x
'y',{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C }, // y
'z',{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 }, // z
'|',{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 } // |
};
/****************************************8*16的点阵************************************/
const struct struct_OLED_ASCII_08x16 // 结构体定义
{
unsigned char Char; // 编码 ASCII字符由1个字节组成
unsigned char Code[16]; // 编码内容
} OLED_ASCII_08x16_FontCode[] =
{
' ',{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // (空格)
'!',{ 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00 }, // !
'"',{ 0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // "
'#',{ 0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00 }, // #
'$',{ 0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00 }, // $
'%',{ 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00 }, // %
'&',{ 0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10 }, // &
'\'',{ 0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // '
'(',{ 0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00 }, // (
')',{ 0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00 }, // )
'*',{ 0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00 }, // *
'+',{ 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00 }, // +
',',{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00 }, // ,
'-',{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01 }, // -
'.',{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00 }, // .
'/',{ 0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00 }, // /
'0',{ 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00 }, // 0
'1',{ 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00 }, // 1
'2',{ 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00 }, // 2
'3',{ 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00 }, // 3
'4',{ 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00 }, // 4
'5',{ 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00 }, // 5
'6',{ 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00 }, // 6
'7',{ 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00 }, // 7
'8',{ 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00 }, // 8
'9',{ 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00 }, // 9
':',{ 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00 }, // :
';',{ 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00 }, // ;
'<',{ 0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00 }, // <
'=',{ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00 }, // =
'>',{ 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00 }, // >
'?',{ 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00 }, // ?
'@',{ 0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00 }, // @
'A',{ 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20 }, // A
'B',{ 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00 }, // B
'C',{ 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00 }, // C
'D',{ 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00 }, // D
'E',{ 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00 }, // E
'F',{ 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00 }, // F
'G',{ 0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00 }, // G
'H',{ 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20 }, // H
'I',{ 0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00 }, // I
'J',{ 0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00 }, // J
'K',{ 0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00 }, // K
'L',{ 0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00 }, // L
'M',{ 0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00 }, // M
'N',{ 0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00 }, // N
'O',{ 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00 }, // O
'P',{ 0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00 }, // P
'Q',{ 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00 }, // Q
'R',{ 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20 }, // R
'S',{ 0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00 }, // S
'T',{ 0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00 }, // T
'U',{ 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00 }, // U
'V',{ 0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00 }, // V
'W',{ 0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00 }, // W
'X',{ 0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20 }, // X
'Y',{ 0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00 }, // Y
'Z',{ 0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00 }, // Z
'[',{ 0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00 }, // [
']',{ 0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00 }, // ]
'^',{ 0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // ^
'_',{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 }, // _
'`',{ 0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // `
'a',{ 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20 }, // a
'b',{ 0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00 }, // b
'c',{ 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00 }, // c
'd',{ 0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20 }, // d
'e',{ 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00 }, // e
'f',{ 0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00 }, // f
'g',{ 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00 }, // g
'h',{ 0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20 }, // h
'i',{ 0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00 }, // i
'j',{ 0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00 }, // j
'k',{ 0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00 }, // k
'l',{ 0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00 }, // l
'm',{ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F }, // m
'n',{ 0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20 }, // n
'o',{ 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00 }, // o
'p',{ 0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00 }, // p
'q',{ 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80 }, // q
'r',{ 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00 }, // r
's',{ 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00 }, // s
't',{ 0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00 }, // t
'u',{ 0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20 }, // u
'v',{ 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00 }, // v
'w',{ 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00 }, // w
'x',{ 0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00 }, // x
'y',{ 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00 }, // y
'z',{ 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00 }, // z
'{',{ 0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40 }, // {
'|',{ 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00 }, // |
'}',{ 0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00 }, // }
'~',{ 0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // ~
};
char CHinese[][32]={
{0x00,0x00,0xF0,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0xF0,0x00,0x00,0x00},
{0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x0F,0x00,0x00,0x00},/*"中",0*/
{0x40,0x40,0x40,0x5F,0x55,0x55,0x55,0x75,0x55,0x55,0x55,0x5F,0x40,0x40,0x40,0x00},
{0x00,0x40,0x20,0x0F,0x09,0x49,0x89,0x79,0x09,0x09,0x09,0x0F,0x20,0x40,0x00,0x00},/*"景",1*/
{0x00,0xFE,0x02,0x42,0x4A,0xCA,0x4A,0x4A,0xCA,0x4A,0x4A,0x42,0x02,0xFE,0x00,0x00},
{0x00,0xFF,0x40,0x50,0x4C,0x43,0x40,0x40,0x4F,0x50,0x50,0x5C,0x40,0xFF,0x00,0x00},/*"园",2*/
{0x00,0x00,0xF8,0x88,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x88,0xF8,0x00,0x00,0x00},
{0x00,0x00,0x1F,0x08,0x08,0x08,0x08,0x7F,0x88,0x88,0x88,0x88,0x9F,0x80,0xF0,0x00},/*"电",3*/
{0x80,0x82,0x82,0x82,0x82,0x82,0x82,0xE2,0xA2,0x92,0x8A,0x86,0x82,0x80,0x80,0x00},
{0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"子",4*/
{0x20,0x20,0x24,0x24,0x24,0xA4,0x24,0x24,0x20,0xFF,0x20,0x22,0x2C,0x20,0x20,0x00},
{0x40,0xC0,0x7E,0x40,0x40,0x3F,0x22,0x22,0x20,0x03,0x0C,0x10,0x20,0x40,0xF8,0x00},/*"武",5*/
/* (16 X 16 , 宋体 )*/
{0x10,0x60,0x02,0x0C,0xC0,0x02,0x1E,0xE2,0x02,0x02,0x02,0xE2,0x1E,0x00,0x00,0x00},
{0x04,0x04,0x7C,0x03,0x80,0x80,0x40,0x20,0x13,0x0C,0x13,0x20,0x40,0x80,0x80,0x00},/*"汉",6*/
/* (16 X 16 , 宋体 )*/
{0x04,0x04,0x04,0x04,0x1F,0x04,0x24,0x44,0x84,0x04,0x1F,0x04,0x04,0x04,0x04,0x00},
{0x10,0x08,0x06,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x70,0x01,0x02,0x0C,0x00},/*"芯",7*/
/* (16 X 16 , 宋体 )*/
{0x10,0x60,0x02,0x8C,0x00,0xFE,0x02,0xF2,0x52,0x5A,0x56,0x52,0x52,0xF2,0x02,0x00},
{0x04,0x04,0x7E,0x41,0x30,0x0F,0x20,0x13,0x49,0x81,0x7F,0x01,0x09,0x13,0x20,0x00},/*"源",8*/
/* (16 X 16 , 宋体 )*/
};
#endif