标题:
在stm32f4将字变大的源码
[打印本页]
作者:
xiangfangyue
时间:
2018-4-30 17:39
标题:
在stm32f4将字变大的源码
单片机源程序如下:
#include "stm32f4xx.h"
#include "usart.h"
#include "led.h"
#include "gpio.h"
#include "stdio.h"
#include "timer.h"
#include "lcd.h"
u8 word[] =
{
0x20,0x02,0x70,0x0A,0x1E,0x12,0x10,0x12,0x10,0x02,0xFF,0x7F,0x10,0x02,0x10,0x22,0x50,0x22,0x30,0x12,0x18,0x0C,0x16,0x44,0x10,0x4A,0x10,0x51,0xD4,0x60,0x08,0x40
};
void drawBlock(u16 xPos, u16 yPos, u16 w, u16 color);
void drawWord(u16 xPos, u16 yPos, u8 *p, u16 lineColor, u16 backColor);
void fjByte(u16 xPos, u16 yPos, u8 byte, u16 lineColor, u16 backColor); // 显示8个点
// 放大
void pointToBig(u16 xPos, u16 yPos, u16 color, u8 bs);
void fjByteToBig(u16 xPos, u16 yPos, u8 byte, u16 lineColor, u16 backColor, u8 bs);
void drawWordToBig(u16 xPos, u16 yPos, u8 *p, u16 lineColor, u16 backColor, u8 bs);
int main()
{
LCD_Init();
drawWordToBig(10, 100, word, 0x3838, 0x0000, 10);
while(1)
{
}
}
void pointToBig(u16 xPos, u16 yPos, u16 color, u8 bs)
{
u8 i, j;
for(i = 0; i < bs; i++)
{
for(j = 0; j < bs; j++)
{
LCD_Draw_Point(xPos+j, yPos+i, color);
}
}
}
void fjByteToBig(u16 xPos, u16 yPos, u8 byte, u16 lineColor, u16 backColor, u8 bs)
{
u8 i;
for(i = 0; i < 8; i++)
{
if(byte & (1 << i))
{
pointToBig(xPos+i*bs, yPos, lineColor, bs);
}
else
{
pointToBig(xPos+i*bs, yPos, backColor, bs);
}
}
}
void fjByte(u16 xPos, u16 yPos, u8 byte, u16 lineColor, u16 backColor)
{
u8 i;
for(i = 0; i < 8; i++)
{
if(byte & (1 << i))
{
LCD_Draw_Point(xPos + i, yPos, lineColor);
}
else
{
LCD_Draw_Point(xPos + i, yPos, backColor);
}
}
}
void drawWordToBig(u16 xPos, u16 yPos, u8 *p, u16 lineColor, u16 backColor, u8 bs)
{
u8 i;
for(i = 0; i < 16; i++)
{
fjByteToBig(xPos, yPos+i*bs, p[2*i], lineColor, backColor, bs);
fjByteToBig(xPos+8*bs, yPos+i*bs, p[2*i+1], lineColor, backColor, bs);
}
}
void drawWord(u16 xPos, u16 yPos, u8 *p, u16 lineColor, u16 backColor)
{
u8 i;
for(i = 0; i < 16; i++)
{
fjByte(xPos, yPos+i, p[2*i], lineColor, backColor);
fjByte(xPos+8, yPos+i, p[2*i+1], lineColor, backColor);
}
}
void drawBlock(u16 xPos, u16 yPos, u16 w, u16 color)
{
u16 x, y;
for(y = yPos; y < yPos + w; y++)
{
for(x = xPos; x < xPos + w; x++)
{
LCD_Draw_Point(x, y, color);
}
}
}
// RGB
// 0011 1 000 000 0 0000
// 16λ
// 5 6 5
//
复制代码
所有资料51hei提供下载:
08_变大.rar
(198.67 KB, 下载次数: 6)
2018-5-1 03:52 上传
点击文件名下载附件
cortexM4 写大字
下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1